Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments from XML Docs: not rendered for [FromForm] params #2519

Closed
poddubitskya opened this issue Oct 17, 2022 · 8 comments
Closed

Comments from XML Docs: not rendered for [FromForm] params #2519

poddubitskya opened this issue Oct 17, 2022 · 8 comments

Comments

@poddubitskya
Copy link

poddubitskya commented Oct 17, 2022

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?

#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

@CarterCall1
Copy link

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.

@poddubitskya
Copy link
Author

Good point to mention, thanks @CarterCall1
In the original case swagger json doesn't contain the description as well

@MonkSoul
Copy link

I also have the same problem. Do you have a solution to this problem?

@dang-gun
Copy link

This error occurs even in version 6.5

@marcel-smits
Copy link

marcel-smits commented Sep 9, 2023

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?

@alexminza
Copy link

#2062

@Havunen
Copy link

Havunen commented Mar 5, 2024

I believe this is fixed in DotSwashbuckle, it has XML comment logic rewritten

@martincostello
Copy link
Collaborator

Duplicate of #2062

@martincostello martincostello marked this as a duplicate of #2062 May 4, 2024
@martincostello martincostello closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants