title: How to implement media-type-versioning in NestJs?
body: <p>When using <a href="https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design#media-type-versioning" rel="nofollow noreferrer">media-type-versioning</a>, different versions of an endpoint should have the same URL and the client can set the <code>Accept</code> header to the desired version: e.g.</p>
  <pre><code>Accept: application/vnd.adventure-works.v1+json
  </code></pre>
  <p>For version 2:</p>
  <pre><code>Accept: application/vnd.adventure-works.v2+json
  </code></pre>
  <p>Pseudo code for controller:</p>
  <pre class="lang-js prettyprint-override"><code>
      @Controller('orders')
      export class OrdersController {
      
        @Get('orders/:id')
        getOrdersV1(@Headers('Accept') acceptHeader: string) {
          // accept header must be 'application/vnd.adventure-works.v1+json'
          return {
            orderId: 1,
            orderName: 'Order 1'
          };
        }
      
        @Get('orders/:id')
        getOrdersV2(@Headers('Accept') acceptHeader: string) {
          // accept header must be 'application/vnd.adventure-works.v2+json'
          return {
            orderId: 1,
            name: 'Order 1'
          };
        }
  </code></pre>
  <ul>
  <li>How can we implement this in NestJs?<br />
  i.e. I need to somehow tell the NestJs router that the endpoint corresponding function should only be called when the accept-header has a fixed value:</li>
  <li>will this work with nestjs-swagger?</li>
  </ul>
  <h1>Update</h1>
  <p>found a related feature request: <a href="https://github.com/OpenAPITools/openapi-generator/issues/3569" rel="nofollow noreferrer">#3569</a></p>