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
  • #5294
Closed
Open
Issue created Feb 11, 2020 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][CSharp] Bug generating code with Enum having maxLength property

Created by: shwetashukla

Hi

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

We have an open api spec version 2.0 and we are trying to generate code in csharp . We have an issue in generated SDKif the property whose type is string is an enum and has maxLength specified . Please refer line 121 in attached contract . petstore.txt

Below is the code in csharp and the one in bold throws error.

// Status (string) maxLength if(this.Status != null && this.Status.Length > 20) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Status , length must be less than 20.", new [] { "Status " }); }

openapi-generator version

3.3.4

OpenAPI declaration file content or url

petstore.txt

Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix

csharp code should be like The code should be like this.Status.ToString().Length.

In the snapshot below we can make fix

image

Assignee
Assign to
Time tracking