Reputation: 1256
I have created a custom endpoint using API Platform. Here is the annotation I have used:
/**
* We only want the POST option for now.
*
* @ApiResource(
* itemOperations={},
* collectionOperations={"post"={
* "method"="POST",
* "controller"=PairingController::class,
* "path"="/devices/pairing",
* "defaults"={"_api_receive"=false}
* }},
* )
*
*
*/
class Pairing
{
...
The controller I am calling executes some custom logic. I am happy with how things are working so far. But the documentation generated by API Platform is now inaccurate. It says:
/devices/pairing Creates a Pairing resource.
... which is no longer true, since my controller does not generate a pairing. (It calls out to a different API instead, asking that API to do some stuff.)
So here's my question: How do I change my annotation to allow me to write a custom piece of documentation for this endpoint?
Upvotes: 3
Views: 4663
Reputation: 1668
You need to use ApiPlatform\Metadata\ApiProperty
, as shown here https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
It didn't works for me, here is how I did it with openapi_context:
"openapi_context"={
"summary"="test",
},
Upvotes: 4
Reputation: 3024
You can use the swagger_context
key to change any Swagger field, including description
(the one you are looking for): https://api-platform.com/docs/core/swagger/#changing-operations-in-the-swagger-documentation
Upvotes: 3