zircote/swagger-php
swagger-php generates OpenAPI 3.0/3.1/3.2 documentation from your PHP 8.2+ code using attributes (preferred) or optional Doctrine annotations. Use it via CLI or programmatically, with helpful error reporting and a full documentation site.
One benefit of using swagger-php is that the library will use a number of strategies to augment your
annotations.
This includes things like:
Based on the context of the annotation swagger-php will look at (in order of priority):
Example
<<< @/snippets/guide/augmentation/context_awareness_at.php
<<< @/snippets/guide/augmentation/context_awareness_an.php
Results in
openapi: 3.0.0
components:
schemas:
Product:
properties:
name:
description: "The product name"
type: string
type: object
As if you'd written
<<< @/snippets/guide/augmentation/explicit_context_at.php
<<< @/snippets/guide/augmentation/explicit_context_an.php
In particular, the following schema elements may be augmented:
nullableitemsreftypeformatminimum / maximumconstenumData types that are not recognized and cannot be resolved to a class-like name (class, interface, enum, etc.) will be ignored.
Mots of these schema elements will be resolved in isolation. For example, nullable may be enforced by the OpenApi annotation
while the actual data type may be resolved from the docblock (or type-hint).
summary and description of certain annotation types (OA\Operation, OA\Property, OA\Parameter and OA\Schema) may be augmented
by extracting the summary and description of the docblock (if any).
OpenApi specs support references to allow reuse of elements and reduce duplication. One of the most common use cases is
to set the type or ref property of a schema to a class name. The only requirement is that the class name must be
annotated as a OA\Schema itself.
Tags are an OpenApi concept and may be added to your spec via th Tag annotation. For convenience, however, it is also
possible to create tags by just adding them to your HTTP operations (Get, Post, etc.).
All tags used that are not explicitly defined with a Tag annotation will be added to the spec.
How can I help you explore Laravel packages today?