Reputation: 672
Swashbuckle is not picking up the description while generating Swagger Json for properties with class types. It works fine with primitive data types.
for ex in below code, both of the definitions show up in xml file but only field with type string
shows up with description in SwaggerJson. Field with type ServiceData
is missing Description. This behavior is consistent all across the project:
{
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
/// <summary>
/// Service Creation Request.
/// </summary>
public class ServiceCreationRequest
{
public ServiceCreationRequest(Servicedata serviceData, string name)
{
this.ServiceData = serviceData;
this.Name = name;
}
/// <summary>
/// Gets Service Data.
/// </summary>
public ServiceData ServiceData { get; set; }
/// <summary>
/// User Defined Service Name
/// </summary>
public string ServiceName{ get; set;}
}
}
snippet from xml file:
<member name="P:Service.ServiceCreationRequest.ServiceData ">
<summary>
Gets Service Data.
</summary>
</member>
<member name="P:Service.ServiceCreationRequest.Name">
<summary>
User Defined Service Name
</summary>
</member>
swagger json snippet:
"ServiceCreationRequest": {
"type": "object",
"properties": {
"serviceData": {
"$ref": "#/components/schemas/"
},
"name": {
"type": "string",
"description": "User Defined Service Name.",
"nullable": true,
"readOnly": true
},
"additionalProperties": false,
"description": "Service Creation Request."
}
Notice description
missing for serviceData
Upvotes: 3
Views: 292