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
Add custom_get_name
config option
#889
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
.gitignore
Outdated
@@ -7,3 +7,4 @@ __pycache__ | |||
/dist | |||
/.github/changelog-generator-cache | |||
/tests/recursion.py | |||
/.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be on your own ~/.gitignore
file...
tests/test_custom_get_name.py
Outdated
GetNameFunction = Callable[ | ||
[ | ||
Optional[ | ||
Union[ | ||
jsonschema_draft_04.JSONSchemaD4, | ||
jsonschema_draft_2019_09_meta_data.JSONSchemaItemD2019, | ||
] | ||
], | ||
Optional[str], | ||
bool, | ||
], | ||
str, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this copy?
@@ -2,10 +2,12 @@ | |||
Automatically generated file from a JSON schema. | |||
""" | |||
|
|||
from typing import Any, Literal, TypedDict, Union | |||
from typing import Any, Callable, Literal, Optional, TypedDict, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated from jsonschema_gentypes/schema.json
and describes the schema of the configurations file.
Then if we want to be able to configure it only with python code we should get the function definition out of this file :-)
But in fact, I didn't see well how you plan to use it?
Like in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbrunner ok! I fixed the two other issues you pointed out.
I can totally get the definition out and instead put it in the configuration
file.
what's the command to generate the schema.json from the configuration file?
I plan to use this exactly how I use it in the test.
Without the custom_get_name
, you wind up with the .title
version like Subresourceuri
as the name and the test fails. I need the only-first-letter-capitalized version like SubresourceUri
.
I also invoke this by importing the process_config
function from a Python script, not from the cli.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbrunner want me to pull that definition out of the configuration
file? any other changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the command to generate the schema.json from the configuration file?
It's the inverse, this file is generated from this schema https://github.com/sbrunner/jsonschema-gentypes/blob/7c7fe0d6f5539c13334580762bfacef292c6edba/jsonschema_gentypes/schema.json
It's done by pre-commit :-)
for more information, see https://pre-commit.ci
Attached is what I'm thinking for a way to allow individual users of the library to pass their own
get_name
method.In case they want to have generated python class types like
SubresourceUri
instead of just the default.title()
version ofSubresourceuri
#843
NOTE: we'll need to swap
get_name
toself.get_name
on all subclasses ofAPI
before we can merge this repo. I only didAPI
andAPIv4
so far.