title: Same/different DTO object in create, update and get rest end points?
body: <p>Consider following UserDTO class and UserController exposing endpoints to create, update and get User.</p>
  
  <p>Having the id property in the UserDTO class does not make sense for create and update. If I use swagger or another auto generated API documentation then it shows that the id can be passed in create end point. But the system does not use it as ids are generated internally.</p>
  
  <p>If I look at get then probably I can get rid of the id property but it is certainly required in a list user end point.</p>
  
  <p>I was thinking of returning internal User domain object in get/list end points. This way I can then get rid of id property form UserDTO class.</p>
  
  <p>Is there any better option I can employ for this?</p>
  
  <pre><code>public class UserDTO {
      private int id;
      private String name;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  
  @RestController
  @RequestMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
  public class UserController {
      @RequestMapping(method = RequestMethod.POST)
      @ResponseBody
      public ResponseEntity&lt;Void&gt; create(@RequestBody UserDTO user) {
      }
  
      @RequestMapping(value = "{id}", method = RequestMethod.GET)
      @ResponseBody
      public ResponseEntity&lt;UserDTO&gt; get(@PathVariable("id") int id) {
      }
  
      @RequestMapping(value = "{id}", method = RequestMethod.PUT)
      @ResponseBody
      public ResponseEntity&lt;Void&gt; update(@PathVariable("id") int id, @RequestBody UserDTO user) {
      }
  }
  </code></pre>
  
  <p>This question may have been asked but I could not find. So excuse me for duplicate question.</p>