Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Swagger Php Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Augmentation

One benefit of using swagger-php is that the library will use a number of strategies to augment your annotations.

This includes things like:

  • the name of properties
  • the description of elements
  • the data type of properties

Based on the context of the annotation swagger-php will look at (in order of priority):

  • the OpenApi annotation itself
  • the docblock (if any)
  • PHP native type hints (if any)

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

Data types

In particular, the following schema elements may be augmented:

  • nullable
  • items
  • ref
  • type
  • format
  • minimum / maximum
  • const
  • enum

Data 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

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).

References

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

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport