goehls
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
15 additions and
3 deletions
-
fastapi/dependencies/utils.py
-
fastapi/openapi/utils.py
|
|
@ -713,14 +713,23 @@ def _validate_value_with_model_field( |
|
|
|
return v_, [] |
|
|
|
|
|
|
|
|
|
|
|
def _get_multidict_value( |
|
|
|
def _get_value( |
|
|
|
field: ModelField, values: Mapping[str, Any], alias: Union[str, None] = None |
|
|
|
) -> Any: |
|
|
|
alias = alias or field.alias |
|
|
|
if is_sequence_field(field) and isinstance(values, (ImmutableMultiDict, Headers)): |
|
|
|
value = values.getlist(alias) |
|
|
|
else: |
|
|
|
value = values.get(alias, None) |
|
|
|
return value |
|
|
|
|
|
|
|
|
|
|
|
def _get_multidict_value( |
|
|
|
field: ModelField, values: Mapping[str, Any], alias: Union[str, None] = None |
|
|
|
) -> Any: |
|
|
|
alias = alias or field.alias |
|
|
|
value = _get_value(field, values, alias) |
|
|
|
if value is None and alias is not None: |
|
|
|
value = _get_value(field, values, field.alias) |
|
|
|
if ( |
|
|
|
value is None |
|
|
|
or ( |
|
|
|
|
|
@ -126,8 +126,11 @@ def _get_openapi_operation_parameters( |
|
|
|
field_mapping=field_mapping, |
|
|
|
separate_input_output_schemas=separate_input_output_schemas, |
|
|
|
) |
|
|
|
param_name = param.alias |
|
|
|
if param_type == ParamTypes.header and param_name: |
|
|
|
param_name = param.alias.replace("_", "-") |
|
|
|
parameter = { |
|
|
|
"name": param.alias, |
|
|
|
"name": param_name, |
|
|
|
"in": param_type.value, |
|
|
|
"required": param.required, |
|
|
|
"schema": param_schema, |
|
|
|