работаем бля работаем
This commit is contained in:
@@ -10,7 +10,6 @@ import FastifySwagger from '@fastify/swagger'
|
||||
import FastifyApiReference from '@scalar/fastify-api-reference'
|
||||
import Fastify from 'fastify'
|
||||
import { Prisma } from './prisma/generated-client/client.ts'
|
||||
import { ErrorReplySchema } from './schemas/common.ts'
|
||||
import 'dotenv/config'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
@@ -52,13 +51,30 @@ fastify.register(FastifySwagger, {
|
||||
const transformedSchema: typeof schema = schema ?? {}
|
||||
const responseSchema: any = transformedSchema.response ?? {}
|
||||
|
||||
responseSchema['4xx'] ??= ErrorReplySchema
|
||||
responseSchema['5xx'] ??= ErrorReplySchema
|
||||
responseSchema['4xx'] ??= { $ref: 'ResponseError' }
|
||||
responseSchema['5xx'] ??= { $ref: 'ResponseError' }
|
||||
|
||||
transformedSchema.response = responseSchema
|
||||
|
||||
return { schema: transformedSchema, url }
|
||||
},
|
||||
refResolver: {
|
||||
buildLocalReference(json, _baseUri, _fragment, i) {
|
||||
if (!json.title && json.$id) {
|
||||
json.title = json.$id
|
||||
}
|
||||
|
||||
if (!json.description) {
|
||||
json.description = json.title
|
||||
}
|
||||
|
||||
if (!json.$id) {
|
||||
return `def-${i}`
|
||||
}
|
||||
|
||||
return json.$id.toString()
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
fastify.register(FastifyApiReference, {
|
||||
@@ -68,10 +84,10 @@ fastify.register(FastifyApiReference, {
|
||||
showDeveloperTools: 'never',
|
||||
pageTitle: 'Chad API',
|
||||
customCss: `
|
||||
.scalar-mcp-layer,
|
||||
.agent-button-container,
|
||||
.t-doc__sidebar > div > button:last-child {
|
||||
display: none !important;
|
||||
.scalar-mcp-layer,
|
||||
.agent-button-container,
|
||||
.t-doc__sidebar > div > button:last-child {
|
||||
display: none !important;
|
||||
}
|
||||
`,
|
||||
},
|
||||
@@ -93,6 +109,7 @@ fastify.register(FastifyMultipart)
|
||||
|
||||
fastify.register(FastifyAutoLoad, {
|
||||
dir: join(__dirname, 'plugins'),
|
||||
maxDepth: 1,
|
||||
})
|
||||
|
||||
fastify.register(FastifyAutoLoad, {
|
||||
|
||||
Reference in New Issue
Block a user