Skip to content

Commit

Permalink
Fix issue with FromForm enums (#3164)
Browse files Browse the repository at this point in the history
Fix issue with .NET 7+.
  • Loading branch information
jgarciadelanoceda authored Nov 22, 2024
1 parent 340eef3 commit e727e8d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 52 deletions.
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

0 comments on commit e727e8d

Please sign in to comment.