Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add support for any type, i.e. when 'type' attribute is not specified…
… in OAS schema
  • Loading branch information
sebastien-rosset committed Apr 15, 2020
commit 4e1dba5012df6ebf70c1f7f87c10569e764089b3
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ COERCION_INDEX_BY_TYPE = {
date: 10,
str: 11,
file_type: 12,
object: 13, # Any type, i.e. 'type' is not specified in the OAS schema.
}

# these are used to limit what type conversions we try to do
Expand Down Expand Up @@ -373,7 +374,9 @@ def order_response_types(required_types):
elif (inspect.isclass(class_or_instance)
and issubclass(class_or_instance, ModelSimple)):
return COERCION_INDEX_BY_TYPE[ModelSimple]
return COERCION_INDEX_BY_TYPE[class_or_instance]
if class_or_instance in COERCION_INDEX_BY_TYPE:
return COERCION_INDEX_BY_TYPE[class_or_instance]
raise ApiValueError("Unsupported type: %s" % class_or_instance)

sorted_types = sorted(
required_types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def __eq__(self, other):
date: 10,
str: 11,
file_type: 12,
object: 13, # Any type, i.e. 'type' is not specified in the OAS schema.
}

# these are used to limit what type conversions we try to do
Expand Down Expand Up @@ -629,7 +630,9 @@ def index_getter(class_or_instance):
elif (inspect.isclass(class_or_instance)
and issubclass(class_or_instance, ModelSimple)):
return COERCION_INDEX_BY_TYPE[ModelSimple]
return COERCION_INDEX_BY_TYPE[class_or_instance]
if class_or_instance in COERCION_INDEX_BY_TYPE:
return COERCION_INDEX_BY_TYPE[class_or_instance]
raise ApiValueError("Unsupported type: %s" % class_or_instance)

sorted_types = sorted(
required_types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def __eq__(self, other):
date: 10,
str: 11,
file_type: 12,
object: 13, # Any type, i.e. 'type' is not specified in the OAS schema.
}

# these are used to limit what type conversions we try to do
Expand Down Expand Up @@ -629,7 +630,9 @@ def index_getter(class_or_instance):
elif (inspect.isclass(class_or_instance)
and issubclass(class_or_instance, ModelSimple)):
return COERCION_INDEX_BY_TYPE[ModelSimple]
return COERCION_INDEX_BY_TYPE[class_or_instance]
if class_or_instance in COERCION_INDEX_BY_TYPE:
return COERCION_INDEX_BY_TYPE[class_or_instance]
raise ApiValueError("Unsupported type: %s" % class_or_instance)

sorted_types = sorted(
required_types,
Expand Down