Skip to content

[CSHARP] Multi Level inheritance is not building #1068

@mdulisch

Description

@mdulisch
Description

If you build a definition with multiple level inheritance, the compiler will not build the generated code.
There are two problems.

  1. the constructor only has the readWrite variables (no possibility to set read only variables)
  2. The "parentVars" list of the model of the generator does only list the vars of the direct parent.
openapi-generator version

3.2.3

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  version: 1.0.0
  title: Inheritence test
  description: Test
paths:
  /v1/post-child:
    post:
      responses:
        200:
          description: OK
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SecondChild'
        description: The actual event resource.
        required: true
components:
  schemas:
    Parent:
      description: the base Parent
      required:
        - secondProperty
      properties:
        firstProperty:
          description: readonly string 
          type: string
          readOnly: true
        secondProperty:
          description: required datetime
          type: string
          format: date-time
    FirstChild:
      description: The first child
      allOf:
        - $ref: '#/components/schemas/Parent'
        - required:
          - thirdProperty
          properties:
            thirdProperty:
              description: Required Property
              type: string
              maxLength: 36
    SecondChild:
      allOf:
        - $ref: '#/components/schemas/FirstChild'
        - required:
          - fourthProperty
          properties:
            fourthProperty:
              description: required Fourth Property
              type: string
Command line used for generation

java -jar .\openapi-generator-cli-3.2.3.jar generate -g csharp -i openapi.yaml

Steps to reproduce

Just generate the code and try to build

Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions