Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion swagger_py_codegen/templates/sanic/schemas.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

{% include '_do_not_change.tpl' %}
import six
from jsonschema import RefResolver

base_path = '{{base_path}}'

Expand Down Expand Up @@ -58,4 +59,3 @@ security = Security()
{{ merge_default }}

{{ normalize }}

9 changes: 8 additions & 1 deletion swagger_py_codegen/templates/sanic/validators.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class SanicValidatorAdaptor(object):
for k, values in obj.items():
prop = self.validator.schema['properties'].get(k, {})
type_ = prop.get('type')
if type_ is None and '$ref' in prop:
ref = prop.get('$ref')
if not ref:
continue
type_ = self.validator.resolver.resolve(prop.get('$ref'))[1].get('type')
if not type_:
continue
fun = convert_funs.get(type_, lambda v: v[0])
if type_ == 'array':
item_type = prop.get('items', {}).get('type')
Expand Down Expand Up @@ -189,4 +196,4 @@ def response_filter(view):
headers=headers,
)

return wrapper
return wrapper