Files
vega-cloud/src/plugins/swagger.ts
T
2025-12-03 14:51:59 +07:00

43 lines
1.1 KiB
TypeScript

import { openapi } from '@elysiajs/openapi'
import { OpenAPIV3 } from 'openapi-types'
import * as z from 'zod'
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: '/docs',
provider: 'scalar',
mapJsonSchema: {
zod: z.toJSONSchema,
},
documentation: {
'info': {
title: 'Vega Cloud API',
version: 'v1.0.0',
},
'tags': [
{ name: 'Auth', description: 'Auth API' },
{ name: 'Device', description: 'Device API' },
],
// --- Grouping di atas tag ---
'x-tagGroups': [
{ name: 'Auth', tags: ['Auth'] },
{ name: 'Device', tags: ['Device'] },
],
'components': {
securitySchemes: {
apiKey: {
type: 'apiKey',
in: 'header',
name: 'X-API-Key',
description: 'API key for authentication',
},
},
},
} as OpenApiDocumentation,
exclude: {
paths: ['/live', '/ready', '/'],
},
})