-
Notifications
You must be signed in to change notification settings - Fork 60
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
Using dynamic schemas #72
Comments
I believe I have an idea for this. Have a container with API much like class Callback(object):
def __init__(self, func, *args, **kwargs):
... with usage as follows (assuming there exists some function, @schema.validate(
input_schema={
"type": "object",
"properties": {
"user": {
"enum": [
Callback(get_users)
]
},
},
"required": ["user"]
}
)
def post(self):
... that would be resolved whenever this Now, introducing this would make So in finality, your snippet would end up looking something like: @schema.validate(
input_schema={
"type": "object",
"properties": {
"user": {
"enum": [
Callback(get_users)
]
},
},
"required": ["user"]
},
dynamic=True
)
def post(self):
... Does this sound reasonable? |
Implementation detail: the actual call will be done through |
Ok, sounds nice. Two remarks: |
Right, so this would work if the function that did this work was called asynchronously by class SchemaCallback(object):
def __init__(self. func, *args, **kwargs):
self.func = func
self.args = args
self.kwargs = kwargs My idea was just to have
Maybe this could be the |
I am new to this so to understand everything here I must see a full example how to use may be For the documentation |
Is there an easy way to create e. g. an input schema dynamicly? At the moment the schema is loaded at import time. I would like to set an
enum
property an fill it with data from my database which are, as one know, not available at import time and might change later.Example:
By the way: Thanks for this nice package again. :-)
The text was updated successfully, but these errors were encountered: