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

Code-generation of type hints and handler interfaces #376

Open
sisp opened this issue Oct 4, 2021 · 3 comments
Open

Code-generation of type hints and handler interfaces #376

sisp opened this issue Oct 4, 2021 · 3 comments

Comments

@sisp
Copy link
Contributor

sisp commented Oct 4, 2021

Something still missing in all OpenAPI-first implementations I've seen for Python including openapi-core is type-safety w.r.t. the validated request body, URL parameters, and headers. openapi-core validates this data, but there currently is no way to statically type it except for manually implementing the type hints and manually typing the request handlers. This is brittle and doesn't scale well.

I suggest to generate code containing type hints and request handler interfaces for the supported web frameworks similar to oapi-codegen (Golang) or fastapi-code-generator (Python).

The details need to be discussed and figured out, of course, but I'd appreciate some feedback first. What do you think?

@sisp
Copy link
Contributor Author

sisp commented Sep 25, 2022

@p1c2u Since you've been quite active again recently, I've been wondering about your opinion on this topic. 🙂 I've noticed your 👍 reaction to this vague idea. Would you (and of course also others) be interested in pursuing this idea more concretely, and would you have the capacity to discuss a concrete proposal?

@p1c2u
Copy link
Collaborator

p1c2u commented Sep 25, 2022

Hi @sisp
definitely interested. Feel free to propose your ideas. I added x-model extension support with possibility to use predefined models. See x-model extension.

@rafalkrupinski
Copy link

I'm working on something like this in Lapidary.

It's not a trivial problem, here's an article why:
https://modern-json-schema.com/json-schema-is-a-constraint-system

It's written mainly from java perspective, and while python class instances are a syntactic sugar over dicts (at least for simple data classes), it still applies to type hints.

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

No branches or pull requests

3 participants