Skip to content

[BUG] [Csharp] distriminator property in subclass generated incorrect in the class constructor #20105

@WuZiHong

Description

@WuZiHong

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

The openapi3 yaml content looks like:

openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths: {}
components:
  schemas:
    CopyActivity:
      type: object
      required:
        - $schema
        - copyActivitytt
      properties:
        $schema:
          type: string
          enum:
            - ScopeActivity
        copyActivitytt:
          type: string
      allOf:
        - $ref: '#/components/schemas/EntityBase'
    EntityBase:
      type: object
      required:
        - $schema
      properties:
        $schema:
          type: string
      discriminator:
        propertyName: $schema
        mapping:
          ScopeActivity: '#/components/schemas/CopyActivity'

When I try to use this to generate csharp code, the constructor in the generated subclass is incorrect. Like below:
image

In the red box, the expected value should be default(stringEnum) instead of a string, as it cannot be correctly assigned.

openapi-generator version

7.9.0

Steps to reproduce

openapi3 yaml file -> csharp model classes

Could you please help check and tell me what I might have done wrong? Or is that should be a bug?

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