OpenAPITools / OpenAPITools/openapi-generator
Change return types for Spring openapi-generator-maven-plugin generated interfaces
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
I've managed to generate the interfaces from a .yaml open-api descriptor file, but, as in the question title, I'd love to change the response type of those interfaces from ResponseEntity to my own types. Basically instead of the interface having this signature:
ResponseEntity<Void> clearCache();
for a method that is implemented basically this way:
public void clearCache(){ //do something}
I'd want the generated interface to be as simply as
void clearCache();
Same thing for my own defined classes, instead of ResponseEntity<MyBook> getBook(String ISBN); I want it to just use MyBook as return type, so it should look something like MyBook getBook(String ISBN);
I think this could be a really useful feature for the future of this openapi-generator plugin, currently I haven't managed to get it do what I'm looking for but I think here on the community with this issue (which was suggested me to create it by @wing328 ) I'll find a solution to it!
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 with the Spring openapi-generator-maven-plugin and generate interfaces from a YAML OpenAPI descriptor. Trace how the generated signatures choose ResponseEntity for void and model responses, then compare the output with the requested void and MyBook return types. Done means the generator can produce those simpler return types without changing the OpenAPI descriptor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100