Skip to content

Commit 19bafc4

Browse files
committed
chore: update major hono-openapi
1 parent 2feee9c commit 19bafc4

6 files changed

Lines changed: 111 additions & 77 deletions

File tree

apps/backend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"srvx": "^0.8.7"
2121
},
2222
"devDependencies": {
23-
"@hono/arktype-validator": "^2.0.1",
23+
"@hono/standard-validator": "^0.1.5",
2424
"@kinde-oss/kinde-typescript-sdk": "^2.13.0",
2525
"@local/common": "workspace:*",
2626
"@local/locales": "workspace:*",
@@ -33,7 +33,7 @@
3333
"convex": "^1.26.2",
3434
"hono": "^4.9.6",
3535
"hono-adapter-aws-lambda": "^1.3.3",
36-
"hono-openapi": "^0.4.8",
36+
"hono-openapi": "^1.0.0",
3737
"hono-sessions": "^0.8.0",
3838
"petite-vue-i18n": "^11.1.12",
3939
"std-env": "^3.9.0",

apps/backend/src/api/dummy/convexTasks.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { appFactory } from '#src/helpers/factory.js'
22
import { getConvexClient } from '#src/providers/baas/convex-main.js'
33
import { type } from 'arktype'
44
import { api } from 'backend-convex/convex/_generated/api'
5-
import { describeRoute } from 'hono-openapi'
6-
import { resolver } from 'hono-openapi/arktype'
5+
import { describeRoute, resolver } from 'hono-openapi'
76

87
export const dummyConvexTasksRouteApp = appFactory.createApp()
98
.get(

apps/backend/src/api/dummy/greet.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { customArktypeValidator } from '#src/helpers/arktype.js'
22
import { appFactory } from '#src/helpers/factory.js'
33
import { i18nComposer } from '#src/helpers/i18n.js'
44
import { type } from 'arktype'
5-
import { describeRoute } from 'hono-openapi'
6-
import { resolver } from 'hono-openapi/arktype'
5+
import { describeRoute, resolver } from 'hono-openapi'
76

87
export const dummyGreetRouteApp = appFactory.createApp()
98
.get(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { DetailedError } from '@namesmt/utils'
2-
import { validator as arktypeValidator } from 'hono-openapi/arktype'
2+
import { validator as arktypeValidator } from 'hono-openapi'
33

44
type arktypeValidatorArguments = Parameters<typeof arktypeValidator>
55
export function customArktypeValidator<Target extends arktypeValidatorArguments[0], Schema extends arktypeValidatorArguments[1]>(target: Target, schema: Schema) {
66
return arktypeValidator(target, schema, (result) => {
77
if (result.success === false)
8-
throw new DetailedError('Validation failed', { statusCode: 400, detail: JSON.stringify(result.errors) })
8+
throw new DetailedError('Validation failed', { statusCode: 400, detail: JSON.stringify(result.error) })
99
})
1010
}

apps/backend/src/openAPI.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import type { Hono } from 'hono'
22
import { Scalar } from '@scalar/hono-api-reference'
3-
import { openAPISpecs } from 'hono-openapi'
3+
import { openAPIRouteHandler } from 'hono-openapi'
44

55
export function setupOpenAPI(app: Hono<any, any>, prefix = '/openapi') {
66
// OpenAPI spec
77
app.get(
8-
`${prefix}/spec`,
9-
openAPISpecs(app, {
8+
`${prefix}/spec.json`,
9+
openAPIRouteHandler(app, {
1010
documentation: {
11-
info: { title: `starter-monorepo's backend`, version: '1.0.0', description: 'My amazing API' },
11+
info: {
12+
title: `starter-monorepo's backend`,
13+
version: '1.0.0',
14+
description: 'My amazing API',
15+
},
1216
},
1317
}),
1418
)
@@ -18,7 +22,7 @@ export function setupOpenAPI(app: Hono<any, any>, prefix = '/openapi') {
1822
`${prefix}/ui`,
1923
Scalar({
2024
theme: 'deepSpace',
21-
url: `${prefix}/spec`,
25+
url: `${prefix}/spec.json`,
2226
}),
2327
)
2428
}

pnpm-lock.yaml

Lines changed: 96 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)