54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { openapi } from '@elysiajs/openapi'
|
|
import { OpenAPIV3 } from 'openapi-types'
|
|
import { PORT } from '~/config'
|
|
|
|
interface OpenApiDocWithTagGroups { 'x-tagGroups': { name: string, tags: string[] } }
|
|
type OpenApiDocumentation = Omit<Partial<OpenAPIV3.Document<OpenApiDocWithTagGroups>>, 'x-express-openapi-additional-middleware' | 'x-express-openapi-validation-strict'>
|
|
|
|
export const swaggerPlugin = openapi({
|
|
path: '/swagger',
|
|
provider: 'scalar',
|
|
documentation: {
|
|
'info': {
|
|
title: 'Backend node Skyrain API Documentation',
|
|
version: 'v1.0.0',
|
|
},
|
|
'tags': [
|
|
{ name: 'Authentication', description: 'Authentication API' },
|
|
{ name: 'Users', description: 'User API' },
|
|
],
|
|
'servers': [
|
|
{
|
|
url: 'https://skyrainstudio.com',
|
|
description: 'production domain',
|
|
},
|
|
{
|
|
url: `http://localhost:${PORT}`,
|
|
description: 'localhost',
|
|
},
|
|
{
|
|
url: `https://skyrainstudio.com`,
|
|
description: 'Dev server',
|
|
},
|
|
],
|
|
// --- Grouping di atas tag ---
|
|
'x-tagGroups': [
|
|
{ name: 'Auth & IAM', tags: ['Authentication', 'Users'] },
|
|
],
|
|
'components': {
|
|
securitySchemes: {
|
|
basicAuth: {
|
|
type: 'http',
|
|
scheme: 'basic',
|
|
},
|
|
bearerAuth: {
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
bearerFormat: 'JWT',
|
|
},
|
|
},
|
|
},
|
|
'security': [{ bearerAuth: [] }],
|
|
} as OpenApiDocumentation,
|
|
})
|