Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Comments from XML Docs: not rendered for [FromForm] params
Hi!
I've updated Swashbuckle from 5.6.3 to 6.4.0 in my solution via the Swashbuckle.AspNetCore metapackage There are some API method params with [FromForm] attribute
I can't see comments for those methods after the upgrade. Rollback to 5.6.3 w\o changing anything else brings the comments back The latest manual still suggests this should work (https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments)
/// <summary>
/// Summary - OK in both
/// </summary>
/// <param name="id" example="123">This is not rendered in 6.4.0 but OK in 5.6.3</param>
Is there a bug?
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2308 I guess this issue is about the same situation. I've decided to create another one and try to express the problem in a more clear way
https://stackoverflow.com/a/66378019/2498155 Here guys discuss the same IMO
I am also having this issue, except with the <example></example>
tag on models.
In 5.6.3, the examples show correctly. In 6.4.0, some of the examples do not show correctly and some do show correctly.
/// <summary>
/// Summary - OK in both
/// </summary>
/// <example>This is sometimes not rendered in 6.4.0 but OK in 5.6.3</example>
I don't see any correlation in the model fields where the example is not rendered. It is seemingly random which fields generate correctly; however, the example is not rendered for the same fields consistently.
I checked the documentation .xml file (not swagger.json) and I see the example tags are correct <example>[email protected]</example>
.
But in the swagger.json file generated schemas, these tags are not there for every model field.
Good point to mention, thanks @CarterCall1 In the original case swagger json doesn't contain the description as well
I also have the same problem. Do you have a solution to this problem?
This error occurs even in version 6.5
I have tried to get to the bottom of this Behaviour, so i wrote this Test Action:
public void ActionWithSwaggerParameterAndFromFormAttribute([FromForm, SwaggerParameter(description: "param")] string param) { }
And added the Following Test:
[Fact] public void Apply_EnrichesFormParrameters_IfActionDecoratedWithSwaggerParameterAndFromForm() { var parameter = new OpenApiParameter { }; var parameterInfo = typeof(FakeControllerWithSwaggerAnnotations) .GetMethod(nameof(FakeControllerWithSwaggerAnnotations.ActionWithSwaggerParameterAndFromFormAttribute)) .GetParameters()[0]; var swaggerParamAttribute = parameterInfo.GetCustomAttributes<SwaggerParameterAttribute>().FirstOrDefault(); var filterContext = new ParameterFilterContext( apiParameterDescription: null, schemaGenerator: null, schemaRepository: null, parameterInfo: parameterInfo); Subject().Apply(parameter, filterContext); Assert.Equal(parameter.Description, swaggerParamAttribute.Description); }
The Test passes and the OpenApiParameter has the correct Description. It wont be displayed tho using SwaggerUI. Not sure were the Problem lies but maybe someone more Familiar with the Library could take a look?
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2062
I believe this is fixed in DotSwashbuckle, it has XML comment logic rewritten
Duplicate of #2062