Hello,
Using the Nswag Owin Middleware with OpenApi 3 enabled, the request body for Post operations is missing from Swagger UI.
Is there something I'm missing ?
Thank you.


Isn't it nullable and thus reference via oneOf?
Thanks for the answer.
I used your sample for Owin Middleware and just add this method:
[HttpPost]
public IHttpActionResult CreateProduct([FromBody] Product product)
{
return Ok();
}
I don't know exactly when "oneOf" should be generated in the swagger file...
Can you post the generated spec?
I think its correct but swagger ui does not support null/oneOf in request bodies. Maybe try adding [BindRequired] and [Required] to the parameter
It seems that the "[Required]" attribute is ignored with Web API.
We have another project with ASP.NET Core 2.2, and the requestBody is generated without "oneOf" whether or not the "[Required]" attribute is set (always required):
"requestBody": {
"x-name": "customer",
"description": "Customer definition",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Customer"
}
}
},
"required": true,
"x-position": 1
}
Do you know why it is different with Web API ?
Web API (legacy) is based on another Swagger/OpenAPI generator inside NSwag and is no longer being maintained... the FromBody handling is different in these two generators and might differ.
@KumG This setting below worked for us.
c#
app.UseSwaggerUi3(controllers, settings =>
{
settings.GeneratorSettings.AllowNullableBodyParameters = false;
}
Yes, it seems to work, thank you!!
Most helpful comment
@KumG This setting below worked for us.
c# app.UseSwaggerUi3(controllers, settings => { settings.GeneratorSettings.AllowNullableBodyParameters = false; }