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:
parent
61fec839e4
commit
7ddbbbbca4
3 changed files with 27 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
5
server/utils/openapi.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export const openAPISecurity = [{
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
description: 'The site\'s token',
|
||||
}]
|
||||
Loading…
Reference in a new issue