Skip to content

[BUG][csharp] Loss of description in generated code for enum property using allOf #17545

@fujieda

Description

@fujieda

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

In the following definition, the mode property in TestResponse uses allOf for a single enum type.

TestResponse:
  type: object
  properties:
    mode:
      description: Test mode
      type: object
      allOf:
        - $ref: '#/components/schemas/TestEnum'
TestEnum:
  description:  Specify the test mode
  type: string
  enum:
    - A
    - B

This technique, while peculiar, has been effective in preserving the description in the generated property until version 6.4.0, resulting in the following C# code:

/// <summary>
/// Test mode
/// </summary>
/// <value>Test mode</value>
[DataMember(Name="mode", EmitDefaultValue=false)]
public TestEnum? Mode { get; set; }

However, starting with version 6.5.0 and later, the description is no longer included in the generated code, resulting in a loss of compatibility. The change in behavior can be observed in the following code snippet:

/// <summary>
/// Gets or Sets Mode
/// </summary>
[DataMember(Name="mode", EmitDefaultValue=false)]
public TestEnum? Mode { get; set; }

This compatibility issue has been present since the commit a4dd90c.

openapi-generator version

6.5.0 and later, including the latest master

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: allOf enum test
  version: 1.0.0
paths: {}

components:

  schemas:
    TestResponse:
      type: object
      properties:
        mode:
          description: Test mode
          type: object
          allOf:
            - $ref: '#/components/schemas/TestEnum'

    TestEnum:
      description:  Specify the test mode
      type: string
      enum:
        - A
        - B
Generation Details

java -jar openapi-generator-cli-7.2.0.jar generate -g csharp -i simple.yaml

Related issues/PRs

#15035

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