File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ class Product // The class name will be used to name exposed resources
108
108
* "swagger_context"={
109
109
* "type"="string",
110
110
* "enum"={"one", "two"},
111
- * "example"="one"
111
+ * "example"="one"
112
112
* }
113
113
* }
114
114
* )
@@ -179,3 +179,50 @@ Will produce the following Swagger documentation:
179
179
}
180
180
}
181
181
```
182
+
183
+ ### Changing the name of a definition
184
+
185
+ ApiPlatform generates a definition name based on the serializer ` groups ` defined
186
+ in the (` de ` )` denormalization_context ` . It's possible to override the name
187
+ thanks to the ` swagger_definition_name ` option:
188
+
189
+ ``` php
190
+ /**
191
+ * @ApiResource(
192
+ * collectionOperations={
193
+ * "post"={
194
+ * "method"="POST",
195
+ * "denormalization_context"={
196
+ * "groups"={"user_read"},
197
+ * "swagger_definition_name": "Read",
198
+ * },
199
+ * },
200
+ * },
201
+ * )
202
+ */
203
+ class User
204
+ {
205
+ }
206
+ ```
207
+
208
+ It's also possible to re-use the ` normalization_context ` :
209
+
210
+ ``` php
211
+ /**
212
+ * @ApiResource(
213
+ * collectionOperations={
214
+ * "post"={
215
+ * "method"="POST",
216
+ * "denormalization_context"=User::API_WRITE,
217
+ * },
218
+ * },
219
+ * )
220
+ */
221
+ class User
222
+ {
223
+ const API_WRITE = [
224
+ 'groups' => ['user_read'],
225
+ 'swagger_definition_name' => 'Read',
226
+ ];
227
+ }
228
+ ```
You can’t perform that action at this time.
0 commit comments