Skip to content

How to handle versioning in path (e.g., "/api/v1/...") #846

Closed Answered by jellydn
joergrech asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @joergrech I think you could use apiFolder option for your need.

import { createSwaggerSpec } from https://github.com/jellydn/next-swagger-doc;

export const getApiV1Docs = async () => {
  const spec = createSwaggerSpec({
    apiFolder: 'api/v1', // define api folder
    definition: {
      openapi: '3.0.0',
      info: {
        title: 'Next Swagger API Example',
        version: '1.0',
      },
      components: {
        securitySchemes: {
          BearerAuth: {
            type: 'http',
            scheme: 'bearer',
            bearerFormat: 'JWT',
          },
        },
      },
      security: [],
    },
  });
  return spec;
};

Let me know if any issue.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@joergrech
Comment options

Answer selected by joergrech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants