quarkiverse / quarkus-openapi-generator

OpenAPI Generator - REST Client Generator
Apache License 2.0
112 stars 77 forks source link

Support for Mutiny Return Type on Specific Endpoints #782

Closed oben01 closed 1 day ago

oben01 commented 2 weeks ago

Description:

I would like to suggest a feature enhancement for the OpenAPI Generator in Quarkus, specifically regarding the generation of Mutiny-based return types for specific API operations. Currently, it seems that Mutiny support is either globally applied. However, there are use cases where only certain endpoints need to leverage Mutiny’s reactive capabilities.

Proposed Solution:

Introduce the ability to apply Mutiny return types selectively to specific operations within an OpenAPI specification. This can be achieved by adding configuration options that allow developers to specify which endpoints should have Mutiny return types.

Example Configuration:

quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny=true
quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny.operation-ids=addPet
# For multiple operation IDs:
quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny.operation-ids=addPet,updatePet

*if only mutiny=true we continue to apply to all endpoints

Use Case:

Consider an OpenAPI specification, such as the one used in the Swagger Petstore example. If a developer only wants to apply Mutiny return types to the POST /pet endpoint, they could use the configuration above. This allows for granular control, enabling developers to optimize specific parts of their API for reactive processing without globally applying it to all operations.

Expected Outcome:

Feedback Request:

I would appreciate your thoughts on the feasibility of this feature. Are there any potential challenges or considerations that I might have overlooked?

Thank you for considering this enhancement!

ricardozanini commented 1 week ago

Hi @oben01! That's a great addition to the extension. If you don't mind, can you work on a PR?

Cheers!

oben01 commented 1 week ago

Hello @ricardozanini Thank you for the positive feedback! I'd be happy to give it a try and work on a PR for this feature.

Additionally, I was thinking of expanding the feature to allow developers to choose between Uni and Multi return types for each endpoint. This would provide even more flexibility depending on whether a single response or a stream of responses is expected from an endpoint.

I'll start working on this and keep you updated on my progress!

oben01 commented 1 week ago

What do u thing of something like :

quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny=true

# Configure return type for specific operation IDs
quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny.operation-ids.addPet=Uni
quarkus.openapi-generator.codegen.spec.my_openapi_yaml.mutiny.operation-ids.updatePet=Multi
ricardozanini commented 1 week ago

Great idea!

oben01 commented 1 week ago

@ricardozanini The PR is ready :)

oben01 commented 6 days ago

@ricardozanini I just forget to run mvn verify to reformat the code sorry about that. could u please run the pipeline again