docs/reference/augmenters.md
This page is generated automatically from the swagger-php sources.
For improvements head over to GitHub and create a PR ;)
Augmenters enrich the collected specification with inferred data before compilation. They run in three groups — resolve (type inference, refs), reduce (filtering, cleanup), and augment (docblocks, operation ids, tags) — and are listed below in execution order.
Augmenters are part of the spec-attributes pipeline (--mode spec or --mode hybrid).
The -c option allows to specify a name/value pair with the name consisting
of the augmenter name (starting lowercase) and option name separated by a dot (.).
> ./vendor/bin/openapi --mode spec -c operationId.hash=true // ...
> ./vendor/bin/openapi --mode spec -c pathFilter.tags[]=/pets/ -c pathFilter.tags[]=/store/ // ...
Configuration can be set using the Builder::withAugmenters() method to access the pipeline
and configure individual augmenters via Pipeline::get().
(new Builder())
->withAugmenters(function ($pipeline) {
$pipeline->get(Augmenter\OperationId::class)->setHash(true);
$pipeline->get(Augmenter\PathFilter::class)->setTags(['/pets/', '/store/']);
});
Expands PHP class hierarchy into OpenAPI composition (allOf).
For each schema backed by a class reflector, walks parents, traits, and interfaces:
After expansion, if a schema has both allOf and properties, the properties are moved into a dedicated allOf entry (anonymous schema with type: object).
OpenApi\Utils\AttributeFactory · default: OpenApi\Utils\AttributeFactoryOpenApi\Utils\TokenScanner · default: OpenApi\Utils\TokenScannerInfers component names from PHP reflectors when not explicitly set.
Sets schema name from the class/interface/trait/enum short name, and parameter component key from its name property.
Expands PHP enums into schema enum values.
For schemas attached to a PHP enum, determines schema name, type, and enum values. Also resolves UnitEnum instances and enum class-strings in any schema's enum array.
Rules for name vs. value:
string · default: nullResolves PathItem prefixes, clones metadata to operations, and sets path-level output.
Walks the class hierarchy to compose path prefixes from ancestor PathItems, prepends them to operation paths, clones tags/security/responses to operations that don't declare their own, and marks PathItems that have spec-level output (parameters, summary, description, servers) with their resolved path.
Infers schema type, format, nullable, items, etc. from PHP type declarations and docblocks.
Walks all properties and parameters in the specification and fills their schema fields from the attached reflector's type information.
OpenApi\Type\TypeResolver · default: OpenApi\Type\TypeResolverResolves FQCN-based $ref values to JSON Reference paths.
Builds a map of class names to their component paths and rewrites any $ref that looks like a FQCN into the proper #/components/... path.
Filters operations by tag and/or path patterns.
If no tags or paths filters are set, no filtering is performed. All filter expressions must be valid regular expressions (with delimiters).
array · default: []array · default: []Removes unreferenced components from the specification.
Iterates multiple times to catch nested dependencies (a schema only referenced by another unused schema should also be removed).
bool · default: trueRe-keys MediaType encoding lists by property name.
The assembler collects Encoding objects as a flat list via contains(). The compiler expects them as an associative array keyed by the property name the encoding applies to.
Fills summary, description, and deprecated from PHP docblock comments.
Walks all attributes in the specification that have summary/description properties and populates them from the reflector's docblock when not explicitly set.
OpenApi\Utils\DocBlockParser · default: OpenApi\Utils\DocBlockParserGenerates operationId for operations that don't have one explicitly set.
bool · default: trueEnsures all tags used on operations exist in the global tags list.
Adds missing Tag objects for any tag name referenced by operations. Removes unused declared tags unless whitelisted.
array · default: []bool · default: trueGenerates a description for enum-based properties.
bool · default: false