You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The specification of the API is available at the `/docs.json` path.
8
+
By default, OpenAPI v2 is used.
9
+
You can also get an OpenAPI v3 compliant version thanks to the `spec_version` query parameter: `/docs.json?spec_version=3`
2
10
3
-
API Platform natively support the [Open API](https://www.openapis.org/) (formerly Swagger) API specification format.
4
11
It also integrates a customized version of [Swagger UI](https://swagger.io/swagger-ui/) and [ReDoc](https://rebilly.github.io/ReDoc/), some nice tools to display the
Symfony allows to [decorate services](https://symfony.com/doc/current/service_container/service_decoration.html), here we
12
38
need to decorate `api_platform.swagger.normalizer.documentation`.
@@ -73,10 +99,10 @@ final class SwaggerDecorator implements NormalizerInterface
73
99
}
74
100
```
75
101
76
-
## Using the Swagger Context
102
+
## Using the OpenAPI and Swagger Contexts
77
103
78
-
Sometimes you may want to change the information included in your Swagger documentation.
79
-
The following configuration will give you total control over your Swagger definitions:
104
+
Sometimes you may want to change the information included in your OpenAPI documentation.
105
+
The following configuration will give you total control over your OpenAPI definitions:
80
106
81
107
```php
82
108
<?php
@@ -110,7 +136,7 @@ class Product // The class name will be used to name exposed resources
110
136
*
111
137
* @ApiProperty(
112
138
* attributes={
113
-
* "swagger_context"={
139
+
* "openapi_context"={
114
140
* "type"="string",
115
141
* "enum"={"one", "two"},
116
142
* "example"="one"
@@ -185,6 +211,8 @@ Will produce the following Swagger documentation:
185
211
}
186
212
```
187
213
214
+
To pass a context to the OpenAPI **v3** generator, use the `openapi_context` attribute (notice the prefix: `openapi_` instead of `swagger_`).
215
+
188
216
## Changing the Name of a Definition
189
217
190
218
API Platform generates a definition name based on the serializer `groups` defined
@@ -230,7 +258,7 @@ class User
230
258
}
231
259
```
232
260
233
-
## Changing Operations in the Swagger Documentation
261
+
## Changing Operations in the OpenAPI Documentation
234
262
235
263
You also have full control over both built-in and custom operations documentation:
236
264
@@ -314,17 +342,20 @@ or with XML:
314
342
315
343

316
344
317
-
## Changing the Swagger UI Location
345
+
Again, you can use the `openapi_context` key instead of the `swagger_context` one to tweak the OpenAPI **v3** specification.
346
+
347
+
## Changing the Location of Swagger UI
318
348
319
349
Sometimes you may want to have the API at one location, and the Swagger UI at a different location. This can be done by disabling the Swagger UI from the API Platform configuration file and manually adding the Swagger UI controller.
320
350
321
-
### Disabling Swagger UI
351
+
### Disabling Swagger UI or of ReDoc
322
352
323
353
```yaml
324
354
# api/config/packages/api_platform.yaml
325
355
api_platform:
326
356
# ...
327
357
enable_swagger_ui: false
358
+
enable_re_doc: false
328
359
```
329
360
330
361
### Manually Registering the Swagger UI Controller
@@ -338,21 +369,6 @@ swagger_ui:
338
369
339
370
Change `/docs` to your desired URI you wish Swagger to be accessible on.
340
371
341
-
## Using the Swagger Command
342
-
343
-
You can also dump your current Swagger documentation using the provided command:
# Swagger documentation dumped directly into JSON file (add --yaml to change format)
354
-
```
355
-
356
372
## Overriding the UI Template
357
373
358
374
As described [in the Symfony documentation](https://symfony.com/doc/current/templating/overriding.html), it's possible to override the Twig template that loads Swagger UI and renders the documentation:
0 commit comments