OpenAPITools / OpenAPITools/openapi-generator
[REQ] Make version.info object accessible via generated classes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
We have the following situation:
We are generating java model classes from a given openApi input specification once and then distribute it as a library jar (Maven dependency) via our own internal repository for all other services which need this model. This way these services do not have to generate them on their own and we also provide some useful helper classes inside the library.
For some use cases we need the openApi specification's "info.version" object available via the generated java classes.
E.g. we want to include the info.version as the model classes get serialized in service A, sent to a central service via a generic queue and there it gets deserialized. The central service has to provide backwards compatibility as we have multiple clients A, B, C (...) using different versions of that model-library. Therefore the central service has to distinguish between different model versions to choose the correct mapper. Best way to do that would be to rely on the info.version property.
Current solution is to manually specify the version in an wrapper object which references the generated model classes and gets sent to the central service.
It would be nice if there would be a configuration option for the Maven generator plugin which will then write the info,version as a fixed value to a) the generated root object of the openApi input spec or b) even better: to some sort of generated extra object containing this metadata and which can be specified.
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 Maven generator plugin and the Java model-generation path, then inspect how the OpenAPI info.version value is represented during generation. Compare exposing it on the generated root object with generating a separate metadata object. Done means a configuration option makes info.version available as a fixed value through the generated Java classes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100