Closed warappa closed 1 month ago
I am working on it. It's a fix over the PRs: #2979, #2972 and #2963. The problem that the previous version had is that if there is no schema it has to create the properties and so on. The AllOf is OK (Because the implementation of Microsoft.AspNetCore.OpenApi does just the same (if there is more than one element then it creates an AllOf node.
This is how it's going to get rendered:
"post": {
"operationId": "Upload",
"parameters": [
{
"name": "tool",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "scenario",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "fileName",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"allOf": [
{
"type": "object",
"properties": {
"tags": {
"type": "string"
}
}
},
{
"required": [
"file"
],
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
}
]
},
"encoding": {
"tags": {
"style": "form"
},
"file": {
"style": "form"
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
Describe the bug
I have a Minimal API. In previous versions of this library I had to patch the generated schema to have
tags
in the schema next tofile
(-> properties of schema object).I heard, in the newer versions of this library
[FromForm]
is better supported, so I tried that. Unfortunately, one of my endpoints relying on[FromForm]
yields a schema that is incorrect.I have a Minimal API with the following action:
Expected behavior
It should generate:
Actual behavior
It generates:
This schema would mean, that the body is a mix of a string (
tags
) and something with a propertyfile
that is a binary file (⚠ note theallOf
). That is incorrect.Steps to reproduce
swagger.json
and inspect generated OpenAPI schemaException(s) (if any)
No response
Swashbuckle.AspNetCore version
6.8.1
.NET Version
net8.0
Anything else?
No response