Description/Summary not changeable for sub resources
API Platform version(s) affected: 2.6.8
Description
Unfortunately the summary and the description for subresources is wrong, but I'm not able to change it. I've tried the following:
'''
* @ApiProperty(
* readableLink=false,
* writableLink=false,
* description="Retrieves signals from the Device resource",
* openapiContext={
* "summary"="Retrieves signals from the Device resource",
* "description"="Retrieves signals from the Device resource"
* },
* attributes={
* "openapiContext"={
* "summary"="Retrieves signals from the Device resource",
* "description"="Retrieves signals from the Device resource"
* }
* }
* )
'''
How to reproduce
Just add the above
Possible Solution
I'm not sure if this is a bug or so by design. If it is this would be a nice feature.
Thx in advance
You need to place the openapi_context of your subresource in your parent class configuration.
For exemple, using yaml, in MyParent.yaml :
resources:
App\Entity\MyParent:
subresourceOperations:
mychild_get_subresource:
openapi_context:
summary: Hey
description: blablabla
Using attributes I think you need to put it in the ApiResource attribute of your parent class and under subresourceOperations property.
I achieved this with the following configuration:
# config/api/company.yaml
# -----
App\Entity\Company:
attributes:
order:
createdAt: DESC
normalization_context:
groups: [ 'company:read' ]
skip_null_values: false
denormalization_context:
groups: [ 'company:write' ]
id:
groups: [ 'company:read', 'company:write', 'user:read', 'user:write', 'site:read', 'documentSending:read', 'tag:read' ]
name:
groups: [ 'company:read', 'company:write', 'user:read', 'user:write', 'site:read', 'documentSending:read', 'tag:read' ]
properties:
# GET /api/companies/{id}/sites to get the list of the Sites related to a Company.
sites:
subresource:
resourceClass: 'App\Entity\Site'
collection: true
subresourceOperations:
sites_get_subresource:
method: 'GET'
openapi_context:
tags: ['Companies', 'Sites']
summary: The list of the sites of a company
description: |
Get all the sites for the specified company
parameters:
- in: path
name: id
description: 'Indicate the id of the **Company**'
required: true
deprecated: false
allowEmptyValue: false
schema:
type: string
format: uuid
default: ''
example: '_company_5'
style: form
explode: true
allowReserved: false
collectionOperations:
get:
method: 'GET'
filters: [ 'company.search_filter', 'company_custom.search_filter' ]
openapi_context:
tags: ['Companies']
summary: Retrieves all the companies
api_companies_name:
openapi_context:
tags: ['Companies']
summary: The list of the companies names
description: |
Get all the companies with only their `id` and `name`.
post:
openapi_context:
tags: ['Companies']
itemOperations:
get:
openapi_context:
tags: ['Companies']
put:
openapi_context:
tags: ['Companies']
delete:
openapi_context:
tags: ['Companies']