Let's say I create a custom action under AppBundle/Action. How can I make it show up in api docs?
This is an example I use:
# src/AppBundle/Resources/config/api_resources/resources.yml
AppBundle\Entity\Dictionary\Word:
collectionOperations:
get:
method: 'GET' # nothing more to add if we want to keep the default controller
normalization_context:
groups: ['list_words']
itemOperations:
get:
method: 'GET'
normalization_context:
groups: ['get_word']
rhymeform:
route_name: 'rhymeform'
swagger_context:
parameters:
-
name: id
in: path
required: true
type: string
responses:
200:
description: "rhymeform of the word"
schema:
type: "object"
required: ["rhymeform"]
properties:
rhymeform:
type: "string"
404:
description: "Resource not found"
summary: "Retrieve the rhymeform of a word"
consumes: ["application/json", "text/html"]
produces: ["application/json"]
syllables:
route_name: 'syllables'
swagger_context:
parameters:
-
name: id
in: path
required: true
type: string
responses:
200:
description: "syllables of the word separated by dash"
schema:
type: "object"
required: ["syllables"]
properties:
syllables:
type: "string"
404:
description: "Resource not found"
summary: "Retrieve the syllables of a word"
consumes: ["application/json", "text/html"]
produces: ["application/json"]
Same can be achieved with annotations.
More about the schema can be found in the swagger documentation.
@angelov-todor thanks
Most helpful comment
This is an example I use:
Same can be achieved with annotations.
More about the schema can be found in the swagger documentation.