OpenAPITools / OpenAPITools/openapi-generator
[REQ] Turn ExampleGenerator into a interface and allow an Codegen implementation to use its own example generator
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.
Currently, an instance of ExampleGenerator is being used by the DefaultCodegen class.
Specific generators cannot change this because is fixed type in hardcoded. To change the behavior it would be necessary to override an ultra big method: fromOperation() . it is a too hard path.
Describe the solution you'd like
-
My idea is to turn the ExampleGenerator class into an Interface and then to create a DefaultExampleGenerator class implementing it.
-
DefaultCodegen has two different places whe examples a being created:
handleMethodResponse,fromOperationandtoExampleValue. I think that we could converhe those uses into the ExampleGenerator interface.
Describe alternatives you've considered
Additional context
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 reading ExampleGenerator and DefaultCodegen, focusing on handleMethodResponse, fromOperation, and toExampleValue, where the issue says examples are created. Trace how DefaultCodegen currently uses ExampleGenerator and how generator-specific implementations could supply their own behavior. Done means the example-generation contract supports custom implementations without overriding fromOperation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100