This is certainly one of those that drives you nuts. As the title indicates all I'm simply trying to do is display comments pulled from an xml file using swagger.
I appear to have taken all steps according to the swagger documentation but to no avail. Hopefully you kind folk can point me in the right direction.
Steps Taken:
Ensured file exists:
Configured SwaggerConfig.cs
I've tried changing the path too: @"bin/....xml"
Nothing seems to work.
**The Error "Could not find file": **
Can anyone point me in the right direction please?
Regards,
Click on the + button on the left of each line of the Swagger spec to add your comment from the Comment Bar. The Comment Bar houses all the comments, both resolved and unresolved, on the API spec, sorted by line. You can access the Comment Bar anytime from the Swagger UI.
An XML comment encountered outside the document type declaration is represented by the Comment value syntax element. It contains the comment text from the XML message. If the value of the element contains the character sequence --> , the sequence is replaced with the text --> .
in .net core 3.0
<GenerateDocumentationFile>true</GenerateDocumentationFile>
in PropertyGroup tag of .csproj file
These are the steps I needed in .Net Core 2.2:
Put this in Startup.cs:
public void ConfigureServices(IServiceCollection services) { ... // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { ... var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); }
Edit your .csproj file and add / change these nodes:
<PropertyGroup> ... <!-- Make sure documentation XML is also included when publishing (not only when testing) see https://github.com/Azure/service-fabric-issues/issues/190 --> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> ... <DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With