Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3646
Closed
Open
Issue created Aug 15, 2019 by Administrator@rootContributor

[BUG] [typescript-fetch] serialize/deserialze not working with inheritence

Created by: stephanpelikan

Description

Properties of super-classes are not serialized/deserialized.

openapi-generator version

4.1.0

OpenAPI declaration file content or url
components:
  schemas:
    Type:
      type: string
      enum:
      - B
    A:
      type: object
      discriminator:
        propertyName: type
      required:
      - type
      properties:
        whatever-a:
          type: string
        type:
          $ref: "#/components/schemas/Type"
    B:
      allOf:
        - $ref: "#/components/schemas/A"
        - type: object
          discriminator:
            propertyName: type
          properties:
            whatever-b:
              type: string
Suggest a fix

in modelGeneric.mustache add the lines with comment:

export function {{classname}}FromJSON(json: any): {{classname}} {
    {{#hasVars}}
    return {
        {{#parent}}...{{{parent}}}FromJSON(json),{{/parent}}  // deserialize inherited properties as well
        {{#additionalPropertiesType}}
            ...json,
        {{/additionalPropertiesType}}

and

export function {{classname}}ToJSON(value?: {{classname}}): any {
    {{#hasVars}}
    if (value === undefined) {
        return undefined;
    }
    return {
        {{#parent}}...{{{parent}}}ToJSON(value),{{/parent}}     // serialize inherited properties as well
        {{#additionalPropertiesType}}
            ...value,
        {{/additionalPropertiesType}}
Assignee
Assign to
Time tracking