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 missing validation in embedded structs #3034

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Dec 29, 2023

This PR fixes the empty Validate methods generated when generating embedded structs (that is, when an object redefines another object with a $ref).

Since the actual need for validation is not known when hitting the embedded struct, always assume a validation.

Exception: when the embedded type is interface{} or io.Reader, we know that we should not call Validate.

@fredbi fredbi added the validator Related to codegen generation of validations label Dec 29, 2023
* fixes go-swagger#2604

This PR fixes the empty Validate methods generated when generating
embedded structs (that is, when an object redefines another object
with a $ref).

Since the actual need for validation is not known when hitting the
embedded struct, always assume a validation.

Exception: when the embedded type is interface{} or io.Reader, we
know that we should not call Validate.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi merged commit a937d36 into go-swagger:master Dec 30, 2023
18 checks passed
@fredbi fredbi deleted the fix/2604-embedded-models branch December 30, 2023 19:47
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.

Generated code fails to call the Validate function on embedded structs resulting in incorrect validation
2 participants