Api Documentation with NelmioApiDocBundle
Auto Generated Documentation
We use theNelmioApiDocBundle to auto generate docs for us. It will parse all of our routing annotations and produce a document that lets people test drive our application.
Config
What this does is say that for the api we using Authorization header with a token prefixed with bearer for our authentication. In the top right corner you will see a place to enter that that token so you don’t have to do it on every request. It also say that by default send all the requests as json.
nelmio_api_doc:
name: 'Symfony Starter Api'
sandbox:
authentication:
name: Authorization
delivery: http
type: bearer
body_format:
formats: [json, form]
default_format: json
To document an end point you only need the ApiDoc annonation. Here is an example.
* @ApiDoc(
* resource=true,
* description="Get's a user",
* section="Users",
* authentication=true
* )
You can read more about in the helpful links section.