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:
|
||||
|
||||
@classmethod
|
||||
def create(cls, request):
|
||||
def create(cls, request, default_when_empty={}):
|
||||
"""
|
||||
Create OpenAPIRequest from falcon Request and route params.
|
||||
"""
|
||||
default = default_when_empty
|
||||
method = request.method.lower()
|
||||
|
||||
# gets deduced by path finder against spec
|
||||
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 = (
|
||||
dumps(request.json) if getattr(request, "json", None)
|
||||
else dumps(request.media)
|
||||
dumps(getattr(request, "json", media))
|
||||
)
|
||||
mimetype = request.options.default_media_type
|
||||
if request.content_type:
|
||||
|
|
|
@ -33,7 +33,6 @@ def request_factory(environ_factory, router):
|
|||
options = RequestOptions()
|
||||
# return create_req(options=options, **environ)
|
||||
req = Request(environ, options)
|
||||
resource, method_map, params, req.uri_template = router.find(path, req)
|
||||
return req
|
||||
return create_request
|
||||
|
||||
|
|
Loading…
Reference in a new issue