question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

About the display of Swagger DTO Model parameters

See original GitHub issue

Create 3 APIs as follows:

  • MyEndpoint : Endpoint<MyRequest, MyResponse>,Get(“/my/query”);

The get request DTO model displays as expected on the swagger page.

image

  • 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.

image

  • YourEndpoint : Endpoint<YourRequest<YourReqDto>, YourResponse<YourInfo>>,Post(“/your/create”);

The general DTO model for POST requests is displayed as expected on the swagger page.

image

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:closed
  • Created 5 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dj-nitehawkcommented, Apr 27, 2023

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.

0reactions
zfchaicommented, Apr 28, 2023

Feedback has been provided, please check here:https://github.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI/issues/52

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found