Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript-angular2 generator does not support polymorphism #6018

Closed
NBakaev opened this issue Jul 10, 2017 · 2 comments
Closed

Typescript-angular2 generator does not support polymorphism #6018

NBakaev opened this issue Jul 10, 2017 · 2 comments

Comments

@NBakaev
Copy link

NBakaev commented Jul 10, 2017

Description

Typescript-angular2 generator does not support polymorphism. If i have base object Founder and have 2 classes that extend that base class (eg FounderComp and FounderPers)

Swagger-codegen version

latest. reproducable via generation in http://editor.swagger.io

Swagger declaration file content or url
---
swagger: "2.0"
info:
  description: "REST API"
  version: "1.0-SNAPSHOT"
  title: "REST API"
  contact:
    url: "http://example.com"
    email: "support@example.com"
  license:
    name: "Company Licence"
host: "localhost:8081"
basePath: "/rest"
tags:
- name: "API"
- name: "founder"
- name: "user"
schemes:
- "http"
- "https"
paths:
  /founder-get:
    get:
      summary: "Returns partner verification"
      description: ""
      operationId: "getFounder"
      produces:
      - "application/json"
      parameters: []
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/Founder"
        404:
          description: "founder not found"
definitions:
  Founder:
    type: "object"
    discriminator: "type"
  FounderComp:
    allOf:
    - $ref: "#/definitions/Founder"
  FounderPers:
    allOf:
    - $ref: "#/definitions/Founder"
  
Command line used for generation
Steps to reproduce

generate in http://editor.swagger.io and get object
export interface FounderComp {
}

without "type" property, which should be setup when use discriminator and allOf in swagger

Related issues

#3904

Suggest a Fix

add new field "type" to every object that extend base class to determine type class

@wing328
Copy link
Contributor

wing328 commented Jul 13, 2017

@NBakaev Can you try the 2.3.0 branch instead (which contains a lot of enhancements for TS Angular2)?

I could find the following in the template:

swagger-codegen|2.3.0⚡ ⇒ grep -i parent modules/swagger-codegen/src/main/resources/typescript-angular2/*
modules/swagger-codegen/src/main/resources/typescript-angular2/modelGeneric.mustache:export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{

@wing328
Copy link
Contributor

wing328 commented Jul 17, 2017

We'll reopen this if this is still an issue with 2.3.0 (master)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants