Skip to content

Commit c4e28d6

Browse files
authored
Merge pull request #660 from dpfaffenbauer/patch-3
add XML example for swagger context
2 parents 5a99307 + b586657 commit c4e28d6

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

core/swagger.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ class User
234234

235235
You also have full control over both built-in and custom operations documentation:
236236

237+
In Yaml:
238+
237239
```yaml
238240
resources:
239241
App\Entity\Rabbit:
@@ -262,6 +264,54 @@ resources:
262264
description: Pink rabbit
263265
```
264266
267+
or with XML:
268+
269+
```xml
270+
<?xml version="1.0" encoding="UTF-8" ?>
271+
<resources xmlns="https://api-platform.com/schema/metadata"
272+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
273+
xsi:schemaLocation="https://api-platform.com/schema/metadata
274+
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
275+
<resource class="App\Entity\Rabbit">
276+
<collectionOperations>
277+
<collectionOperation name="create_user">
278+
<attribute name="method">get</attribute>
279+
<attribute name="path">/rabbit/rand</attribute>
280+
<attribute name="controller">App\Controller\RandomRabbit</attribute>
281+
<attribute name="swagger_context">
282+
<attribute name="summary">Random rabbit picture</attribute>
283+
<attribute name="description">
284+
# Pop a great rabbit picture by color!
285+
286+
![A great rabbit](https://rabbit.org/graphics/fun/netbunnies/jellybean1-brennan1.jpg)
287+
</attribute>
288+
<attribute name="parameters">
289+
<attribute>
290+
<attribute name="in">body</attribute>
291+
<attribute name="schema">
292+
<attribute name="type">object</attribute>
293+
<attribute name="properties">
294+
<attribute name="name">
295+
<attribute name="type">string</attribute>
296+
</attribute>
297+
<attribute name="description">
298+
<attribute name="type">string</attribute>
299+
</attribute>
300+
</attribute>
301+
</attribute>
302+
<attribute name="example">
303+
<attribute name="name">Rabbit</attribute>
304+
<attribute name="description">Pink rabbit</attribute>
305+
</attribute>
306+
</attribute>
307+
</attribute>
308+
</attribute>
309+
</collectionOperation>
310+
</collectionOperations>
311+
</resource>
312+
</resources>
313+
```
314+
265315
![Impact on swagger ui](../distribution/images/swagger-ui-2.png)
266316

267317
## Changing the Swagger UI Location

0 commit comments

Comments
 (0)