title: Only expose certain fields when viewing specific item with Spring Data?
body: <p>I'm currently using Spring Boot to create a REST API with a mongodb backend. Is it possible to only expose certain fields when viewing a specific item, and not a list of items?</p>
  
  <p>For example, when viewing a list of users, to only expose email, name, and id:</p>
  
  <p><code>GET /{endpoint}/users</code></p>
  
  <pre><code>{
    "_embedded": {
    "users": [
      {
        "email": "some_email@gmail.com",
        "name": "some name",
        "id": "57420b2a0d31bb6cef4ee8e9"
      }, 
      {
        "email": "some_other_email@gmail.com",
        "name": "some other name",
        "id": "57420f340d31cd8a1f74a84e"
      }
    ]
  }
  </code></pre>
  
  <p>But expose extra fields, e.g. address and gender, when searching for a specific user: </p>
  
  <p><code>GET /{endpoint}/users/57420f340d31cd8a1f74a84e</code></p>
  
  <pre><code>{
    "email": "some_other_email@gmail.com",
    "name": "some other name",
    "address": "1234 foo street"
    "gender": "female"
    "id": "57420f340d31cd8a1f74a84e"
  }
  </code></pre>
  
  <p>given a user class:</p>
  
  <pre><code>public class User {
  
      private String id;
      private String email;
      private String address;
      private String name;
      private String gender;
  
  ...
  }
  </code></pre>