Swagger-codegen: [Typescript-angular2] Inheritance in generated model not working

Created on 18 May 2017  路  4Comments  路  Source: swagger-api/swagger-codegen

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{}

TypeScript Composition / Inheritance Bug

Most helpful comment

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

All 4 comments

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

@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?

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

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

Was this page helpful?
0 / 5 - 0 ratings