mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-22 03:00:10 +00:00
requests request typing fix
This commit is contained in:
parent
f316b81ba3
commit
ff4a6c81ee
1 changed files with 8 additions and 7 deletions
|
@ -1,8 +1,8 @@
|
||||||
"""OpenAPI core contrib requests requests module"""
|
"""OpenAPI core contrib requests requests module"""
|
||||||
from typing import Union
|
from __future__ import absolute_import
|
||||||
from werkzeug.datastructures import ImmutableMultiDict
|
from werkzeug.datastructures import ImmutableMultiDict
|
||||||
from requests import Request, PreparedRequest
|
from requests import Request
|
||||||
from urllib.parse import urlparse, parse_qs
|
from six.moves.urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
from openapi_core.validation.request.datatypes import (
|
from openapi_core.validation.request.datatypes import (
|
||||||
RequestParameters, OpenAPIRequest,
|
RequestParameters, OpenAPIRequest,
|
||||||
|
@ -12,7 +12,7 @@ from openapi_core.validation.request.datatypes import (
|
||||||
class RequestsOpenAPIRequestFactory(object):
|
class RequestsOpenAPIRequestFactory(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, request: Union[Request, PreparedRequest]) -> OpenAPIRequest:
|
def create(cls, request):
|
||||||
"""
|
"""
|
||||||
Converts a requests request to an OpenAPI one
|
Converts a requests request to an OpenAPI one
|
||||||
|
|
||||||
|
@ -40,12 +40,13 @@ class RequestsOpenAPIRequestFactory(object):
|
||||||
# gets deduced by path finder against spec
|
# gets deduced by path finder against spec
|
||||||
path = {}
|
path = {}
|
||||||
|
|
||||||
# Order matters because all python requests issued from a session include
|
# Order matters because all python requests issued from a session
|
||||||
# Accept */* which does not necessarily match the content type
|
# include Accept */* which does not necessarily match the content type
|
||||||
mimetype = request.headers.get('Content-Type') or \
|
mimetype = request.headers.get('Content-Type') or \
|
||||||
request.headers.get('Accept')
|
request.headers.get('Accept')
|
||||||
|
|
||||||
# Headers - request.headers is not an instance of dict, which is expected
|
# Headers - request.headers is not an instance of dict
|
||||||
|
# which is expected
|
||||||
header = dict(request.headers)
|
header = dict(request.headers)
|
||||||
|
|
||||||
# Body
|
# Body
|
||||||
|
|
Loading…
Reference in a new issue