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

Add JSON tags to unmarshal int64s as strings #22

Closed
wants to merge 1 commit into from
Closed

Conversation

erademacher
Copy link
Contributor

No description provided.

@@ -19,7 +19,7 @@ type {{classname}} struct {
{{#deprecated}}
// Deprecated
{{/deprecated}}
{{name}} {{^required}}*{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{name}} {{^required}}*{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}{{#isString}},string{{/isString}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me!
I think including the tag for all isString is nice because it might also catch other json string cases in https://protobuf.dev/programming-guides/proto3/#json (sourced from grpc-ecosystem/grpc-gateway#219 (comment))

More specifically targeting int64s seems like it might be difficult. I looked at the "request_unit_limit" part of the json model used by the templates by adding --global-property debugModels to the openapi-generator generate ... command and did not see any "x": true variables we could immediately use.

@erademacher erademacher closed this May 9, 2023
@erademacher erademacher deleted the int-strings branch May 9, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants