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

Feature request: support configuring generated struct tags #79

Closed
codeboten opened this issue May 16, 2023 · 5 comments · Fixed by #80
Closed

Feature request: support configuring generated struct tags #79

codeboten opened this issue May 16, 2023 · 5 comments · Fixed by #80
Milestone

Comments

@codeboten
Copy link
Contributor

Currently the generated code always sets a struct tag for json, yaml, and mapstructure. See:

if isRequired {
structField.Tags = fmt.Sprintf(`json:"%s" yaml:"%s" mapstructure:"%s"`, name, name, name)
} else {
structField.Tags = fmt.Sprintf(`json:"%s,omitempty" yaml:"%s,omitempty" mapstructure:"%s,omitempty"`,
name, name, name)

It would be great if it was possible to pass in a configuration option to specify which of these to set.

codeboten pushed a commit to codeboten/go-jsonschema that referenced this issue May 25, 2023
This feature allows users to configure which struct tags to generate. By
default it generates json, yaml, mapstructure.

Fix omissis#79

Signed-off-by: Alex Boten <aboten@lightstep.com>
codeboten pushed a commit to codeboten/go-jsonschema that referenced this issue May 25, 2023
This feature allows users to configure which struct tags to generate. By
default it generates json, yaml, mapstructure.

Fix omissis#79

Signed-off-by: Alex Boten <aboten@lightstep.com>
@omissis
Copy link
Owner

omissis commented May 26, 2023

Hi @codeboten, thanks for raising this issue and for contributing the PR! Question: do those unused, extra tags cause issues in downstream code, or is this change done for "cosmetic" purposes only?

@codeboten
Copy link
Contributor Author

@omissis the request came from this comment open-telemetry/opentelemetry-collector#7679 (comment). The rest of the code for the configuration for the collector only contains mapstructure struct tags, so i think this is mostly for consistency

@omissis
Copy link
Owner

omissis commented May 26, 2023

I see, thanks. I'll ask on that PR and I will take a look over the weekend

@codeboten
Copy link
Contributor Author

@omissis any thoughts on whether the PR for this feature can get merged?

@omissis
Copy link
Owner

omissis commented Jun 14, 2023

@codeboten yeah I asked on the pr some clarifications, and I'm ok with offloading some maintenance off them to have it here, even though I feel the command interface is becoming a bit bloated. I'll see to review this PR as soon as possible. Thanks!

codeboten pushed a commit to codeboten/go-jsonschema that referenced this issue Jun 22, 2023
This feature allows users to configure which struct tags to generate. By
default it generates json, yaml, mapstructure.

Fix omissis#79

Signed-off-by: Alex Boten <aboten@lightstep.com>
omissis pushed a commit that referenced this issue Jun 25, 2023
This feature allows users to configure which struct tags to generate. By
default it generates json, yaml, mapstructure.

Fix #79

Signed-off-by: Alex Boten <aboten@lightstep.com>
@omissis omissis added this to the v0.12.0 milestone Jun 25, 2023
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 a pull request may close this issue.

2 participants