asyncapi / saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.
https://www.asyncapi.com/
MIT License
199 stars 56 forks source link

Allow setting description for attributes/parameters #87

Closed claorden closed 3 years ago

claorden commented 3 years ago

Hi there!

An idea that I think it's not available right now (please correct me if it is). It would be very useful to be able to define the "description" field of the properties of a class via summary or metadata.

Example:

public sealed class MyClass
    {
        /// <summary>
        /// Att1 description.
        /// </summary>
        public double Att1 { get; set; }

        [Saunter.Attributes.ParameterDefinition(Description = "Att2 description.")]
        public double Att2 { get; set; }
    }

Resulting in:

"myClass":{"properties":{
        "Att1":{"type":"number", "description":"Att1 description."},
        "Att2":{"type":"number", "description":"Att2 description."}
}}
m-wild commented 3 years ago

This is currently implemented https://github.com/tehmantra/saunter/blob/76818cccb9a5e512dd691ad0ce5b56566611f0bf/src/Saunter/Utils/Reflection.cs#L227

If it's not working, make sure that the the XML file is being generated at build time

  <PropertyGroup>
    <DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
  </PropertyGroup>