OpenAPITools / OpenAPITools/openapi-generator

allOf ignored when the property is used on its own

Open
#4,146 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

https://github.com/OpenAPITools/openapi-generator/pull/3771 (v4.1.2) breaks code generation (TypeScript) when a model only defines a single allOf/$ref and no other properties.

Example

MyModel:
      description: a model
      allOf:
        - $ref: '#/components/schemas/MyOtherModel'

Generated output

import { SomeImportPropertyType } from './propModel';    // this is correct

/**
 * MyModel
 */
export interface MyModel { 
    // properties from {MyOtherModel} are missing
}
export namespace MyModel {
}

@wing328 I assume this is what you meant could happen by your comment https://github.com/OpenAPITools/openapi-generator/pull/3771#discussion_r318663859

openapi-generator version

latest

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

Reproduce the TypeScript generation case from the issue using a schema with a single allOf/$ref, then compare the relevant generation path with the change discussed in PR 3771. Done means the generated MyModel includes the properties inherited from MyOtherModel while preserving the shown import and interface structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.