swagger-api / swagger-api/swagger-codegen-generators

[typescript-angular] multiple `allOf` with `allOf` does not work

Open
#1,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Given the following schema:

swagger: '2.0'
paths:
  "/api/v1/users":
    get:
      summary: Get users
      operationId: GetUserRoute
      responses:
        '200':
          description: Ok
          schema:
            type: array
            items:
              "$ref": "#/definitions/user"
definitions:
  user:
    type: object
    allOf:
    - "$ref": "#/definitions/requiredUser"
    - "$ref": "#/definitions/optionalUser"
  requiredUser:
    type: object
    allOf:
    - "$ref": "#/definitions/email"
    required:
    - id
    properties:
      id:
        type: string
  email:
    type: string
  optionalUser:
    type: object
    allOf:
    - "$ref": "#/definitions/address"
    properties:
      name:
        type: string
  address:
    type: object
    properties:
      zipCode:
        type: string
      street:
        type: string

It describes a user that is allOf: requiredUser, optionalUser.
And they are again composed of properties and allOf.

Then the generated user.ts looks like this:

import { OptionalUser } from './optionalUser';
import { RequiredUser } from './requiredUser';

export interface User extends RequiredUser { 
    name?: string;
}

So all of requiredUser is included, and only the immediate properties of optionalUser but not the address from the allOf.

My expectation would be:

import { OptionalUser } from './optionalUser';
import { RequiredUser } from './requiredUser';

export interface User extends RequiredUser, OptionalUser { 
}

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 at the typescript-angular generator entry point and trace how nested allOf definitions are converted into the generated user.ts interface. Reproduce the issue with the schema in the report, then compare the output with the expected multiple-inheritance form. Done means nested allOf references such as address are preserved in the generated interface without breaking existing composition.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.