Skip to content

add XML example for swagger context #660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions core/swagger.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class User

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

In Yaml:

```yaml
resources:
App\Entity\Rabbit:
Expand Down Expand Up @@ -262,6 +264,54 @@ resources:
description: Pink rabbit
```

or with XML:

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="App\Entity\Rabbit">
<collectionOperations>
<collectionOperation name="create_user">
<attribute name="method">get</attribute>
<attribute name="path">/rabbit/rand</attribute>
<attribute name="controller">App\Controller\RandomRabbit</attribute>
<attribute name="swagger_context">
<attribute name="summary">Random rabbit picture</attribute>
<attribute name="description">
# Pop a great rabbit picture by color!

![A great rabbit](https://rabbit.org/graphics/fun/netbunnies/jellybean1-brennan1.jpg)
</attribute>
<attribute name="parameters">
<attribute>
<attribute name="in">body</attribute>
<attribute name="schema">
<attribute name="type">object</attribute>
<attribute name="properties">
<attribute name="name">
<attribute name="type">string</attribute>
</attribute>
<attribute name="description">
<attribute name="type">string</attribute>
</attribute>
</attribute>
</attribute>
<attribute name="example">
<attribute name="name">Rabbit</attribute>
<attribute name="description">Pink rabbit</attribute>
</attribute>
</attribute>
</attribute>
</attribute>
</collectionOperation>
</collectionOperations>
</resource>
</resources>
```

![Impact on swagger ui](../distribution/images/swagger-ui-2.png)

## Changing the Swagger UI Location
Expand Down