mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-22 03:00:10 +00:00
Bugfix #311, openapicore works with falcon 3.0.0
This commit is contained in:
parent
0865a4f54f
commit
bcdbf6eadd
2 changed files with 9 additions and 5 deletions
|
@ -11,19 +11,24 @@ from openapi_core.validation.request.datatypes import (
|
||||||
class FalconOpenAPIRequestFactory:
|
class FalconOpenAPIRequestFactory:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, request):
|
def create(cls, request, default_when_empty={}):
|
||||||
"""
|
"""
|
||||||
Create OpenAPIRequest from falcon Request and route params.
|
Create OpenAPIRequest from falcon Request and route params.
|
||||||
"""
|
"""
|
||||||
|
default = default_when_empty
|
||||||
method = request.method.lower()
|
method = request.method.lower()
|
||||||
|
|
||||||
# gets deduced by path finder against spec
|
# gets deduced by path finder against spec
|
||||||
path = {}
|
path = {}
|
||||||
|
|
||||||
# Support falcon-jsonify.
|
# in falcon 3 we must hadle empty media or an exception will be raised
|
||||||
|
if hasattr(request, "get_media"):
|
||||||
|
media = request.get_media(default_when_empty=default)
|
||||||
|
else:
|
||||||
|
media = request.media if request.media else default
|
||||||
|
# # Support falcon-jsonify.
|
||||||
body = (
|
body = (
|
||||||
dumps(request.json) if getattr(request, "json", None)
|
dumps(getattr(request, "json", media))
|
||||||
else dumps(request.media)
|
|
||||||
)
|
)
|
||||||
mimetype = request.options.default_media_type
|
mimetype = request.options.default_media_type
|
||||||
if request.content_type:
|
if request.content_type:
|
||||||
|
|
|
@ -33,7 +33,6 @@ def request_factory(environ_factory, router):
|
||||||
options = RequestOptions()
|
options = RequestOptions()
|
||||||
# return create_req(options=options, **environ)
|
# return create_req(options=options, **environ)
|
||||||
req = Request(environ, options)
|
req = Request(environ, options)
|
||||||
resource, method_map, params, req.uri_template = router.find(path, req)
|
|
||||||
return req
|
return req
|
||||||
return create_request
|
return create_request
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue