title: Is it correct to share two different DTOs to represent the same object differently for different microservices using Client Modules (Libraries)?
body: <p>Currently I am trying to authenticate an User in my system that resides in the user-service and I have two other microservices, authentication-service (is basically my gateway used for authentication) and delivery-service (used to just create a delivery for an user). Both of these services expect to receive an UserDTO which is represents an User entity differently.</p>
  <p>UserDTO for authentication-service:</p>
  <pre><code>public class UserDTO {
      private String email;
      private String password;
  
      // constructor, getters, setters
  }
  </code></pre>
  <p>UserDTO for delivery-service:</p>
  <pre><code>public class UserDTO {
      private String firstName;
      private String lastName;
      private String homeAddress;
      private String contactNumber;
  
      // constructor, getters, setters
  }
  </code></pre>
  <p>According to <a href="https://www.baeldung.com/java-microservices-share-dto" rel="nofollow noreferrer">https://www.baeldung.com/java-microservices-share-dto</a> I find it a good idea to use Client Modules to share these so I created the following modules for my user-service:</p>
  <pre><code>user-service
  |__ user-client
  |__ user-server
  </code></pre>
  <pre><code>user-service
  └──user-client
       UserClient.java
       UserClientImpl.java
       UserAuthenticationResponseDTO.java --- This contains the email and password fields requiered by authentication-service
       UserOrderResponseDTO.java --- This contains the fields required by the order-service
  </code></pre>
  <p>My question is, do you think this is a good solution to my issue ? I think this will also solve the issue when I will start making requests as well because for example to make a request to the delivery-service the homeAddress field should be required but I don't want to have a required homeAddress field when I make a request to my authentication-service</p>