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

Optionally provide SchemaIDNameFormatter for $id field #82

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gmlewis
Copy link
Contributor

@gmlewis gmlewis commented Jun 28, 2023

Fixes: #81.

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@samlown samlown added the invalid This doesn't seem right label Sep 6, 2023
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@gmlewis gmlewis changed the title Remove ToSnakeCase for $id field Optionally use CamelCase for $id field Sep 6, 2023
@gmlewis
Copy link
Contributor Author

gmlewis commented Sep 6, 2023

@samlown - thank you for the feedback.
What do you think of this solution?

reflect.go Outdated
@@ -149,6 +149,10 @@ type Reflector struct {
// include a schema ID.
BaseSchemaID ID

// UseCamelCaseForIDs determines if missing IDs will use CamelCase (e.g. `TestUser`)
// or the default snake-case (e.g. `test-user`) when creating the BaseSchemaID.
UseCamelCaseForIDs bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than a specific case, It'd probably be better to use a specific method, which is consistent with some of the other text modifiers.

Something like:

SchemaIDNameFormatter func(id string) string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, is this more like what you are thinking of, @samlown ?

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@gmlewis gmlewis changed the title Optionally use CamelCase for $id field Optionally provide SchemaIDNameFormatter for $id field Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kebab-case $id fields break Python jschon parser
2 participants