RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.76k stars 1.29k forks source link

Generate XML doc <example> in Pocos when they're included in swagger.json #3182

Open drwatson85 opened 3 years ago

drwatson85 commented 3 years ago

Hey,

i'm currently using NSwag to generate a .Net Core 3.1 Client from a swagger.json. The json includes example values, like:

"ID": {
            "type": "integer",
            "description": "ID",
            "format": "int32",
            "example": 12
}

Is there a way to include these examples in the generated classes in the form of a XML doc comment <example>?

RicoSuter commented 3 years ago

Currently this is not supported out-of-the-box, maybe you could overwrite the template and add it manually.. but i think it makes sense to add this by default. As these are on DTO properties, we need to add this in the NJsonSchema project: https://github.com/RicoSuter/NJsonSchema

E.g. here somewhere: https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid#L40