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

[Question]: is some solution to move all descriptive OA attributes from the route's method to another place (a separate class or method) ? #2441

Open
upsetcode opened this issue Feb 6, 2025 · 1 comment
Labels

Comments

@upsetcode
Copy link

Version

5

Question

Is it possible to specify one attribute near the route method so that it points to an object that will contain all the attributes necessary to describe the route?

Goal: not to clutter the main code with attributes, so that the route method has only 2 attributes

For example:

#[Route(path: '/example', name: 'get-example', methods: [Request::METHOD_GET])]
#[OARouteSchema(ref: new NA\Model(type: ClassContainsExampleRouteSchema::class)))]
public function example():Response{...}

the class ClassContainsExampleRouteSchema contains all needed attributes for describes route (requests, response, tags, ...) OR it can use #[OA\Get(...)].

I know that I can describe everything in one attribute #[OA\Get(...)] on route, but it will contain too much code.

Perhaps there is some other solution to move all descriptive OA attributes from the route's method to another place (a separate class or method) ?

Additional context

No response

@DjordyKoert
Copy link
Collaborator

This is not really possible at the moment.

Currently the only way to kinda do this is by updating your bundle configuration and then referencing that in your attributes

https://symfony.com/bundles/NelmioApiDocBundle/current/configuration_reference.html#documentation

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

No branches or pull requests

2 participants