Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Next.js Swagger Plugin Route Problem Was Solved #159

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,32 @@ import type { ElysiaSwaggerConfig } from './types'
*
* @see https://github.com/elysiajs/elysia-swagger
*/
export const swagger = async <Path extends string = '/swagger'>(
{
export const swagger = async <Path extends string = '/swagger'>({
slug = "/", //api/
provider = 'scalar',
scalarVersion = 'latest',
scalarCDN = '',
scalarConfig = {},
documentation = {},
version = '5.9.0',
excludeStaticFile = true,
path = '/swagger' as Path,
path = 'swagger' as Path,
exclude = [],
swaggerOptions = {},
theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`,
autoDarkMode = true,
excludeMethods = ['OPTIONS'],
excludeTags = []
}: ElysiaSwaggerConfig<Path> = {
slug: "/", // api/ -> Forexample
provider: 'scalar',
scalarVersion: 'latest',
scalarCDN: '',
scalarConfig: {},
documentation: {},
version: '5.9.0',
excludeStaticFile: true,
path: '/swagger' as Path,
path: 'swagger' as Path,
exclude: [],
swaggerOptions: {},
autoDarkMode: true,
Expand All @@ -59,8 +60,7 @@ export const swagger = async <Path extends string = '/swagger'>(
version: '0.0.0',
...documentation.info
}

const relativePath = path.startsWith('/') ? path.slice(1) : path
const relativePath = (slug + path).startsWith('/') ? path.slice(1) : path

const app = new Elysia({ name: '@elysiajs/swagger' })

Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {
* @see https://github.com/swagger-api/swagger-ui
*/
provider?: 'scalar' | 'swagger-ui'
/**
* Base route for framework integrations
*
* @default '/'
* @see https://github.com/scalar/scalar
* @see https://github.com/swagger-api/swagger-ui
*/
slug?: string
/**
* Version to use for Scalar cdn bundle
*
Expand Down
Loading