title: Nestjs/swagger: how to document the JWT payload?
body: <p>I have a controller's <code>login()</code> method that can return either <code>200 OK</code> with JWT token fitted with <code>Session</code> payload or <code>451 Unavailable due to legal reasons</code> with JWT token fitted with AcceptTerms payload if user trying to log in needs to agree to new version of terms&amp;conditions.</p>
  
  <pre class="lang-ts prettyprint-override"><code>@Nest.Post("login")
  @ApiOperation({ title: 'Log in the user given email and password',  operationId: 'userLogin'})
  @Nest.UseFilters(UnavailableLegalReasonsExceptionFilter)
  @ApiResponse({ status: HttpStatus.OK, description: "User was properly logged in", type: JwtToken})
  @ApiResponse({ status: 451, description: "User haven't confirmed the latest version of Terms &amp; Conditions", type: JwtToken})
  async login(@Nest.Body() body: DTOs.LoginDto): Promise&lt;JwtToken&gt; {
      ...
  }
  </code></pre>
  
  <p>Now, I'd like to document it with Swagger. <code>JwtToken</code> is defined as:</p>
  
  <pre class="lang-ts prettyprint-override"><code>export class JwtToken {
      @ApiModelProperty({enum: TOKEN})
      type: TOKEN;
  
      @ApiModelProperty({description: "Number of seconds"})
      expiresIn: number;
  
      @ApiModelProperty({ description: "Token", example: "eyJhb ... wWFQ"})
      accessToken: string;
  }
  </code></pre>
  
  <p>and <code>TOKEN</code>:</p>
  
  <pre class="lang-ts prettyprint-override"><code>export enum TOKEN {
      AcceptTerms = "AcceptTerms",
      Session = "Session"
  }
  </code></pre>
  
  <p>But writing that <code>login()</code> returns just a <code>JwtToken</code> is confusing as in case of <code>200</code> the <code>type</code> is <code>Session</code> and in case of <code>451</code> it is <code>AcceptTerms</code>. The payloads differ significantly too: </p>
  
  <pre class="lang-ts prettyprint-override"><code>export class JwtPayload {
    @ApiModelProperty({enum: TOKEN, description: "Token type"})
    type: TOKEN;
  
    @ApiModelProperty()
    issuedAt: number;
  }
  
  export class LoginJwtPayload extends JwtPayload {
    @ApiModelProperty()
    name: string;
  
    @ApiModelProperty({description: "T&amp;C version accepted"})
    tncAccepted: number;
  }
  
  export class AcceptTermsJwtPayload extends JwtPayload {
    @ApiModelProperty({format: "email"})
    email: string;
  }
  </code></pre>
  
  <p><code>200</code>'s token uses <code>LoginJwtPayload</code> payload and <code>451</code>'s uses <code>AcceptTermsJwtPayload</code>.</p>
  
  <p>How to document it using Nest's SwaggerModule?</p>