-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Why NSwag doesn't generate model from request? #3486
Comments
You should use the generic |
Ok, so it seems you have the same issue here as I already reported in #3301, see the comments why it is that way. Simply put, there is not solution right now and you have to live with simple parameters. I did try to change the NSwag sources to generate a model, I remember it being pretty hard effort but then I got distracted and could never finish the change and provide a proof of concept (if that is even possible). |
Thanks for truly reply) Is it possible to tell Nswag to generate a particular model? |
No as NSwag flattens the class properties (in your case the propertiers of
As I already wrote, I tried to find a solution for it but I could not finish my solution so that it can be merged. |
Thanks a lot for helping me |
Hi There @DragonDara after playing around with the same issue, I found that using So for instance Hope this helps if anyone else runs into this issue, |
Ohh. Thank you a lot for this response.
It has been long time since I posted this issue and it still remains
unresolved in my team.
I will check your resolution mandatory
…On Mon, Mar 13, 2023, 14:57 alpha-nero1 ***@***.***> wrote:
Hi There @DragonDara <https://github.com/DragonDara> after playing around
with the same issue, I found that using [FromBody] instead of [FromQuery]
makes nswag generate the request dto for you instead of the annoying
endless params.
So for instance create(title: string, description: string...) will be
turned into:
create(request: Command)
Hope this helps if anyone else runs into this issue,
Thanks
—
Reply to this email directly, view it on GitHub
<#3486 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIXPDNJVUPJSSO3IGHXPFYLW33VRBANCNFSM45UDRUBA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It really generates DTO-s, but GET-methods on backend has been broken and error is thrown - "A non-empty request body is required". |
This can not be done for Get, it will brake any Dto that you have into params ... sucks... |
Does anyone know the solution? |
Hi, there!
I have REST API on .NET Core 3.1 and we use NSwag to generate client code(typescript).
It works well except for one thing. Nswag doesn't generate a model in the request query.
After generating, I get the following typescript code:
I searched the Internet for answers, but I failed.
Does nswag support such functionality? If yes, what should I use?
Regards,
Darkhan
The text was updated successfully, but these errors were encountered: