Skip to content

Migrating to v3 โ€‹

Swagger-PHP 3.x generates an openapi.json file that follows the OpenAPI Version 3.0.x Specification.

If you need to output the older 2.x specification, use OpenApi-php 2.x

The default output changed from JSON to YAML โ€‹

This aligns better with the direction of the swagger documentation and examples. Annotations can't be used as string anymore, you'll need to call toYaml() or toJson() if you prefer the JSON format.

Updated CLI โ€‹

  • Added colors
  • No output for successful execution (Removed summary)
  • non-zero exit when an error occurred.
  • Defaults to YAML
  • Defaults to stdout. To save to openapi.yaml use -o or >

Changed annotations โ€‹

SWG is renamed to OA โ€‹

The namespace is renamed from SWG (Swagger) to OA (OpenApi)

@SWG\Swagger() is renamed to @OA\OpenApi() โ€‹

@SWG\Path() is renamed to @OA\PathItem() โ€‹

The specification uses the term "Path Item Object", updated the annotation to reflect that.

@SWG\Definition() is removed โ€‹

Use @OA\Schema() instead of @OA\Definition() and update the references from "#/definitions/something" to "#/components/schemas/something".

@SWG\Path is removed โ€‹

Use @OA\PathItem instead of @SWG\Path and update references.

Consumes, produces field is removed from OpenAPI specification โ€‹

Use @OA\MediaType to set data format.

Rename parameter references โ€‹

Rename #/parameters/{parameter_name} to #/components/parameters/{parameter_name}

Rename response references โ€‹

Rename #/responses/{response} to #/components/responses/{response}

Renamed cli โ€‹

Renamed swagger to openapi

More details about differences: โ€‹

A Visual Guide to What's New in Swagger 3.0