Reference

Attributes

Every PHP attribute of the generator, where it goes and each of its parameters.

All attributes are in Ark4ne\OpenApi\Attributes. Those accepted on a controller apply to each of its actions; the action overrides them. The attributes of a parent class or of a parent method are merged under those of the child. Types are PHPDoc types. An attribute that cannot be built (an unknown or wrong argument) is left out with a warning.

Operation

On a controller or an action. Replaces the metadata given by the PHPDoc and the strategies; on the controller, it fills only what the action leaves empty.

summary
?string
The summary of the operation.
description
?string
The description, CommonMark.
operationId
?string
The operation id, instead of the strategy's.
tags
list<string>
The tags, replacing those of the strategy. Default []: the strategy's.
deprecated
?bool
Deprecated or not, over @deprecated and #[\Deprecated].
externalDocs
?string
The URL of the external documentation.
externalDocsDescription
?string
Its description.

Tag

Repeatable, on a controller or an action. Adds a tag to the operation, and describes it in the document.

name
string required
The name of the tag.
description
?string
Its description.
parent
?string
The parent tag: Tag.parent in 3.2, x-tagGroups before with vendor_extensions: redoc.
summary
?string
A short summary (3.2).
kind
?string
nav, badge… (3.2).
externalDocs
?string
The URL of the external documentation.
externalDocsDescription
?string
Its description.

Response

Repeatable, on a controller, an action or an exception class. Replaces the response inferred for its status; a declared success (2xx) leaves out the successes inferred for other statuses. On an exception class, it is the response of the actions that declare @throws with it. See Responses.

status
int|string
The status, or 'default'. Default 200.
description
?string
The description. Default: the HTTP phrase of the status.
resource
?class-string
A JsonResource or ResourceCollection giving the body.
type
?string
A PHPDoc type giving the body: array{id: int}, list<string>.
mediaType
?string
Default application/json. With text/event-stream, type is one event (itemSchema, 3.2).
headers
array<string, string>
Header name → PHPDoc type of its value.
paginator
?class-string
LengthAwarePaginator, Paginator or CursorPaginator: resource paginated, with links and meta.
summary
?string
A short summary (3.2).
example
mixed
An example of the body.

Without resource nor type, the response keeps the body inferred for its status.

RequestBody

On an action. Gives the body, or describes the body the rules gave. See Requests.

type
?string
A PHPDoc type giving the body.
resource
?class-string
A resource whose schema is the body ({data} for a JSON:API resource).
mediaType
?string
The media type of the body given by type or resource. Default application/json.
description
?string
The description of the body.
required
?bool
null: required when the attribute gives the body, unchanged otherwise.

Repeatable, on a controller, a request class or an action. Adds a parameter, or completes the parameter of the same name and location given by the rules. A parameter left null keeps its value. A header is matched whatever the case of its name.

name
string required
The name of the parameter.
type
?string
A PHPDoc type. null: the schema already described, else string.
description
?string
Its description.
required
?bool
null: unchanged, else not required.
deprecated
?bool
#[QueryParameter] only. null: unchanged, else not deprecated.
example
mixed
An example value.

PathParameter

Repeatable, on an action. Completes a path parameter; it is always required.

name
string required
The name of the parameter, as in the URI.
type
?string
A PHPDoc type. null: the type inferred from the route and the action.
description
?string
Its description.
example
mixed
An example value.

Security

Repeatable, on a controller or an action. Each attribute is an alternative requirement; on the action, they replace those of the class and of the middlewares.

scheme
string required
The name of a security scheme: sanctum, passport, one of security_schemes.
scopes
list<string>
Its scopes. Default [].

Exclude

On a controller, an action, a closure route, or a payload webhook class Since 1.3. Left out of every document. No parameter.

Webhook

On a JsonResource: a payload webhook Since 1.3, found under webhooks.paths or listed in webhooks.classes, without a route. On a controller or an action: a route webhook, deprecated. Both are documented under webhooks (3.1+, x-webhooks before with redoc), not under paths. See Webhooks & callbacks.

name
?string
On a payload class: the key of the webhook, required. On an action: the key of the webhook (default: the route name). On a controller: the prefix of the keys of its actions (order + paid gives order.paid).
method
?string
On a payload class: the HTTP method of the request sent. Default POST. Ignored on a route webhook.

Callback

Repeatable, on an action. A request sent back to a URL the client gave.

name
string required
The key of the callback in the operation.
url
string required
The runtime expression of the URL: {$request.body#/callback_url}.
method
string
The HTTP method. Default POST.
webhook
?string
A webhook whose request and responses the callback reuses.
resource
?class-string
A resource giving the payload.
type
?string
A PHPDoc type giving the payload.
mediaType
?string
The media type of the payload.
description
?string
The description of the request.
status
?int
The response expected from the receiver. Default 200.

ResourceFactory

On a resource whose toArray() does not receive a model. Builds the samples it receives. See Sampling.

factory
class-string required
A model factory class (its make() is called), or any class, called through method or invoked.
parameters
array
The attributes given to make(), or the arguments given by name to method / __invoke.
method
?string
The method of factory that builds the sample. Default: __invoke.

SchemaName

On a resource or a backed enum. The name of its component; default: the class name without Resource.

name
string required
The name of the component.