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
Generate server: UnmarshalJSON redeclared for object with default values when --strict-additional-properties specified #2189
Comments
Thanks for reporting this. The problem is indeed more general than this specific use case: unmarshallers with default values conflict with other unmarshallers. I am reshuffling the templates for serializers so we can get a clearer view on this. |
fredbi
added a commit
to fredbi/go-swagger
that referenced
this issue
Jan 29, 2020
…LITY * reshuffled serializers templates in a separate directory, split the templates by schema type * reindented model templates, using {{- }}, fixed some issues with template blank gobbling * revamped docstring (fixed unattended line feed, removed unused hardcoded reference) * regenerated examples * contributes to forthcoming fix for go-swagger#2189 Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi
added a commit
to fredbi/go-swagger
that referenced
this issue
Jan 29, 2020
…LITY * reshuffled serializers templates in a separate directory, split the templates by schema type * reindented model templates, using {{- }}, fixed some issues with template blank gobbling * revamped docstring (fixed unattended line feed after comments, removed unused hardcoded reference) * regenerated examples * contributes to forthcoming fix for go-swagger#2189 Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi
added a commit
to fredbi/go-swagger
that referenced
this issue
Feb 8, 2020
…LITY Motivation: I wanted to fix some bugs with model generation, but needed to clarify things a bit beforehand * reshuffled serializers templates in a separate directory, split the templates by schema type * reindented model templates, using {{- }}, fixed some issues with template blank gobbling * revamped docstring (fixed unattended line feed after comments, removed unused hardcoded reference) * fixes go-swagger#2215 (syntax error in templates, no more tolerated by go1.14) * contributes to forthcoming fixes for go-swagger#2189 (serializers with defaults), go-swagger#2220 (edge cases on polymorphic types) * contributes to go-swagger#673 (templates readability) Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Adapted test expectations to slight modifications of how goformat ends up when some blank lines are removed Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Regenerated examples Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
casualjim
pushed a commit
that referenced
this issue
Feb 8, 2020
…LITY Motivation: I wanted to fix some bugs with model generation, but needed to clarify things a bit beforehand * reshuffled serializers templates in a separate directory, split the templates by schema type * reindented model templates, using {{- }}, fixed some issues with template blank gobbling * revamped docstring (fixed unattended line feed after comments, removed unused hardcoded reference) * fixes #2215 (syntax error in templates, no more tolerated by go1.14) * contributes to forthcoming fixes for #2189 (serializers with defaults), #2220 (edge cases on polymorphic types) * contributes to #673 (templates readability) Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Adapted test expectations to slight modifications of how goformat ends up when some blank lines are removed Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Regenerated examples Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem statement
Using go-swagger to generate a server. My schema defines an object with default values specified for some properties, and I am specifying the --strict-additional-properties command-line option.
The generated code has two instances of the UnmarshalJSON() method for this object, resulting in a compilation error.
If the server is generated without the --strict-additional-properties command-line option, only one UnmarshalJSON() method is generated.
In addition, if the default values are removed from the Swagger definition, only one UnmarshalJSON() method is generated.
Please remove the sections that don't apply
Swagger specification
Steps to reproduce
Environment
swagger version: v0.21.0
go version: go1.11.5
OS: Linux
The text was updated successfully, but these errors were encountered: