domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.22k stars 1.31k forks source link

Add Example to Swashbuckle.AspNetCore.Annotations #2115

Open AchoArnold opened 3 years ago

AchoArnold commented 3 years ago

Thanks for contributing to Swashbuckle.AspNetCore! As per the contributing guidelines, please adhere to the following rules of thumb before submitting your issue:

It would be nice to have an annotation for an example property. Perhaps we could add it to [SwaggerSchema]? I know currently you can add the example using XML.

APIWT commented 2 years ago

I agree, this would be super helpful. Especially now that we have record types, so for positional records it isn't super feasible to add XML docs in a minimalistic manner.

collinbarrett commented 2 years ago

To me, an "example" doesn't have exact correlation with a "default value". But, you can use the existing DefaultValueAttribute to kind of achieve this, I think (assuming I am understanding the OP).

See here.