Let's consider a simple UserDTO
:
public record UserDTO(string Id, string Username);
It means that in Swagger UI, for the POST
request, both Id
and Username
will be asked, but that Id
won't be used. Maybe it's confusing for the client.
On the other hand, for GET
requests, it could be useful.
What is the proper way to avoid this confusion?
Username
string for the POST
parameter (here it's OK but could be messy with 10 properties);POST
and GET
(lots of redundancy);Thanks.
Just create separate DTO for distinct endpoints.
Don't be afraid of creating more types, even if there is some duplication between them. You can always derive common abstractions later.