Spec Attribute Reference โ
This page is generated automatically from the swagger-php sources.
For improvements head over to GitHub and create a PR ๐
Spec attributes are typed PHP 8.1+ attributes in the OpenApi\Spec namespace โ the foundation of the spec-attributes pipeline (--mode spec or --mode hybrid).
They are immutable data containers with no serialization logic. Relationships between attributes are declared via contains() (what children an attribute absorbs) and merge() (what parent an attribute composes into). The Assembler resolves nesting, and Augmenters enrich the collected specification before compilation.
Typed subclasses (e.g. Operation\Get, Parameter\Path, Flow\AuthorizationCode) pre-fill common fields to reduce boilerplate โ the base class can always be used directly.
Spec Attributes โ
Attachable โ
Base class for custom attributes.
By default not allowed to contain other attributes, but can be inline nested into any other attribute (including itself).
Components โ
Container for reusable component definitions.
Place on a class to declare standalone components that go into the components section of the OpenAPI document. The Components attribute itself is not emitted โ its children are promoted to their respective Specification buckets.
The primary use case is for DTOs that are NOT roots and therefore cannot be declared at class level on their own: Parameter, Header, Link, and Example. Other types (Schema, PathItem, SecurityScheme, named Response/RequestBody) are already roots and can be declared directly on a class without needing a Components wrapper.
#[Components] class SharedComponents { #[Parameter(parameter: 'tenant_id', name: 'tenant_id', in: 'path', schema: new Schema(type: 'string'))] public string $tenantId;
#[Header(header: 'X-Rate-Limit', schema: new Schema(type: 'integer'))]
public string $rateLimit;
#[Example(example: 'dog', summary: 'A dog', value: ['name' => 'Fido'])]
public string $dogExample;
}
Nested elements โ
Schema, Parameter, Response, RequestBody, Header, Security\Scheme, Link, Example, PathItem
Contact โ
Contact information for the exposed API.
Allowed in โ
Parameters โ
- name :
string|nullThe identifying name of the contact person/organization - url :
string|nullA URL pointing to the contact information - email :
string|nullThe email address of the contact person/organization
Reference โ
- Contact Object โ
Discriminator โ
Aids in serialization, deserialization, and validation when request bodies or responses can be one of several schemas (used with oneOf, anyOf, allOf).
Allowed in โ
Parameters โ
- propertyName :
string|nullThe name of the property in the payload that distinguishes types - mapping :
array<string,string>|nullMaps payload values to schema names or references
Reference โ
Encoding โ
Describes the encoding for a single property in a media type.
Allowed in โ
MediaType, MediaType\Json, MediaType\Xml
Parameters โ
- encoding :
string|nullThe property name this encoding applies to - contentType :
string|nullThe Content-Type for encoding a specific property - headers :
list<Header>|nullAdditional headers for multipart media types - style :
string|ParameterStyle|nullHow the property value is serialized - explode :
bool|nullWhether arrays/objects generate separate parameters - allowReserved :
bool|nullWhether reserved characters are allowed without encoding
Reference โ
- Encoding Object โ
Example โ
Describes an example value for a parameter, media type, or schema.
Allowed in โ
Components, Header, MediaType, MediaType\Json, MediaType\Xml, Parameter, Parameter\Cookie, Parameter\Header, Parameter\Path, Parameter\Query
Parameters โ
- example :
string|nullReusable example identifier (component key) - summary :
string|nullShort description of the example - description :
string|nullLong description of the example (CommonMark syntax) - value :
mixedEmbedded literal example value - externalValue :
string|nullA URI pointing to the literal example - ref :
string|nullA JSON Reference to a reusable example
Reference โ
- Example Object โ
ExternalDocumentation โ
Allows referencing an external resource for extended documentation.
Allowed in โ
Parameters โ
- url :
string|nullThe URL for the target documentation - description :
string|nullA description of the target documentation (CommonMark syntax)
Reference โ
Flow โ
Configuration details for a supported OAuth2 flow.
Typed subtypes pre-fill the flow type:
OA\Flow\Implicit- implicit grant (authorizationUrl required)OA\Flow\Password- resource owner password credentials (tokenUrl required)OA\Flow\ClientCredentials- client credentials grant (tokenUrl required)OA\Flow\AuthorizationCode- authorization code grant (authorizationUrl + tokenUrl required)#[OA\Security\Scheme\OAuth2(securityScheme: 'oauth2', flows: [ new OA\Flow\AuthorizationCode( authorizationUrl: 'https://example.com/oauth/authorize', tokenUrl: 'https://example.com/oauth/token', scopes: ['read:pets' => 'Read pets', 'write:pets' => 'Write pets'], ), ])]
Produces: components: securitySchemes: oauth2: type: oauth2 flows: authorizationCode: authorizationUrl: https://example.com/oauth/authorize tokenUrl: https://example.com/oauth/token scopes: read:pets: Read pets write:pets: Write pets
Allowed in โ
Security\Scheme, Security\Scheme\ApiKey, Security\Scheme\Http, Security\Scheme\MutualTls, Security\Scheme\OAuth2, Security\Scheme\OpenIdConnect
Parameters โ
- flow :
string|FlowType|nullThe OAuth2 flow type (implicit, password, clientCredentials, authorizationCode) - authorizationUrl :
string|nullThe authorization URL for this flow - tokenUrl :
string|nullThe token URL for this flow - refreshUrl :
string|nullThe URL for obtaining refresh tokens - scopes :
array<string,string>|nullThe available scopes for the OAuth2 security scheme
Reference โ
Flow\AuthorizationCode โ
Configuration for the OAuth2 Authorization Code flow.
Allowed in โ
Parameters โ
- authorizationUrl :
string|nullNo details available. - tokenUrl :
string|nullNo details available. - refreshUrl :
string|nullNo details available. - scopes :
array<string,string>|nullNo details available.
Reference โ
Flow\ClientCredentials โ
Configuration for the OAuth2 Client Credentials flow.
Allowed in โ
Parameters โ
- tokenUrl :
string|nullNo details available. - refreshUrl :
string|nullNo details available. - scopes :
array<string,string>|nullNo details available.
Reference โ
Flow\Implicit โ
Configuration for the OAuth2 Implicit flow.
Allowed in โ
Parameters โ
- authorizationUrl :
string|nullNo details available. - refreshUrl :
string|nullNo details available. - scopes :
array<string,string>|nullNo details available.
Reference โ
Flow\Password โ
Configuration for the OAuth2 Resource Owner Password flow.
Allowed in โ
Parameters โ
- tokenUrl :
string|nullNo details available. - refreshUrl :
string|nullNo details available. - scopes :
array<string,string>|nullNo details available.
Reference โ
Header โ
Describes a single HTTP header.
Allowed in โ
Nested elements โ
Parameters โ
- header :
string|nullThe header name (component key) - description :
string|nullA brief description of the header (CommonMark syntax) - required :
bool|nullWhether the header is mandatory - deprecated :
bool|nullWhether the header is deprecated - ref :
string|nullA JSON Reference to a reusable header - style :
string|ParameterStyle|nullHow the header value is serialized - explode :
bool|nullWhether arrays/objects generate separate parameters - schema :
Schema|nullThe schema defining the type for the header - example :
mixedExample of the header's value - examples :
list<Example>|nullExamples of the header's value - content :
MediaType|list<MediaType>|nullContent-type based header serialization
Reference โ
- Header Object โ
Info โ
Metadata about the API.
Nested elements โ
Parameters โ
- title :
string|nullThe title of the API - description :
string|nullA description of the API (CommonMark syntax) - termsOfService :
string|nullA URL to the Terms of Service for the API - version :
string|nullThe version of the API document - contact :
Contact|nullContact information for the API - license :
License|nullLicense information for the API - summary :
string|nullA short summary of the API
Reference โ
- Info Object โ
License โ
License information for the exposed API.
Allowed in โ
Parameters โ
- name :
string|nullThe license name used for the API - identifier :
string|nullAn SPDX license expression for the API - url :
string|nullA URL to the license used for the API
Reference โ
- License Object โ
Link โ
Describes a possible design-time link for a response.
Allowed in โ
Parameters โ
- link :
string|nullReusable link identifier (component key) - operationRef :
string|nullA relative or absolute URI reference to a linked operation - operationId :
string|nullThe name of an existing operation (mutually exclusive with operationRef) - parameters :
array<string,mixed>|nullValues to pass to the linked operation's parameters - requestBody :
mixedA value to use as the request body for the linked operation - description :
string|nullA description of the link (CommonMark syntax) - ref :
string|nullA JSON Reference to a reusable link - server :
Server|nullA server object to be used by the target operation
Reference โ
- Link Object โ
MediaType โ
Describes the content payload for a specific media type.
Allowed in โ
Header, Parameter, Parameter\Cookie, Parameter\Header, Parameter\Path, Parameter\Query, RequestBody, Response
Nested elements โ
Parameters โ
- mediaType :
string|nullThe media type identifier (e.g. 'application/json') - schema :
Schema|nullThe schema defining the content - example :
mixedExample of the media type content - examples :
list<Example>|nullExamples of the media type content - encoding :
list<Encoding>|array<string,Encoding>|nullEncoding information for specific properties
Reference โ
MediaType\Json โ
Describes the content payload for application/json.
A shortcut version of OA\MediaType with some of the more common OA\Schema properties added.
mediaTypeis set toapplication/jsonby default.ref,type,items,propertiesandrequiredmay be used and will be expanded into a nestedOA\Schemaautomatically.- If
schemais explicitly set, the customOA\Schemaproperties will be ignored.
Allows to shorten this:
#[OA\Response(response: 200, content: [ new OA\MediaType(mediaType: 'application/json', schema: new OA\Schema(type: 'array', items: new OA\Schema(ref: Pet::class))), ])]
to this:
#[OA\Response(response: 200, content: [new OA\MediaType\Json(type: 'array', items: new OA\Schema(ref: Pet::class))])]
The Shortcuts augmenter expands the schema properties into a nested OA\Schema automatically.
Allowed in โ
Response, RequestBody, Parameter
Nested elements โ
Parameters โ
- ref :
string|nullA JSON Reference to a reusable schema - type :
string|list<string>|nullThe value type(s) (string, number, integer, boolean, array, object, null) - items :
Schema|string|nullSchema for array items - properties :
list<Property|Schema>|nullObject property definitions - required :
list<string>|nullList of required property names - schema :
Schema|nullThe schema defining the content - example :
mixedExample of the media type content - examples :
list<OA\Example>|nullExamples of the media type content - encoding :
list<OA\Encoding>|array<string,OA\Encoding>|nullEncoding information for specific properties
Reference โ
MediaType\Xml โ
Describes the content payload for application/xml.
A shortcut version of OA\MediaType with some of the more common OA\Schema properties added.
mediaTypeis set toapplication/xmlby default.ref,type,items,propertiesandrequiredmay be used and will be expanded into a nestedOA\Schemaautomatically.- If
schemais explicitly set, the customOA\Schemaproperties will be ignored.
Allows to shorten this:
#[OA\Response(response: 200, content: [ new OA\MediaType(mediaType: 'application/xml', schema: new OA\Schema(type: 'array', items: new OA\Schema(ref: Pet::class))), ])]
to this:
#[OA\Response(response: 200, content: [new OA\MediaType\Xml(type: 'array', items: new OA\Schema(ref: Pet::class))])]
The Shortcuts augmenter expands the schema properties into a nested OA\Schema automatically.
Allowed in โ
Response, RequestBody, Parameter
Nested elements โ
Parameters โ
- ref :
string|nullA JSON Reference to a reusable schema - type :
string|list<string>|nullThe value type(s) (string, number, integer, boolean, array, object, null) - items :
Schema|string|nullSchema for array items - properties :
list<Property|Schema>|nullObject property definitions - required :
list<string>|nullList of required property names - schema :
Schema|nullThe schema defining the content - example :
mixedExample of the media type content - examples :
list<OA\Example>|nullExamples of the media type content - encoding :
list<OA\Encoding>|array<string,OA\Encoding>|nullEncoding information for specific properties
Reference โ
OpenApi โ
The root element of an OpenAPI definition.
Nested elements โ
Parameters โ
- version :
string|nullThe OpenAPI specification version (e.g. '3.1.0') - security :
list<Security\Requirement>|nullDefault security requirements for the API
Reference โ
- OpenAPI Object โ
Operation โ
Describes a single API operation on a path.
Typed subclasses pre-fill the HTTP method โ use them instead of specifying method manually:
#[OA\Operation\Get(path: '/pets/{id}', responses: [ new OA\Response(response: 200, description: 'A pet', content: [ new OA\MediaType(schema: new OA\Schema(ref: Pet::class)), ]), ])] public function show(int $id) {}
Produces: paths: /pets/{id}: get: operationId: show responses: '200': description: A pet content: application/json: schema: $ref: '#/components/schemas/Pet'
For webhooks, use webhook instead of path:
#[OA\Operation\Post(webhook: 'petAdopted', responses: [...])]
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullThe URL path for the operation - webhook :
string|nullThe webhook name (mutually exclusive with path) - method :
string|HttpMethod|nullThe HTTP method (get, post, put, delete, etc.) - operationId :
string|nullUnique identifier for the operation - summary :
string|nullA short summary of what the operation does - description :
string|nullA verbose explanation of the operation (CommonMark syntax) - tags :
list<string>|nullTags for API documentation grouping - parameters :
list<Parameter>|nullParameters applicable to this operation - requestBody :
RequestBody|nullThe request body applicable to this operation - responses :
list<Response>|nullThe list of possible responses - callbacks :
array<string,mixed>|nullPossible out-of-band callbacks related to the operation - deprecated :
bool|nullWhether the operation is deprecated - security :
list<Security\Requirement>|nullSecurity mechanisms that can be used for this operation - servers :
list<Server>|nullAlternative servers for this operation - externalDocs :
ExternalDocumentation|nullAdditional external documentation
Reference โ
- Operation Object โ
- Webhooks โ
Operation\Delete โ
Shorthand for an HTTP DELETE operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Get โ
Shorthand for an HTTP GET operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Head โ
Shorthand for an HTTP HEAD operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Options โ
Shorthand for an HTTP OPTIONS operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Patch โ
Shorthand for an HTTP PATCH operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Post โ
Shorthand for an HTTP POST operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Put โ
Shorthand for an HTTP PUT operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Operation\Trace โ
Shorthand for an HTTP TRACE operation.
Nested elements โ
Parameter, Response, RequestBody, Server, Security\Requirement
Parameters โ
- path :
string|nullNo details available. - webhook :
string|nullNo details available. - operationId :
string|nullNo details available. - summary :
string|nullNo details available. - description :
string|nullNo details available. - tags :
list<string>|nullNo details available. - parameters :
list<OA\Parameter>|nullNo details available. - requestBody :
OpenApi\Spec\RequestBody|nullNo details available. - responses :
list<OA\Response>|nullNo details available. - callbacks :
array<string,mixed>|nullNo details available. - deprecated :
bool|nullNo details available. - security :
list<OA\Security\Requirement>|nullNo details available. - servers :
list<OA\Server>|nullNo details available. - externalDocs :
OpenApi\Spec\ExternalDocumentation|nullNo details available.
Reference โ
- Operation Object โ
Parameter โ
Describes a single operation parameter.
Typed subtypes pre-fill in (and required for path):
OA\Parameter\Path- path parameters (in: path, required: true)OA\Parameter\Query- query string parameters (in: query)OA\Parameter\Header- header parameters (in: header)OA\Parameter\Cookie- cookie parameters (in: cookie)
Inline on an operation:
#[OA\Operation\Get(path: '/pets', parameters: [ new OA\Parameter\Query(name: 'status', schema: new OA\Schema(type: 'string', enum: ['active', 'sold'])), ])]
Or as a reusable component (set parameter for the component key):
#[OA\Parameter\Path(parameter: 'petId', name: 'id', schema: new OA\Schema(type: 'integer'))]
Produces: components: parameters: petId: name: id in: path required: true schema: type: integer
Allowed in โ
Components, Operation, Operation\Delete, Operation\Get, Operation\Head, Operation\Options, Operation\Patch, Operation\Post, Operation\Put, Operation\Trace, PathItem
Nested elements โ
Parameters โ
- parameter :
string|nullReusable parameter identifier (component key) - name :
string|nullThe name of the parameter - in :
string|ParameterIn|nullThe location of the parameter (query, header, path, cookie) - description :
string|nullA brief description of the parameter (CommonMark syntax) - required :
bool|nullWhether the parameter is mandatory - deprecated :
bool|nullWhether the parameter is deprecated - allowEmptyValue :
bool|nullWhether empty-valued parameters are allowed - ref :
string|nullA JSON Reference to a reusable parameter - style :
string|ParameterStyle|nullHow the parameter value is serialized - explode :
bool|nullWhether arrays/objects generate separate parameters - allowReserved :
bool|nullWhether reserved characters are allowed without encoding - schema :
Schema|nullThe schema defining the type for the parameter - example :
mixedExample of the parameter's value - examples :
list<Example>|nullExamples of the parameter's value - content :
MediaType|list<MediaType>|nullContent-type based parameter serialization
Reference โ
- Parameter Object โ
Parameter\Cookie โ
A parameter passed via an HTTP cookie.
Allowed in โ
Nested elements โ
Parameters โ
- parameter :
string|nullNo details available. - name :
string|nullNo details available. - description :
string|nullNo details available. - required :
bool|nullNo details available. - deprecated :
bool|nullNo details available. - ref :
string|nullNo details available. - explode :
bool|nullNo details available. - schema :
OpenApi\Spec\Schema|nullNo details available. - example :
mixed|nullNo details available. - examples :
list<OA\Example>|nullNo details available. - content :
OA\MediaType|list<OA\MediaType>|nullNo details available.
Reference โ
- Parameter Object โ
Parameter\Header โ
A parameter passed via an HTTP header.
Allowed in โ
Nested elements โ
Parameters โ
- parameter :
string|nullNo details available. - name :
string|nullNo details available. - description :
string|nullNo details available. - required :
bool|nullNo details available. - deprecated :
bool|nullNo details available. - ref :
string|nullNo details available. - explode :
bool|nullNo details available. - schema :
OpenApi\Spec\Schema|nullNo details available. - example :
mixed|nullNo details available. - examples :
list<OA\Example>|nullNo details available. - content :
OA\MediaType|list<OA\MediaType>|nullNo details available.
Reference โ
- Parameter Object โ
Parameter\Path โ
A parameter passed via the URL path (always required).
Allowed in โ
Nested elements โ
Parameters โ
- parameter :
string|nullNo details available. - name :
string|nullNo details available. - description :
string|nullNo details available. - deprecated :
bool|nullNo details available. - ref :
string|nullNo details available. - style :
OpenApi\Spec\ParameterStyle|string|nullNo details available. - explode :
bool|nullNo details available. - schema :
OpenApi\Spec\Schema|nullNo details available. - example :
mixed|nullNo details available. - examples :
list<OA\Example>|nullNo details available. - content :
OA\MediaType|list<OA\MediaType>|nullNo details available.
Reference โ
- Parameter Object โ
Parameter\Query โ
A parameter passed via the URL query string.
Allowed in โ
Nested elements โ
Parameters โ
- parameter :
string|nullNo details available. - name :
string|nullNo details available. - description :
string|nullNo details available. - required :
bool|nullNo details available. - deprecated :
bool|nullNo details available. - allowEmptyValue :
bool|nullNo details available. - ref :
string|nullNo details available. - style :
OpenApi\Spec\ParameterStyle|string|nullNo details available. - explode :
bool|nullNo details available. - allowReserved :
bool|nullNo details available. - schema :
OpenApi\Spec\Schema|nullNo details available. - example :
mixed|nullNo details available. - examples :
list<OA\Example>|nullNo details available. - content :
OA\MediaType|list<OA\MediaType>|nullNo details available.
Reference โ
- Parameter Object โ
PathItem โ
Describes shared metadata for all operations under a path.
Place on a controller class โ the path is inferred from its operations. Parameters, summary, description and servers are emitted at path level in the OpenAPI output. Prefix, tags, security and responses are controller-level features that compose via class hierarchy and apply to all contained operations.
Shared path-level properties (parameters, summary, description, servers per OpenAPI spec):
#[PathItem(parameters: [new Parameter\Path(name: 'id', schema: new Schema(type: 'integer'))])] class ProductController { #[Operation\Get(path: '/products/{id}')] public function get() {} }
The path in the output is inferred from the operations โ no need to declare it on PathItem, avoiding duplication.
Prefix composition with inherited metadata:
#[PathItem(prefix: '/api/v1')] class BaseController {}
#[PathItem(prefix: '/users', tags: ['Users'], security: [new Security\Requirement(scheme: 'bearerAuth')])] #[Response(response: 401, description: 'Unauthorized')] #[Response(response: 500, description: 'Server error')] class UserController extends BaseController { #[Operation\Get(path: '/list')] // resolved: /api/v1/users/list, tags: ['Users'] public function list() {}
#[Operation\Get(path: '/{id}')] // resolved: /api/v1/users/{id}, tags: ['Users']
public function get() {}
}
Prefixes compose by walking the class hierarchy โ each ancestor PathItem contributes its prefix segment. All collection properties merge additively: tags, security, responses, and parameters accumulate from the full ancestor chain. Deduplication is by value (tags), by scheme (security), by status code (responses), and by name+in (parameters).
Allowed in โ
Nested elements โ
Parameter, Server, Response, Security\Requirement
Parameters โ
- ref :
string|nullA JSON Reference to a reusable path item - prefix :
string|nullPath prefix โ composable via class hierarchy - summary :
string|nullAn optional summary, intended to apply to all operations in this path - description :
string|nullAn optional description, intended to apply to all operations in this path - parameters :
list<Parameter>|nullParameters applicable to all operations under this path - servers :
list<Server>|nullAlternative servers for all operations under this path - tags :
list<string>|nullTags to clone to contained operations - security :
list<Security\Requirement>|nullSecurity requirements to clone to contained operations - responses :
list<Response>|nullShared responses to clone to contained operations
Reference โ
- Path Item Object โ
Property โ
Defines a single property within a Schema object.
Allowed in โ
Parameters โ
- property :
string|nullThe property name - schema :
Schema|nullThe schema defining the property type and constraints
Reference โ
- Schema Object โ
RequestBody โ
Describes a single request body.
Allowed in โ
Components, Operation, Operation\Delete, Operation\Get, Operation\Head, Operation\Options, Operation\Patch, Operation\Post, Operation\Put, Operation\Trace
Nested elements โ
Parameters โ
- request :
string|nullReusable request body identifier (component key) - description :
string|nullA brief description of the request body (CommonMark syntax) - required :
bool|nullWhether the request body is required - ref :
string|nullA JSON Reference to a reusable request body - content :
MediaType|list<MediaType>|nullThe content of the request body
Reference โ
Response โ
Describes a single response from an API operation.
Allowed in โ
Components, Operation, Operation\Delete, Operation\Get, Operation\Head, Operation\Options, Operation\Patch, Operation\Post, Operation\Put, Operation\Trace, PathItem
Nested elements โ
Parameters โ
- response :
string|int|nullThe HTTP status code or 'default' - description :
string|nullA description of the response (CommonMark syntax) - ref :
string|nullA JSON Reference to a reusable response - headers :
list<Header>|nullHeaders sent with the response - content :
MediaType|list<MediaType>|nullPossible response payloads - links :
list<Link>|nullDesign-time links for the response
Reference โ
- Response Object โ
Schema โ
Defines the structure and validation rules for a data type.
On a class โ becomes a reusable component schema (name inferred from class):
#[OA\Schema] class Pet { #[OA\Property] public string $name; #[OA\Property] public ?int $age; }
Produces: components: schemas: Pet: type: object properties: name: { type: string } age:
Inline โ used within parameters, responses, or other schemas:
new OA\Schema(type: 'array', items: new OA\Schema(ref: Pet::class))
Allowed in โ
Components, Schema, Schema\Items
Nested elements โ
Parameters โ
- schema :
string|nullReusable schema identifier (component key) - title :
string|nullA title for the schema - description :
string|nullA description of the schema (CommonMark syntax) - ref :
string|nullA JSON Reference to a reusable schema - type :
string|list<string>|nullThe value type(s) (string, number, integer, boolean, array, object, null) - format :
string|nullFurther refines the type (e.g. int32, int64, float, double, date-time, email) - nullable :
bool|nullWhether the value can be null (OAS 3.0 only; use type array in 3.1+) - minLength :
int|nullMinimum string length - maxLength :
int|nullMaximum string length - pattern :
string|nullRegular expression pattern the string must match - contentMediaType :
string|nullThe media type of string content encoding - contentEncoding :
string|nullThe encoding used for string content (e.g. base64) - minimum :
int|float|nullMinimum numeric value (inclusive) - maximum :
int|float|nullMaximum numeric value (inclusive) - exclusiveMinimum :
int|float|bool|nullExclusive minimum value - exclusiveMaximum :
int|float|bool|nullExclusive maximum value - multipleOf :
int|float|nullThe value must be a multiple of this number - items :
Schema|string|nullSchema for array items - minItems :
int|nullMinimum number of array items - maxItems :
int|nullMaximum number of array items - uniqueItems :
bool|nullWhether array items must be unique - prefixItems :
list<Schema>|nullSchemas for positional array items (tuple validation) - contains :
Schema|bool|nullSchema that at least one array item must match - minContains :
int|nullMinimum number of items matching contains - maxContains :
int|nullMaximum number of items matching contains - unevaluatedItems :
Schema|bool|nullSchema for items not covered by other keywords - properties :
list<Property|Schema>|nullObject property definitions - required :
list<string>|nullList of required property names - additionalProperties :
Schema|bool|nullSchema or boolean for additional properties - patternProperties :
array<string,Schema>|nullSchemas for properties matching regex patterns - minProperties :
int|nullMinimum number of properties - maxProperties :
int|nullMaximum number of properties - unevaluatedProperties :
Schema|bool|nullSchema for properties not covered by other keywords - propertyNames :
Schema|nullSchema that property names must validate against - dependentRequired :
array<string,list<string>>|nullProperty-level required dependencies - dependentSchemas :
array<string,Schema>|nullProperty-level schema dependencies - allOf :
list<Schema>|nullAll schemas must match (AND composition) - anyOf :
list<Schema>|nullAt least one schema must match (OR composition) - oneOf :
list<Schema>|nullExactly one schema must match (XOR composition) - not :
Schema|nullThe schema must NOT match - if :
Schema|nullConditional schema (if-then-else) - then :
Schema|nullApplied when 'if' succeeds - else :
Schema|nullApplied when 'if' fails - enum :
list<string|int|float|bool|\UnitEnum|class-string<\UnitEnum>|null>|nullAllowed values - const :
mixedA single allowed value - example :
mixedAn example value - examples :
list<mixed>|nullA list of example values - deprecated :
bool|nullWhether the schema is deprecated - readOnly :
bool|nullWhether the value is read-only - writeOnly :
bool|nullWhether the value is write-only - default :
mixedThe default value - discriminator :
Discriminator|nullDiscriminator for polymorphism - externalDocs :
ExternalDocumentation|nullAdditional external documentation - xml :
Xml|nullXML representation metadata
Reference โ
- Schema Object โ
- JSON Schema โ
Schema\Items โ
Shortcut for OA\Schema with type array and items.
Allows to shorten this:
#[OA\Schema] class Pet { #[OA\Property] #[OA\Schema(type: 'array', items: new OA\Schema(ref: MyModel::class))] public array $names; }
to this:
#[OA\Schema] class Pet { #[OA\Property] #[OA\Schema\Items(ref: MyModel::class)] public array $names; }
The Shortcuts augmenter wraps this into OA\Schema(type: 'array', items: ...) automatically.
Allowed in โ
Property, Parameter, Header, MediaType
Nested elements โ
Parameters โ
- schema :
string|nullReusable schema identifier (component key) - title :
string|nullA title for the schema - description :
string|nullA description of the schema (CommonMark syntax) - ref :
string|nullA JSON Reference to a reusable schema - type :
string|list<string>|nullThe value type(s) (string, number, integer, boolean, array, object, null) - format :
string|nullFurther refines the type (e.g. int32, int64, float, double, date-time, email) - nullable :
bool|nullWhether the value can be null (OAS 3.0 only; use type array in 3.1+) - minLength :
int|nullMinimum string length - maxLength :
int|nullMaximum string length - pattern :
string|nullRegular expression pattern the string must match - contentMediaType :
string|nullThe media type of string content encoding - contentEncoding :
string|nullThe encoding used for string content (e.g. base64) - minimum :
int|float|nullMinimum numeric value (inclusive) - maximum :
int|float|nullMaximum numeric value (inclusive) - exclusiveMinimum :
int|float|bool|nullExclusive minimum value - exclusiveMaximum :
int|float|bool|nullExclusive maximum value - multipleOf :
int|float|nullThe value must be a multiple of this number - items :
Schema|string|nullSchema for array items - minItems :
int|nullMinimum number of array items - maxItems :
int|nullMaximum number of array items - uniqueItems :
bool|nullWhether array items must be unique - prefixItems :
list<Schema>|nullSchemas for positional array items (tuple validation) - contains :
Schema|bool|nullSchema that at least one array item must match - minContains :
int|nullMinimum number of items matching contains - maxContains :
int|nullMaximum number of items matching contains - unevaluatedItems :
Schema|bool|nullSchema for items not covered by other keywords - properties :
list<Property|Schema>|nullObject property definitions - required :
list<string>|nullList of required property names - additionalProperties :
Schema|bool|nullSchema or boolean for additional properties - patternProperties :
array<string,Schema>|nullSchemas for properties matching regex patterns - minProperties :
int|nullMinimum number of properties - maxProperties :
int|nullMaximum number of properties - unevaluatedProperties :
Schema|bool|nullSchema for properties not covered by other keywords - propertyNames :
Schema|nullSchema that property names must validate against - dependentRequired :
array<string,list<string>>|nullProperty-level required dependencies - dependentSchemas :
array<string,Schema>|nullProperty-level schema dependencies - allOf :
list<Schema>|nullAll schemas must match (AND composition) - anyOf :
list<Schema>|nullAt least one schema must match (OR composition) - oneOf :
list<Schema>|nullExactly one schema must match (XOR composition) - not :
Schema|nullThe schema must NOT match - if :
Schema|nullConditional schema (if-then-else) - then :
Schema|nullApplied when 'if' succeeds - else :
Schema|nullApplied when 'if' fails - enum :
list<string|int|float|bool|\UnitEnum|class-string<\UnitEnum>|null>|nullAllowed values - const :
mixedA single allowed value - example :
mixedAn example value - examples :
list<mixed>|nullA list of example values - deprecated :
bool|nullWhether the schema is deprecated - readOnly :
bool|nullWhether the value is read-only - writeOnly :
bool|nullWhether the value is write-only - default :
mixedThe default value - discriminator :
Discriminator|nullDiscriminator for polymorphism - externalDocs :
ExternalDocumentation|nullAdditional external documentation - xml :
Xml|nullXML representation metadata
Reference โ
- Schema Object โ
Security\Requirement โ
A security requirement declaring which security schemes apply.
Each requirement instance represents one entry in the security array (OR logic). Multiple schemes within a single requirement represent AND logic.
Allowed in โ
OpenApi, Operation, Operation\Delete, Operation\Get, Operation\Head, Operation\Options, Operation\Patch, Operation\Post, Operation\Put, Operation\Trace, PathItem
Parameters โ
- scheme :
string|nullSingle scheme name (shorthand for simple requirements) - scopes :
list<string>|nullScopes for the single scheme (OAuth2/OpenIdConnect) - schemes :
array<string,list<string>>|nullMap of scheme names to scopes (for AND logic with multiple schemes)
Reference โ
Security\Scheme โ
Defines a security scheme that can be used by the operations.
Typed subtypes are available for each security scheme type:
OA\Security\Scheme\Http- HTTP authentication (Basic, Bearer, etc.)OA\Security\Scheme\ApiKey- API key in header, query, or cookieOA\Security\Scheme\OAuth2- OAuth2 with one or more flowsOA\Security\Scheme\OpenIdConnect- OpenID Connect discoveryOA\Security\Scheme\MutualTls- Mutual TLS authentication
Allowed in โ
Nested elements โ
Parameters โ
- securityScheme :
string|nullReusable security scheme identifier (component key) - type :
string|OA\SchemeType|nullThe type of the security scheme (apiKey, http, mutualTLS, oauth2, openIdConnect) - description :
string|nullA description of the security scheme (CommonMark syntax) - name :
string|nullThe name of the header, query, or cookie parameter (apiKey) - in :
string|OA\SchemeIn|nullThe location of the API key (query, header, cookie) - scheme :
string|nullThe HTTP authorization scheme (http) - bearerFormat :
string|nullA hint about the format of the bearer token (http/bearer) - openIdConnectUrl :
string|nullThe OpenID Connect URL to discover configuration (openIdConnect) - flows :
list<OA\Flow>|nullThe available OAuth2 flows (oauth2) - ref :
string|nullA JSON Reference to a reusable security scheme
Reference โ
Security\Scheme\ApiKey โ
An API key security scheme (header, query, or cookie).
Nested elements โ
Parameters โ
- securityScheme :
string|nullNo details available. - description :
string|nullNo details available. - name :
string|nullNo details available. - in :
OpenApi\Spec\SchemeIn|string|nullNo details available.
Reference โ
Security\Scheme\Http โ
An HTTP authentication security scheme (Basic, Bearer, etc.).
Nested elements โ
Parameters โ
- securityScheme :
string|nullNo details available. - description :
string|nullNo details available. - scheme :
string|nullNo details available. - bearerFormat :
string|nullNo details available.
Reference โ
Security\Scheme\MutualTls โ
A Mutual TLS security scheme.
Nested elements โ
Parameters โ
- securityScheme :
string|nullNo details available. - description :
string|nullNo details available.
Reference โ
Security\Scheme\OAuth2 โ
An OAuth2 security scheme with one or more flows.
Nested elements โ
Parameters โ
- securityScheme :
string|nullNo details available. - description :
string|nullNo details available. - flows :
list<OA\Flow>|nullNo details available.
Reference โ
Security\Scheme\OpenIdConnect โ
An OpenID Connect Discovery security scheme.
Nested elements โ
Parameters โ
- securityScheme :
string|nullNo details available. - description :
string|nullNo details available. - openIdConnectUrl :
string|nullNo details available.
Reference โ
Server โ
Represents a Server.
Allowed in โ
Operation, Operation\Delete, Operation\Get, Operation\Head, Operation\Options, Operation\Patch, Operation\Post, Operation\Put, Operation\Trace, PathItem
Nested elements โ
Parameters โ
- url :
string|nullA URL to the target host - description :
string|nullA description of the host (CommonMark syntax) - variables :
list<ServerVariable>|nullVariables for server URL template substitution
Reference โ
- Server Object โ
ServerVariable โ
Represents a Server Variable for server URL template substitution.
Allowed in โ
Parameters โ
- serverVariable :
string|nullThe variable name - default :
string|nullThe default value to use for substitution - description :
string|nullA description of the server variable (CommonMark syntax) - enum :
list<string>|nullEnumeration of allowed string values for substitution
Reference โ
Tag โ
Adds metadata to a single tag used by the Operation Object.
Nested elements โ
Parameters โ
- name :
string|nullThe name of the tag - description :
string|nullA description of the tag (CommonMark syntax) - externalDocs :
ExternalDocumentation|nullAdditional external documentation for this tag
Reference โ
- Tag Object โ
Xml โ
Metadata for XML representation of a schema property.
Allowed in โ
Parameters โ
- name :
string|nullReplaces the name of the element/attribute - namespace :
string|nullThe URI of the XML namespace - prefix :
string|nullThe namespace prefix to use - attribute :
bool|nullWhether the property translates to an XML attribute - wrapped :
bool|nullWhether array items are wrapped in an additional element
Reference โ
- XML Object โ