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

[REQ] [Java][Spring] Generate a Controller per operation #17145

Closed
pcuriel opened this issue Nov 20, 2023 · 1 comment · Fixed by #17161
Closed

[REQ] [Java][Spring] Generate a Controller per operation #17145

pcuriel opened this issue Nov 20, 2023 · 1 comment · Fixed by #17161

Comments

@pcuriel
Copy link

pcuriel commented Nov 20, 2023

Having controllers split by tags is nice, but patterns like Vertical Slicing suggest going a step further and having one Controller per endpoint.

In a similar fashion to useTags, a useOperationIds config option could be added to use the operationId to generate the interface/controller classnames.

An alternative/complementary option could be adding a x-controller-name vendor extension applicable to Operation object.

@wing328
Copy link
Member

wing328 commented Nov 22, 2023

I've filed #17161 to meet this requirement. To give it a try, here is an example:

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g spring -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml  -o  /tmp/spring5 --openapi-normalizer SET_TAGS_TO_OPERATIONID=true --additional-properties useTags=true

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

Successfully merging a pull request may close this issue.

2 participants