Skip to content

fix: allow space on jsonschema tags - #147

Open
nvanheuverzwijn wants to merge 1 commit into
invopop:mainfrom
nvanheuverzwijn:fix-allow-space-on-jsonschema-tags
Open

fix: allow space on jsonschema tags#147
nvanheuverzwijn wants to merge 1 commit into
invopop:mainfrom
nvanheuverzwijn:fix-allow-space-on-jsonschema-tags

Conversation

@nvanheuverzwijn

@nvanheuverzwijn nvanheuverzwijn commented Aug 1, 2024

Copy link
Copy Markdown

I was trying to parse this golang struct:

type Tool struct {
	Environment string `json:"environment,omitempty" jsonschema:"enum=dev, enum=qa, enum=staging, enum=production, enum=other"`
}

and I realized that the enum were not being populated correctly. Turns out I needed to remove the space from the struct. I added a PR to trim the tags if that's something interesting for you guys. Otherwise, I will open another PR with documentation change to reflect that jsonschema should not have any space betweem each tags.

I also added another enum in the test fixtures with spaces. The actual code change is here https://github.com/invopop/jsonschema/pull/147/files#diff-672d1dd2b9193c8818108f625c29ff25feaea4c1c50cc36cfda18108cba3e1b2

@samlown samlown left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks useful! Thanks! I do think it would be better however to move the test outside of the mega-example to avoid updating all the fixtures.

Comment thread reflect_test.go Outdated
@samlown samlown added the enhancement New feature or request label Oct 7, 2024
@nvanheuverzwijn
nvanheuverzwijn force-pushed the fix-allow-space-on-jsonschema-tags branch from 4b9dcfb to 538b528 Compare October 9, 2024 15:32
@nvanheuverzwijn

Copy link
Copy Markdown
Author

@samlown You are right, much cleaner that way :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants