-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Bug]: String in json format as input for [FromForm] is not recognized in UI #3014
Comments
Can you share your OpenAPI document and/or a runnable code sample in the form of a GitHub repo? This could be either an issue with Swashbuckle (the OpenAPI document being incorrectly generated) or SwaggerUI (incorrectly interpreting the OpenAPI document). |
Sounds very similar to #2930, which is an issue in SwaggerUI. |
This is exactly the same issue as in #2930. Do you still need an OpenAPI document from me? |
If it's because of SwaggerUI, then no I don't think so. If there isn't already an issue for this, I suggest opening one over in their repo. We can then ingest the fix when it's available. |
@KillerBoogie, can you test if it's working now? |
I'm sorry, but I don't have the time to test right now due to a few deadlines. What is MyGet? |
It's the NuGet feed containing our prerelease package versions. |
Describe the bug
For an endpoint that accepts a file, the title, and a description in multiple languages I use this method
public async Task<ActionResult<GuidIdResponse>> UploadImage([FromForm] string title, [FromForm] string? description, IFormFile file)
The title is entered in JSON format like:
{de":"Bildschirmfoto","en":"screen shot"}
When I enter the above string in the title field of the generated Swashbuckle UI I'm getting error 400:
The code of my endpoint method is not hit. The error is produced by the framework. When I send the same request with Postman it works fine!
This only happens if the JSON string is well formed and not escaped.
This is sent correctly:
{\"de\":\"Bildschirmfoto\",\"en\":\"screen shot\"}
Those also pass through:
As soon as the JSON is correctly formed, but not escaped the string is not passed and treated as not entered.
Since it works fine with Postman t must be a bug in Swashbuckle.,
Expected behavior
Pass the entered string into the variable.
Actual behavior
A string in valid JSON format is treated as not provided:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"title": [
"The title field is required."
]
},
"traceId": "00-259db306db8ce9b0015192084dfc72f2-cd711e4da768cce5-00"
}
Steps to reproduce
No response
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
6.7.0
.NET Version
8.0.303
Anything else?
The text was updated successfully, but these errors were encountered: