7.12 adds a hand-written base document on the command line, lets a plugin add the sources a build reads, and describes more of a class without #[OA\Schema]: a schema declared on a method is typed from its return type, and a class whose members carry attributes is a schema where something references it. It also fixes how a PathItem's security combines with an operation's.
Most of this changes the generated document. Changed output in 7.12 has the details.
Added
openapi --documentadds a hand-written OpenAPI 3.1 document to the build, asBuilder::withDocument()does, and can be repeated (#2457, cookbook)Hooks::addSource(), so a plugin adds to the sources a build reads, for example the controllers a framework's router knows.openapitakes no paths when--pluginor--discover-pluginsis given (#2464, docs)
Changed output
- Spec and hybrid: spec attributes on a protected or private method are read. Before, they were left out without a message (#2458)
- Spec and hybrid: an operation with
security: []below aPathItemwithsecurityhas no security. Before, it got thePathItem's requirements (#2459) - Spec and hybrid: an operation gets each of its
PathItem's security requirements unless it has one naming the same schemes. Before, some were dropped without a message or added beside the operation's own, and an array requirement raised a PHP warning or stopped the build (#2460) - Spec and hybrid: a security scheme named only by a requirement written as an array is kept by cleanup (#2461)
- Hybrid: a base document's root fields are used only where the classic attributes have none, as with spec attributes (#2462)
- Spec and hybrid: where two documents describe the same thing, the later one wins. Before, the first one did (#2463)
- Spec and hybrid: a component schema declared on a method takes its type from the return type, and an array shape fills in the properties the schema declares. Before, the schema was empty, or took nothing from the shape once it declared a property (#2469)
- Spec and hybrid: a referenced class without
#[OA\Schema]whose members carry spec attributes is a schema component, and so is a referenced parent class, written asallOfwith a reference to it. Before, the member attributes were left out and the parent's properties inlined. Spec warns about each member attribute of a class that nothing references, extends or implements (#2470) - Where two schemas have the same name and only one of them is declared on its class, the declared one is kept. Before, the last one was (#2470)
Changed
Builder::withPlugins()passes plugin settings that are a list, or a mix of list entries and named ones, on to the plugin. Before, it skipped the plugin with an error. A plugin that takes no list now reports one itself (#2471, docs)- A base document's root fields are added after every
withSpecification()hook, andBuilder::addDocumentRoot()adds them. A subclass callingaddDocument()itself callsaddDocumentRoot()as well (#2462) - The modes page in the guide names the output differences between classic and spec attributes (#2472)
What's Changed
- feat(Console): add
--documentfor a hand-written base document by @DerManoMann in #2457 - fix(Utils): read attributes on methods of any visibility by @DerManoMann in #2458
- fix(Augmenter): leave an operation with security: [] without its PathItem's security by @DerManoMann in #2459
- fix(Augmenter): match PathItem security requirements by the schemes they name by @DerManoMann in #2460
- fix(Augmenter): keep security schemes named by raw array requirements by @DerManoMann in #2461
- fix(Builder): add a document's root fields after the hybrid bridge by @DerManoMann in #2462
- fix(Builder): a later document wins over an earlier one by @DerManoMann in #2463
- chore(deps-dev): update rector/rector requirement from 2.8.5 to 2.9.2 by @dependabot[bot] in #2466
- feat(Builder): let a plugin add sources by @DerManoMann in #2464
- test(Compiler): merge tests that differ only in their subject by @DerManoMann in #2467
- docs(Roadmap): keep
OpenApi\Specas deprecated aliases through 8.x by @DerManoMann in #2468 - feat(Builder): pass plugin settings that are a list on to the plugin by @DerManoMann in #2471
- chore(deps-dev): bump @redocly/cli from 2.82.0 to 2.84.0 in the npm group across 1 directory by @dependabot[bot] in #2465
- docs(Guide): point the modes page at the output differences by @DerManoMann in #2472
- feat(Augmenter): type a schema declared on a method from its return type by @DerManoMann in #2469
- feat(Resolver): a referenced class whose members carry attributes is a schema by @DerManoMann in #2470
Full Changelog: 7.11.0...7.12.0