feat: add OpenAPI metadata to endpoints

Enhances API documentation by adding OpenAPI metadata to location and verify endpoints. Includes:

- Security requirements for both endpoints
- Detailed description of endpoint purposes
- Response documentation for verify endpoint with success/error cases
This commit is contained in:
ccbikai 2025-05-21 20:31:12 +08:00
parent 61fec839e4
commit 7ddbbbbca4
3 changed files with 27 additions and 0 deletions

View file

@ -1,3 +1,10 @@
defineRouteMeta({
openAPI: {
description: 'Get the location of the user',
security: openAPISecurity,
},
})
export default eventHandler((event) => {
const { request: { cf } } = event.context.cloudflare
return {

View file

@ -1,3 +1,18 @@
defineRouteMeta({
openAPI: {
description: 'Verify the site token',
security: openAPISecurity,
responses: {
200: {
description: 'The site token is valid',
},
default: {
description: 'The site token is invalid',
},
},
},
})
export default eventHandler(() => {
return {
name: 'Sink',

5
server/utils/openapi.ts Normal file
View file

@ -0,0 +1,5 @@
export const openAPISecurity = [{
type: 'http',
scheme: 'bearer',
description: 'The site\'s token',
}]