Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit 63ca501

Browse files
committed
Version 1.3.1
1 parent f5160b0 commit 63ca501

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

openapi_codec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from openapi_codec.decode import _parse_document
99

1010

11-
__version__ = '1.3.0'
11+
__version__ = '1.3.1'
1212

1313

1414
class OpenAPICodec(BaseCodec):

openapi_codec/encode.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,23 @@ def _get_operation(operation_id, link, tags):
9898
return operation
9999

100100

101-
def _get_schema_type(schema):
102-
if schema is None:
101+
def _get_field_description(field):
102+
if getattr(field, 'description', None) is not None:
103+
# Deprecated
104+
return field.description
105+
106+
if field.schema is None:
107+
return ''
108+
109+
return field.schema.description
110+
111+
112+
def _get_field_type(field):
113+
if getattr(field, 'type', None) is not None:
114+
# Deprecated
115+
return field.type
116+
117+
if field.schema is None:
103118
return 'string'
104119

105120
return {
@@ -109,7 +124,7 @@ def _get_schema_type(schema):
109124
coreschema.Boolean: 'boolean',
110125
coreschema.Array: 'array',
111126
coreschema.Object: 'object',
112-
}.get(schema.__class__, 'string')
127+
}.get(field.schema.__class__, 'string')
113128

114129

115130
def _get_parameters(link, encoding):
@@ -122,8 +137,8 @@ def _get_parameters(link, encoding):
122137

123138
for field in link.fields:
124139
location = get_location(link, field)
125-
field_description = field.schema.description if field.schema else ''
126-
field_type = _get_schema_type(field.schema)
140+
field_description = _get_field_description(field)
141+
field_type = _get_field_type(field)
127142
if location == 'form':
128143
if encoding in ('multipart/form-data', 'application/x-www-form-urlencoded'):
129144
# 'formData' in swagger MUST be one of these media types.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy