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

Take length from MinLenght, MaxLength data annotation attributes to add minLength, maxLength to schema #1303

Open
georgievaja opened this issue Feb 19, 2019 · 0 comments

Comments

@georgievaja
Copy link

STEPS TO REPRODUCE:

  • when using MinLenght ro MaxLenght DataAnnotation attributes, no minLenght or maxLenght schema properties are being generated

EXPECTED RESULT:

  • minLenght, maxLenght are in schema

ADDITIONAL DETAILS

  • it would be enough if you would add
                if (attribute is MaxLengthAttribute maxLength)
                {
                    schema.maxLength = maxLength.Length;
                }

                if (attribute is MinLengthAttribute minLength)
                {
                    schema.minLength = minLength.Length;
                }

to your Swashbuckle.Core/Swagger/SchemaExtensions.cs - WithValidationProperties
but you would have to update .NET framework to 4.5 as in this pr: #1302

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