OpenAPITools / OpenAPITools/openapi-generator

[REQ] Turn ExampleGenerator into a interface and allow an Codegen implementation to use its own example generator

Open
#7,523 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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, fromOperation and toExampleValue. I think that we could converhe those uses into the ExampleGenerator interface.

Describe alternatives you've considered

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.