Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nswag not handling the maxLength and pattern properties in the OpenAPI specification for array items #4879

Open
Dharam625 opened this issue May 2, 2024 · 0 comments

Comments

@Dharam625
Copy link

I have the following open api specification written in yaml:

type: object
additionalProperties: false
properties:
  oddNumbers:
    type: array
    items:
      type: string
      pattern: '^[0-9]+$'
      maxLength: 19
    example: ["1", "3", "5", "7", "9"]

Here is the generated c# code using NWag:


    [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
    public partial class OddNumbers
    {
        [System.Text.Json.Serialization.JsonPropertyName("oddNumbers")]
        public System.Collections.Generic.List<string> OddNumbers1 { get; set; }
    }

As you can see, pattern and maxLength applied at each array item in open api specification is not carried through in generated code.

is this feature not supported currently in Nswag or there is some configuration setting i am missing ?

Any help is much appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant