Skip to content

Conversation

@nvanheuverzwijn
Copy link

@nvanheuverzwijn nvanheuverzwijn commented Aug 1, 2024

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

Copy link
Contributor

@samlown samlown left a comment

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.

@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
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