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

fix(validations): fixed MinProperties/MaxProperties #3033

Merged
merged 1 commit into from
Dec 31, 2023

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Dec 29, 2023

This PR fixes some cases in which the Min/MaxProperties were wrongly evaluated:

Other fixes:

This PR introduces some context to GenSchema, namely IsElem and IsProperty, to allow templates to take better informed decisions. At this moment, this is only used by the minmaxproperties validation template.

@fredbi fredbi marked this pull request as ready for review December 29, 2023 20:19
@fredbi fredbi added the validator Related to codegen generation of validations label Dec 29, 2023
* fixes go-swagger#2587

This PR fixes some cases in which the Min/MaxProperties were wrongly
evaluated:
* case of a property which is a map (issue go-swagger#2587)
* case of a property which is an array  (non reported issue)
* edge case of a map representing an object with additionalProperties:
  false and a enum validation

Other fixes:
* fixed duplicate or missing Min/MaxProperties documentation in
  docstrings
* whenever a min/maxProperties validation is present, if no additional
  properties key is provided, assume "additionalProperties: true"

* Tests
  * added more assertions for existing test cases involving min/max
    properties (go-swagger#2444, go-swagger#2163)
  * added codegen assertions with an extended version of the spec
    provided with issue go-swagger#2587

This PR introduces some context to GenSchema, namely IsElem and
IsProperty, to allow templates to take better informed decisions.
At this moment, this is only used by the minmaxproperties validation
template.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi merged commit 1f6ae7d into go-swagger:master Dec 31, 2023
18 checks passed
@fredbi fredbi deleted the fix/2587-maxProperties branch December 31, 2023 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validator Related to codegen generation of validations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation code for maxProperties is generated incorrectly
2 participants