Skip to content
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

Allow to set openapi_context on subresourceOperations #4004

Merged
merged 2 commits into from Feb 2, 2021
Merged

Allow to set openapi_context on subresourceOperations #4004

merged 2 commits into from Feb 2, 2021

Conversation

yoshz
Copy link
Contributor

@yoshz yoshz commented Feb 1, 2021

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tickets fixes #3573
License MIT
Doc PR api-platform/docs#...

It is not possible to set openapi_context on subresource operations right now.
With this PR the openapi_context property on the subresource operation with be copied within SubresourceOperationFactory and afterwards used in OpenApiFactory.
This allows to override tags, summary and more as described here.

Example use case:

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;

/**
 * @ApiResource(
 *   subresourceOperations={
 *     "answer_get_subresource"={
 *       "openapi_context"={
 *         "summary"="My custom answer summary",
 *         "tags"={"My Answer"},
 *       }
 *     }
 *   }
 * )
 */
class Question {
    /**
     * @ApiSubresource
     */
    public Answer $answer;
}

/**
 * @ApiResource()
 */
class Answer {}

Note that the operation id is without the resource prefix, which will hopefully be fixed in #3458.

@soyuka soyuka added this to the 2.6.2 milestone Feb 1, 2021
@soyuka
Copy link
Member

soyuka commented Feb 1, 2021

May you run php-cs-fixer?

@yoshz yoshz changed the base branch from main to 2.6 February 1, 2021 18:14
@yoshz
Copy link
Contributor Author

yoshz commented Feb 1, 2021

I have rebased the MR to the 2.6 branch as the CI fails on unrelated things that are broken in main.

@soyuka soyuka merged commit abd1905 into api-platform:2.6 Feb 2, 2021
@soyuka
Copy link
Member

soyuka commented Feb 2, 2021

Thanks @yoshz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not override openapi_context tags in subresource operation
2 participants