This repository has been archived by the owner on Feb 25, 2022. It is now read-only.
Parse object from GET parameters #580
Comments
I think this is similar to #487 |
I think this is not same. This issue is bug because apistar generate correct openapi scheme:
But api don't work |
The only way to do what you try to do is by separating the handlers and using the same type validator: from apistar import App, Route, types, validators, http
class Product(types.Type):
name = validators.String(max_length=100)
rating = validators.Integer(minimum=1, maximum=5)
def post_welcome(product: Product) -> Product:
return product
def get_welcome(params: http.QueryParams) -> Product:
product = Product(dict(params)).validate() # yeah, it's hacky
return product
routes = [
Route('/', method='POST', handler=post_welcome),
Route('/', method='GET', handler=get_welcome, name='welcome_get'),
]
app = App(routes=routes)
if __name__ == '__main__':
app.serve('127.0.0.1', 5000, debug=True) Yes having a |
Closing this off given that 0.6 is moving to a framework-agnostic suite of API tools, and will no longer include the server. See https://discuss.apistar.org/t/api-star-as-a-framework-independant-tool/614 and #624. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version 0.5.27
Now i can't parse object if i send params in query (works only if send in body). Example:
POST query working good:
GET Query dosn't work:
The text was updated successfully, but these errors were encountered: