|
|
@ -51,14 +51,11 @@ def create_response_field( |
|
|
|
""" |
|
|
|
Create a new response field. Raises if type_ is invalid. |
|
|
|
""" |
|
|
|
class_validators = class_validators or {} |
|
|
|
field_info = field_info or FieldInfo() |
|
|
|
|
|
|
|
response_field = functools.partial( |
|
|
|
ModelField, |
|
|
|
name=name, |
|
|
|
type_=type_, |
|
|
|
class_validators=class_validators, |
|
|
|
class_validators=class_validators or {}, |
|
|
|
default=default, |
|
|
|
required=required, |
|
|
|
model_config=model_config, |
|
|
@ -66,7 +63,8 @@ def create_response_field( |
|
|
|
) |
|
|
|
|
|
|
|
try: |
|
|
|
return response_field(field_info=field_info) |
|
|
|
_info = field_info or FieldInfo() |
|
|
|
return response_field(field_info=_info) |
|
|
|
except RuntimeError: |
|
|
|
raise fastapi.exceptions.FastAPIError( |
|
|
|
f"Invalid args for response field! Hint: check that {type_} is a valid pydantic field type" |
|
|
@ -134,7 +132,7 @@ def generate_operation_id_for_path( |
|
|
|
) |
|
|
|
operation_id = name + path |
|
|
|
operation_id = re.sub("[^0-9a-zA-Z_]", "_", operation_id) |
|
|
|
operation_id = operation_id + "_" + method.lower() |
|
|
|
operation_id = f"{operation_id}_{method.lower()}" |
|
|
|
return operation_id |
|
|
|
|
|
|
|
|
|
|
@ -142,7 +140,7 @@ def generate_unique_id(route: "APIRoute") -> str: |
|
|
|
operation_id = route.name + route.path_format |
|
|
|
operation_id = re.sub("[^0-9a-zA-Z_]", "_", operation_id) |
|
|
|
assert route.methods |
|
|
|
operation_id = operation_id + "_" + list(route.methods)[0].lower() |
|
|
|
operation_id = f"{operation_id}_{list(route.methods)[0].lower()}" |
|
|
|
return operation_id |
|
|
|
|
|
|
|
|
|
|
@ -169,8 +167,7 @@ def get_value_or_default( |
|
|
|
|
|
|
|
Otherwise, the first item (a `DefaultPlaceholder`) will be returned. |
|
|
|
""" |
|
|
|
items = (first_item,) + extra_items |
|
|
|
for item in items: |
|
|
|
for item in (first_item,) + extra_items: |
|
|
|
if not isinstance(item, DefaultPlaceholder): |
|
|
|
return item |
|
|
|
return first_item |
|
|
|