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

try out pydantic (or just data classes) for REST API validation #4655

Open
minrk opened this issue Dec 8, 2023 · 1 comment
Open

try out pydantic (or just data classes) for REST API validation #4655

minrk opened this issue Dec 8, 2023 · 1 comment

Comments

@minrk
Copy link
Member

minrk commented Dec 8, 2023

Proposed change

Python dataclasses (and at a higher level, pydantic) allow convenient validation and serialization of JSON request/reply schemas. I think we can try this out incrementally with new APIs and slowly adopt it more as we like it. It should have no user-facing consequences (aside from the dependency, see below).

Alternative options

  • Just use dataclasses (stdlib, avoids current issues around the pydantic v2 migration, which will affect users because it would be installed in the single-user environment)
  • Keep manual JSON validation (tedious, I started looking into this for user-initiated sharing #4594 after writing yet another JSON model validation method

Who would use this feature?

Mostly JupyterHub maintainers, but especially with pydantic, it could be used to generate accurate docs, as is done with FastAPI.

@minrk
Copy link
Member Author

minrk commented Mar 4, 2024

This is currently done on the sharing endpoints only. I had a pretty good experience, so I think we can iteratively apply these to the other endpoints.

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

No branches or pull requests

1 participant