swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Typescript-angular2] Inheritance in generated model not working

Open sidebaet opened this issue 9 years ago • 4 comments

Description

I use swagger to generate my angular4 client and I have an issue when I have inheritance in my model. The generated typescrpit is not correct. The generated code is :

parent.ts:

export interface Parent{}

child.ts:

import {Parent} from './Parent';

export interface Child extends models.Parent{}

Swagger-codegen version

2.3.0-SNAPSHOT

Swagger declaration file content or url

BaseHospitalVisit: type: object AmbulatoryVisit: allOf: - $ref: '#/BaseHospitalVisit' - type: object

Command line used for generation
API V1 generate generate-resources api model /v1/api.yaml typescript-angular2
Suggest a Fix

Generate: export interface Child extends Parent{}

sidebaet avatar May 18 '17 08:05 sidebaet

@sidebaet can you share the spec via https://gist.github.com so that the community can use it to reproduce the issue?

wing328 avatar May 25 '17 11:05 wing328

@wing328 I am able to reproduce with: https://gist.github.com/austin94/11642f6482dc2eed7a227979f0b44dfe

The fix for me was to just remove the models. string in modelGeneric.mustache. It appears that this was being used when the models namespace was still around?

austingreendev avatar May 26 '17 00:05 austingreendev

@austin94 thanks for sharing more. I wonder if you can file a PR with the suggested fix when you've time.

wing328 avatar May 29 '17 02:05 wing328

@wing328 Sure, I can submit a PR in the next few days.

austingreendev avatar May 29 '17 03:05 austingreendev