I am using swashbuckle (version 6.5.0) to generate an open api document (version 3).
I have a POST request that has a [FromBody] parameter. The [FromBody] parameter is an object, that has other objects nested inside of it. I have not found how to have swashbuckle add the description for these objects that are nested within the main request body object. Showing example below for a better explanation.
[HttpPost("{Id}")]
public class Task<ActionResult> PostRequest([SwaggerParameter(Description = "Description for Route Parameter.")][FromRoute] int id, [SwaggerRequestBody(Description = "Description for Body Parameter")][FromBody] RequestBodyClass request)
{
...
}
[SwaggerSchema(Description = "Description for class")]
public class RequestBodyClass
{
[SwaggerSchema(Description = "Name field description")
public string nameField {get; set;}
[SwaggerSchema(Description = "Nested object description")
public OtherClass nestedObjectField {get; set;}
}
The generated swagger doc is below, note that the request body referenced object has the nested object inside of it, but the description is not there for it.
paths:
'/{Id}':
post:
...
requestBody:
Description: Description for Body Parameter
content:
application/json:
schema:
$ref: '#/components/schemas/RequestBodyClass'
...
components:
schemas:
RequestBodyClass:
type: object
properties:
** Task:
--Notice no description in the Task node--
$ref: '#/components/schemas/NestedClass'**
additionalProperties: false
description: Description for class
I would've expected the the Task property inside the RequestBodyClass schema to have the description "Nested object description" so that I can describe that object in the request body. Is this by design?