Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #4954
Closed
Open
Issue created Jan 09, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][C#] Shouldn't replace tab, cr, lf in string enum values

Created by: kevinoid

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The EnumMember.Value generated for csharp (and csharp-netcore) replaces \t, \r, and \n characters with space characters. This causes values sent from the server to fail to deserialize and values sent to the server to not match the specified values.

openapi-generator version

Tested with 4.2.2 and current master (2d24d42e).

OpenAPI declaration file content or url
Example OpenAPI document
{
  "swagger": "2.0",
  "info": {
    "title": "Problematic enum strings example",
    "version": "1.0.0"
  },
  "definitions": {
    "ErrorMessage": {
      "type": "string",
      "enum": [
        "RangeError:\tToo many items.",
        "TypeError:\tInvalid type.\nCan't count multiple types.",
        "TypeError:\tInvalid type.\r\nCan't count multiple types."
      ]
    }
  },
  "paths": {
    "/count": {
      "get": {
        "operationId": "getCount",
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "type": "integer"
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/ErrorMessage"
            }
          }
        }
      }
    }
  }
}
Command line used for generation
openapi-generator generate -g csharp -i openapi.json -o generated
Steps to reproduce
  1. Copy example OpenAPI document into openapi.json.
  2. Run above command.
  3. Observe that EnumMember.Value in generated/openapi/src/Org.OpenAPITools/Model/ErrorMessage.cs does not match enum in openapi.json.
Related issues/PRs

None that I could find.

Suggest a fix

DefaultCodegen.escapeText could skip removal of \t\r\n or DefaultCodegen.toEnumValue could use a different method for escaping.

Thanks for considering, Kevin

Assignee
Assign to
Time tracking