OpenAPITools / OpenAPITools/openapi-generator

[BUG] C# Generator with component name "on" produces in correct datamember

Open
#13,609 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [x ] 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?
    Actual:
        [DataMember(Name="true", EmitDefaultValue=false)]

Expected:

        [DataMember(Name="on", EmitDefaultValue=false)]
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I created a schema component for which one of the propties is called on. Somewhere in the generation step, the value on gets lost is translated to true

openapi-generator version

I'm using version 6.2.0
It's a regression. It used to work in version 5.x.x

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 0.0.1
  title: Test

  
paths:
  /:
    get:
      summary: get test
      responses:
        '200':
          description: OK

servers:
  - url: http://localhost:81

components:
  schemas:
    Effect:
        properties:
          on:
            description: If true, turns on the visual effect. If false, turn off the visual effect.
            type: boolean
Generation Details
Steps to reproduce
  1. save the yml file as example.yml
  2. Run: openapi-generator-cli generate -g csharp -i ./file.yml -o client
Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the supplied OpenAPI YAML and the command openapi-generator-cli generate -g csharp -i ./file.yml -o client using version 6.2.0. Trace the C# generator's handling of the component property named on; done means the generated DataMember uses Name="on" rather than Name="true", while preserving the boolean property behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.