OpenAPITools / OpenAPITools/openapi-generator
[REQ] (Server side) Java Class per endpoint
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
The way the API interfaces are generated created Low cohesion with Clean Architecture business logic approaches.
I'm always frustrated when trying to implement the interface generated by the openapi-generator when my business logic is following clean architecture principles where each User Case is done in an independent class. As the generated API contains many methods, my controller implementation will depend on many classes what makes it have low cohesion and coupling with different use case classes (also mappers, DTO, etc).
Describe the solution you'd like
I would like a similar behavior to the one we have with the useTags option.
It could be a property called interfacePerEndpoint that generates a class/interface per each endpoint named with the OperationId or a "generic name" with a method called execute or run or do etc, that contains the related annotations and receive the information.
Describe alternatives you've considered
The usage of useTags and creating a tag per endpoint looks to give the result I expect in the generated code, but the problem with this approach is the Swagger-UI that is generated, the visual that comes from a spec with this approach has a lot of nonmeaningful groups (One per tag) with only one endpoint.
The other approach that we are thinking of is to create the implementation without extending from the generated Api interface and using the generated Models, but with this approach could miss updates on the specification and we will be misusing what openapi-generator provides us.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Java server generation path for the existing useTags option; the issue names no file or test. Compare the requested interfacePerEndpoint behavior with the generated API structure and Swagger UI grouping, then define endpoint naming, execution-method, annotation, and acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100