Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with FromForm and enums for Controllers #3164

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ private OpenApiSchema GenerateSchemaFromFormParameters(
: new OpenApiSchema { Type = "string" };

if (schema.Reference is null
|| (formParameter.Type is not null && (Nullable.GetUnderlyingType(formParameter.Type) ?? formParameter.Type).IsEnum))
|| (formParameter.ModelMetadata?.ModelType is not null && (Nullable.GetUnderlyingType(formParameter.ModelMetadata.ModelType) ?? formParameter.ModelMetadata.ModelType).IsEnum))
{
var name = _options.DescribeAllParametersInCamelCase
? formParameter.Name.ToCamelCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,32 +675,33 @@
content: {
multipart/form-data: {
schema: {
allOf: [
null,
null,
{
type: object,
properties: {
name: {
type: string,
description: Summary for Name,
example: MyName
},
phoneNumbers: {
type: array,
items: {
type: integer,
format: int32
},
description: Sumary for PhoneNumbers
},
formFile: {
type: string,
format: binary
}
}
type: object,
properties: {
name: {
type: string,
description: Summary for Name,
example: MyName
},
phoneNumbers: {
type: array,
items: {
type: integer,
format: int32
},
description: Sumary for PhoneNumbers
},
logLevel: {
$ref: #/components/schemas/LogLevel
},
formFile: {
type: string,
description: Description for file,
format: binary
},
dateTimeKind: {
$ref: #/components/schemas/DateTimeKind
}
]
}
},
encoding: {
name: {
Expand All @@ -709,8 +710,14 @@
phoneNumbers: {
style: form
},
logLevel: {
style: form
},
formFile: {
style: form
},
dateTimeKind: {
style: form
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,36 +684,33 @@
"content": {
"multipart/form-data": {
"schema": {
"allOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Summary for Name",
"example": "MyName"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"description": "Sumary for PhoneNumbers"
},
"logLevel": {
"$ref": "#/components/schemas/LogLevel"
},
{
"$ref": "#/components/schemas/DateTimeKind"
"formFile": {
"type": "string",
"description": "Description for file",
"format": "binary"
},
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Summary for Name",
"example": "MyName"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"description": "Sumary for PhoneNumbers"
},
"formFile": {
"type": "string",
"format": "binary"
}
}
"dateTimeKind": {
"$ref": "#/components/schemas/DateTimeKind"
}
]
}
},
"encoding": {
"name": {
Expand All @@ -722,8 +719,14 @@
"phoneNumbers": {
"style": "form"
},
"logLevel": {
"style": "form"
},
"formFile": {
"style": "form"
},
"dateTimeKind": {
"style": "form"
}
}
}
Expand Down