ContextValidate panics if the field is nil
for discriminator types
#2911
Labels
discriminator
Related to polymorphic types
model
Related to swagger generate model command
validator
Related to codegen generation of validations
Problem statement
The context validation expects a field to be set and can panic if it's
nil
. I expect it to skip the validation if it'snil
.Swagger specification
pets.yml
The generated model for
animal.go
as the following validator since go-swagger v0.27.0Which panics if
m.Kind() == nil
While the check is done in the field's validation
Steps to reproduce
Go test:
The first assert pass, the second panics:
Environment
swagger version: 0.30.4
go version: 1.20
OS: Manjaro Linux 6.1.12
Potential fix
romainbou@76553bf
If this makes sense and doesn't have unforeseen consequences, I can make a PR.
Alternatively, would there be an option to disable
contextValidate
?Thanks!
The text was updated successfully, but these errors were encountered: