About the display of Swagger DTO Model parameters
See original GitHub issueCreate 3 APIs as follows:
- MyEndpoint : Endpoint<MyRequest, MyResponse>,Get(“/my/query”);
The get request DTO model displays as expected on the swagger page.
- UserEndpoint : Endpoint<UserRequest<UserReqDto>, UserResponse<UserInfo>>,Get(“/user/query”);
The generic DTO model requested by get does not display as expected on the swagger page.
- YourEndpoint : Endpoint<YourRequest<YourReqDto>, YourResponse<YourInfo>>,Post(“/your/create”);
The general DTO model for POST requests is displayed as expected on the swagger page.
Strangely, none of the above DTO models display XML document annotation information. Is there any configuration error?
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
DTO model attributes all have XML document annotations. How to display them in the swagger?
For more information, please refer to demo: MyWebApp
Demo => Solution1.zip
ts!
Issue Analytics
- State:
- Created 5 months ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to annotate DTO so that it shows up in SwaggerUI ...
I have a controller with a @RequestBody DTO. I need to show the DTO's schema instead of the default string in the RequestBody...
Read more >Data Models (Schemas)
The data types are described using a Schema object. To learn how to model various data types, see the following topics: Data Types...
Read more >Some DTO won't show in the Swagger Schema · Issue #954
Current behavior. I am using NestJS Swagger module to list api end points. Some DTO won't show in the Swagger Schema. Input Code....
Read more >Setting Example and Description with Swagger
First, we'll learn how to add a description to different parts of the APIs, like methods, parameters, and error codes. Then we'll see...
Read more >Swagger PUT/POST body value issue
Removing ParameterType=body allows the Post function to read the values correctly, but breaks all of the DTO parameter handling in Swagger.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
also it’s not recommended that you do GET requests with complex dto models. if the request data is complex, always put them in the body as json and make it a POST request, even if it’s a data retrieval operation. query params with complex objects is a bad practice imho. even though swagger/fetch client doesn’t support GET requests with a json body, the http spec doesn’t disallow it.
if you really must set examples/default values for complex/generic request dtos, you may be able to achieve that with a custom operation processor for nswag.
Feedback has been provided, please check here:https://github.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI/issues/52