Home:ALL Converter>Custom generation of Model documentation using Swashbuckle

Custom generation of Model documentation using Swashbuckle

Ask Time:2018-08-07T22:16:49         Author:Samuel Barr

Json Formatter

I am using Swashbuckle to generate swagger documentation for an ASP.NET core API I am writing. In my API, I am using a lot of custom Json converters, so the json I am receiving and returning doesn't look exactly like how the C# class is defined. For example, I may have a class like this:

public class MyModel
{
    private MyClass complicatedField;
}

which will be serialized as

{
    "complicatedField": "String representation of the object"
}

However, Swashbuckle documents it as

{
    "complicatedField": {/*Json object of all the fields MyClass has*/}
}

How do I tell Swashbuckle how my models get serialized and deserialized?

Author:Samuel Barr,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51728999/custom-generation-of-model-documentation-using-swashbuckle
yy