OpenAPITools / OpenAPITools/openapi-generator

[BUG] allOf to generate a model

Open
#2,076 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Issue: Workaround available
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I'm using this definition to simulate genericity of paging result:

responses:
        200:
          description: 'List of products for the shop'
          content:
            application/json:
              schema:
                title: ‘ProductList',
                allOf:
                  - $ref: '#/components/schemas/PaginateResults'
                  - type: object
                    properties:
                      results: 
                        type: array
                        items: 
                          $ref: '#/components/schemas/Product'

I'm expecting this to generate a ProductList model that contains PaginateResults and the additional one. Problem is that it doesn't generate ProductList at all only PaginateResults and Product. And the generated method return only a PaginateResults which is incorrect.

I checked under DefaultCodegen::getSchemaType and it return only the first allOf it found, I manage to check and return the title if it's set, but that's solve only half the problem as ProductList is still not generated :/ only the method definition is correct now

Any idea ?

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 with DefaultCodegen::getSchemaType and then trace the model-generation path for schemas using allOf. Verify the generated output for the provided PaginateResults and Product example: ProductList should be generated and the generated method should return it rather than PaginateResults.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.