cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Problem with inheritance after version 0.17.3 #184

Closed drenda closed 2 years ago

drenda commented 2 years ago

Updating from version 0.17.3 to latest version, I've problems with inheritance. I know you changed that part but in my case it broken the model.

I've these models in my openapi.json:

AuditLog

"AuditLog": {
        "required": [
          "operationType",
          "severity",
          "type"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "createdDate": {
            "type": "string",
            "format": "date-time"
          },
          "lastModifiedDate": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "$ref": "#/components/schemas/AuditUser"
          },
          "lastModifiedBy": {
            "$ref": "#/components/schemas/AuditUser"
          },
          "operationType": {
            "$ref": "#/components/schemas/AuditType"
          },
          "severity": {
            "$ref": "#/components/schemas/AuditLogSeverity"
          },
          "remoteAddress": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "parentType": {
            "type": "string"
          },
          "parentId": {
            "type": "integer",
            "format": "int64"
          },
          "type": {
            "type": "string"
          }
        },
        "discriminator": {
          "propertyName": "type"
        }
      },

and AuditCdr

 "AuditCdr": {
        "required": [
          "operationType",
          "severity"
        ],
        "type": "object",
        "allOf": [
          {
            "$ref": "#/components/schemas/AuditLog"
          },
          {
            "type": "object",
            "properties": {
              "callFrom": {
                "type": "string"
              },
              "callTo": {
                "type": "string"
              },
              "callType": {
                "$ref": "#/components/schemas/CallType"
              },
              "callStartDate": {
                "type": "string",
                "format": "date-time"
              },
              "callEndDate": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },

With ng-open-api 0.17.3 this is what is generated:

/* tslint:disable */
/* eslint-disable */
import { AuditLogSeverity } from './audit-log-severity';
import { AuditType } from './audit-type';
import { AuditUser } from './audit-user';
export interface AuditLog {
  createdBy?: AuditUser;
  createdDate?: string;
  id?: number;
  lastModifiedBy?: AuditUser;
  lastModifiedDate?: string;
  operationType: AuditType;
  parentId?: number;
  parentType?: string;
  remoteAddress?: string;
  severity: AuditLogSeverity;
  text?: string;
  type: string;
}

and

/* tslint:disable */
/* eslint-disable */
import { AuditLog } from './audit-log';
import { CallType } from './call-type';
export interface AuditCdr extends AuditLog {
  callEndDate?: string;
  callFrom?: string;
  callStartDate?: string;
  callTo?: string;
  callType?: CallType;
}

This is what I expected and it works fine. After version 0.17.3 instead models are generated in this way:

/* tslint:disable */
/* eslint-disable */
import { AuditLogSeverity } from './audit-log-severity';
import { AuditType } from './audit-type';
import { AuditUser } from './audit-user';
export interface AuditLog {
  createdBy?: AuditUser;
  createdDate?: string;
  id?: number;
  lastModifiedBy?: AuditUser;
  lastModifiedDate?: string;
  operationType: AuditType;
  parentId?: number;
  parentType?: string;
  remoteAddress?: string;
  severity: AuditLogSeverity;
  text?: string;
  type: string;
}

and

/* tslint:disable */
/* eslint-disable */
import { AuditLog } from './audit-log';
import { CallType } from './call-type';
export interface AuditCdr {
}

The problem is as you can see with AuditCdr that has not any fields. Am I missing something or this is not intended behaviour?

Thanks

drenda commented 2 years ago

Hi, any news about this? Thanks

luisfpg commented 2 years ago

I'm trying to find some time on it. I could reproduce, so I'm trying to find the cause.

drenda commented 2 years ago

Wonderful. When the new version will be published?

Thanks

luisfpg commented 2 years ago

Was already released with 0.20.0.