OpenAPITools / OpenAPITools/openapi-generator

[REQ] Enable accessing child type `Bar` or `Baz` from the type `GetFoo*Response` / `CreateFoo*Response`

Open
#18,764 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.

This is the link to a different feature request but the setup/scenario is the same: here

It would be very convenient if there would a way to get the Bar or Baz type out of Get/CreateFooDefaultResponse type. I imagine they might be created as inner classes or similar -- the generator should already be aware which attributes belong to which type.

Describe the solution you'd like

For example, the type GetFoo*Response will be generated if the GET request might return either type Bar or Baz. Ideally I would be able to call an inner class on the type which would give me an object of Bar/Baz.

Describe alternatives you've considered

An alternative is to create and use an utility method that extracts the appropriate type attributes - it goes without saying that this is tedious.

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

Review the response-type generation behavior for Get/CreateFoo*Response and the related feature request in issue #18763. Determine how Bar and Baz are represented in generated responses; done means callers can access the matching child type without a separate utility extractor.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.