C
C#2y ago
riazuezra

❔ POST request in swagger shows entire schema and parts of it are not needed in request body

I have a one to one relationship between Product and CartItem, in the POST request for Product the CartItem also shows but it's only there for the ef core relationship and not req body.
7 Replies
Angius
Angius2y ago
That's why you only ever return DTOs from the API, not database models
riazuezra
riazuezra2y ago
ok but in the controller how do I copy from DTO to model is there a special syntax for that? Thanks
Angius
Angius2y ago
Just do it manually, use an automapper, or create some helper methods for mapping
riazuezra
riazuezra2y ago
Ok thanks
Callum
Callum2y ago
Stack Overflow
Specify example requests for swagger's "Try it out"
Is there a way to specify example requests for swagger? Maybe even multiple ones? The Try it out button shows only generic values like: { "firstName": "string", "lastName": "string" } f...
Callum
Callum2y ago
you could also do this where it let's you specify example request bodies if that helps? As someone who writes OData APIs I also sympathise with this struggle...
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts