Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of not validating for enum params. What about if:
this.{{{name}}}.ToString().Length > {{maxLength}}so that it will work for other case like:Else, it will also break at:
UuidProperty.Length > 36There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you mean, are you saying strings with
format: uuidare not String objects and thus need thetoString()call? Looks like a separate issue if that's what you meant.Here the fix simply skips adding validation checks if the property specifies an enum, which is a very reliable and future-proof way, me thinks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings with format: uuid are of Guid type in c#. The comment is valid however and worth some thought. If there is a simple way to keep validation and still have the enum behavior that might be worth exploring. However having validation for enum parameters would mean that they might break at some point in the future when one decides to use the forbidden values for the first time instead of breaking immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I meant to say is
Strings with format: uuid are of Guid type in c#.And, as the above validations like
MaxLength/MinLengthare specific tostringtype. Its better to convert to string type usingToString()before validating the property.Similar to that I found in
ruby-client-> https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache#L302 (to_sconverts tostringIIUC)Besides, it might be separate issue but the gist of the bug is same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guids really don't have the same issue however. Reason being that it performs its own validation. Of course the same applies you could technically have the validation parameters in the spec I guess. It just makes no sense whatsoever.