Skip to content

[BUG][CSHARP][GENERICHOST] Enums not written to JSON in expected format #21697

@alec-petersen

Description

@alec-petersen

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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 JsonConverter.Write method for enums, there is only this line:

writer.WriteStringValue(counterEnum.ToString());

This causes enums to be written to JSON as "DailyMaintenance" or "MonthlyRinse" instead of "daily_maintenance" and "monthly_rinse" as they may be formatted in the OpenAPI specification.

openapi-generator version

7.14

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

Define an enum in the specification which has values like "daily_maintenance" and "monthly_rinse"

Related issues/PRs

None that I could find.

Suggest a fix

It seems like we should replace .ToString with BlahEnumValueConverter.ToJsonValue(blahEnum). I can open a PR for review.

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