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
  • Merge requests
  • !10365

[Kotlin-spring] fix model inheritance

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/galeries-lafayette/fix/kotlin-inheritance into master Sep 10, 2021
  • Overview 0
  • Commits 3
  • Pipelines 1
  • Changes 4

Created by: frecco75

This PR fixes kotlin classes generation with inherited models in the source schema.

For example given this schema

openapi: "3.0.1"
info:
  version: 1.0.0
  title: Users

paths:
  /users:
    get:
      responses:
        200:
          description: users
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
  
  
components:
  schemas:
    User:
      type: object
      required:
        - name
      properties:
        name:
          type: string
      discriminator:
        propertyName: type

    Admin:
      title: Admin
      allOf:
        - $ref: '#/components/schemas/User'
        - type: object
          required:
            - role
          properties:
            role:
              type: string

With the fix the generated code is valid and compiles correctly.

Moreover, it's better to use JsonTypeInfo.As.EXISTING_PROPERTY to avoid duplicate name in the JSON response

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/galeries-lafayette/fix/kotlin-inheritance