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

Add custom_get_name config option #889

Merged
merged 6 commits into from
May 21, 2024
Merged

Conversation

eupharis
Copy link
Contributor

@eupharis eupharis commented Mar 7, 2024

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 of Subresourceuri

#843

NOTE: we'll need to swap get_name to self.get_name on all subclasses of API before we can merge this repo. I only did API and APIv4 so far.

.gitignore Outdated Show resolved Hide resolved
tests/test_custom_get_name.py Outdated Show resolved Hide resolved
jsonschema_gentypes/configuration.py Outdated Show resolved Hide resolved
@eupharis
Copy link
Contributor Author

@sbrunner ok! I finally got a chance to fix this up.

The pull request checks are failing because my commits dont start with a capital letter. I think everything else is passing (pytest and pre-commit)

I've removed all by manual edits from configuration.py and now configuration.py generated by pre-commit

I couldn't make custom_get_name a callable in the schema.json.

So instead I made get_name_properties just a string enum with two options:

  • Title the default and current behavior
  • UpperFirst the new behavior where just the first letter is capitalized (but the rest of the title isn't lowercase)

Let me know what you think!

@sbrunner
Copy link
Owner

That looks good to me :-)

@eupharis
Copy link
Contributor Author

@sbrunner awesome! could we release it as new version?

The one failing check is this:

"requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/repos/sbrunner/jsonschema-gentypes/pulls/889/commits"

I think that's a spurious error maybe?

@sbrunner sbrunner merged commit 1a0112c into sbrunner:master May 21, 2024
1 of 2 checks passed
@geo-ghci-int geo-ghci-int bot added this to the 2.6.0 milestone May 21, 2024
@sbrunner
Copy link
Owner

Released in version 2.6.0

@eupharis
Copy link
Contributor Author

@sbrunner woohoo! thanks so much!

@eupharis eupharis deleted the custom-get-name branch May 21, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants