Spec pipeline
#[OA\Components] holds components declared on its members
A class carrying #[OA\Components] now takes in the components declared on its methods. One without a key is named after the method, the way a class names its own. Many schemas can share one class, one method each, and each method's docblock becomes its description. A parameter is still keyed by its name:. (#2261)
#[OA\Components]
class Models
{
/** A thing someone owns. */
#[OA\Schema(type: OA\Type::Object, properties: ['id' => OA\Type::Integer])]
public function thing() {}
#[OA\Response(description: 'No such thing')]
public function notFound() {}
}This gives #/components/schemas/thing and #/components/responses/notFound.
Smaller fixes
- The parameter subclasses (
Parameter\Query,Path,Header,Cookie),MediaType\JsonandXml, and the typed security schemes acceptcomponent:. Before, following the 6.12 deprecation on one of them failed withUnknown named parameter $componentand the class was skipped. (#2260) - Attributes declared on a constructor are reported with a warning. Spec still ignores them, so they belong on the class. (#2257)
Rector set
The classic-to-spec set now also:
- rewrites the type names classic maps,
type: 'long'for example, to the type and format they stand for (#2255) - turns a reference in a
Property'sschema:, a pointer or a::class, into the nested schema'sref(#2258) - rewrites every literal item of
security:to aSecurity\Requirement, bare scheme names and arrays alike (#2259, #2262)
Output changes
Hybrid keeps a security requirement written as a scheme name
This changes hybrid output. Classic reads security: ['bearerAuth'] as that scheme with no scopes. Hybrid dropped the string without a word and wrote security: [], so the operation was documented as public. It now reads it as classic does, and warns, since spec does not accept the form. Spec used to crash on it with a TypeError. It now drops it with a warning, and the operation falls back to the requirements declared above it. (#2259)
Hybrid keeps schema components declared on a method
This changes hybrid output. A named Schema on a method, #[OAT\Schema(schema: 'Thing', ...)] on a model() method for example, is a component in classic. Hybrid dropped it, and every $ref to it pointed at nothing. It is now kept as classic keeps it. (#2256)
Classic type aliases in hybrid and spec
This changes hybrid and spec output. Hybrid and spec wrote type: 'long', 'int', 'float', 'bool', 'date' and the other names classic maps as they were, which is not a valid type, with an "unknown type" warning. They now get the type and format classic gives them, integer with int64 for long for example, and a deprecation per alias in place of the warning. The translation is removed in 8.0, and -c typeAliases.enabled=false switches it off now. (#2255)
What's Changed
- feat(Augmenter): translate classic type aliases in hybrid and spec by @DerManoMann in #2255
- fix(HybridBridge): keep schema components declared on methods by @DerManoMann in #2256
- fix(Spec): report attributes declared on a constructor by @DerManoMann in #2257
- fix(Rector): turn a reference in a Property schema into a ref by @DerManoMann in #2258
- fix(Security): handle a bare scheme name in security requirements by @DerManoMann in #2259
- fix(Spec): accept component on the parameter, media type and security scheme subclasses by @DerManoMann in #2260
- feat(Spec): let a #[Components] class hold components declared on its methods by @DerManoMann in #2261
- feat(Rector): rewrite security requirement arrays to Security\Requirement by @DerManoMann in #2262
Full Changelog: 6.14.0...6.15.0