openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Type is lost when extending model properties without specifying it's type

Open vyobukhov opened this issue 3 years ago • 0 comments

Minimal schema example:

openapi: 3.0.1
info:
  title: Schema Example
  version: 1.0.0
components:
  schemas:
    Common:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
    ExtendedSchema:
      allOf:
        - $ref: '#/components/schemas/Common'
        - type: object
          properties:
            noTypeFoo:
              description: "It should be any, that is correct"
            id:
              description: "It should be integer but we get any instead"

Expected type for ExtendedSchema model:

import type { Common } from './Common';

export type ExtendedSchema = (Common & {
    noTypeFoo?: any;
    id?: number;
});

Actual generated ExtendedSchema model:

import type { Common } from './Common';

export type ExtendedSchema = (Common & {
    noTypeFoo?: any;
    id?: any;
});

vyobukhov avatar Feb 15 '22 15:02 vyobukhov