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

Dynamically excluding a field in a struct from json schema export #149

Open
iangregsondev opened this issue Aug 14, 2024 · 1 comment
Open
Labels
question Further information is requested

Comments

@iangregsondev
Copy link

Hi,

I was wondering if it's possible to exclude a field dynamically.

I have the following field.

	Internal InternalConfig `json:"internalConfig"`

What would be ideal is to create 2 schemas: one for developers, which includes this field, and the other for clients (I am using this schema to create a Markdown file).

InternalConfig is something I don't want to exist in the client schema (which I use for creating markdown documentation)

Any ideas?

I am probably missing something.

Thanks in advance

ian

@samlown
Copy link
Contributor

samlown commented Oct 7, 2024

Hi! How did you solve this in the end?

Assuming you're running the Reflect method in some kind of one-off script as opposed to on-demand or dynamically. You could consider using globals or flags alongside the JSONSchemaExtend method to determine if the InternalConfig should be included or not: https://github.com/invopop/jsonschema?tab=readme-ov-file#custom-type-definitions

@samlown samlown added the question Further information is requested label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants