![]() ![]() Return current_app.ensure_sync(self.dispatch_request)(**kwargs)įile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/views.py", line 188, in dispatch_request Return self.ensure_sync(self.view_functions)(**view_args)įile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/views.py", line 107, in view Return gi_app(environ, start_response)įile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_appįile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_appįile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_requestįile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_requestįile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request name # Call use_args (from webargs) to inject params in function return wrapper return decoratorįile "/home/dinesh/pyworkspace/.VSMOREST/lib/python3.8/site-packages/flask/app.py", line 2548, in _call_ Il will be # replaced later on by $ref or json. # At this stage, put schema instance in doc dictionary. We shall add a note in the docs saying mixed multipart is not supported. Once is merged (almost done, just waiting for apispec 3.0), we'll be able to send files (using multipart), and to properly set a content type. I don't think I'll do that for the next release. I think we can live with this limitation. Otherwise, modifiers would be lost in the process. To be able to do so, we'd need to add a restriction to multipart_argument: only pass schema classes (or perhaps field dicts), not schema instances. This could avoid duplicating apispec code, or having to pull functions from there to do the job here. Things would go relatively smooth if we could pass apispec a schema that would be the aggregation of the different schemas involved ( a single schema inheriting from all). We could add a multipart_arguments decorator so that we don't have to detect multipart cases and we can ask for all needed parameters. This implementation issues make me think that the sanest way to do that would be to require more explicitness from the user. arguments( FormSchema, location = 'form', description = 'Some other description') arguments( FilesSchema, location = 'files', description = 'Some description') blp. The form/files case is a bit simpler because webargs does nothing, it just injects the relevant part of the request into the view function, leaving it the job of actually reading the blp. To actually receive xml, the user would need to subclass FlaskParser to add a parse_xml method and complete the mappings with xml -> body (perhaps this could be added to flask-rest-api core, but I'd rather not add an external dependency for it, and I don't think it is such a common case). Using location=json, content_type="application/xml" won't make the application parse xml. Note that the content type here is only used for documentation purpose. allow overriding content type par resource in with content or content_type argument.Those are default values than can be overridden in a Blueprint subclass form: application/x-www-form-urlencoded.It could be added to the temporary doc structure and used in _prepare_doc. I'm thinking maybe we could modify arguments to allow passing the content type. ![]() We may have to make an arbitrary choice here, just like we currently force application/json for body as it is complicated to parametrize.įiles: multipart/form-data? (And there would be no way to specify a specific type such as image/png)įorm: multipart/form-data? application/x-www-form-urlencoded? Now, we need to associate a content type to files and form. All we need to do is ensure that when using OAS3, body/files/form are declared as requestBody. In fact, we don't even need to do the mapping at all. This way, in _prepare_doc, we'd have access to the string entered by the user before any mapping is done, and we'd do the right thing. To maintain the OAS version abstraction, we should do the mapping in _prepare_doc. Then later on in _prepare_doc (at this stage, the doc has not been passed to apispec yet), we check for body and change that into requestBody if using OAS3 (so apispec never sees that body string and we could use any arbitrary string). In arguments, we use the mapping from apispec to change parameters location. However, what we do in flask-rest-api is a bit wrong. When using OAS3, files and form should be sent as requestBody, not parameters, so the mapping is not used (so files/form mapping is not really wrong in the OAS3 case, it is just useless). Thanks for the report and investigation, and sorry for the delay.ĪFAIU, apispec's mapping is correct for OAS2. ![]()
0 Comments
Leave a Reply. |