docs: replace jsonT with json (#328)

pull/322/head
Sor4chi 2023-12-29 04:25:02 +09:00 committed by GitHub
parent 616afbcd03
commit 009cc77cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -88,7 +88,7 @@ const app = new OpenAPIHono()
app.openapi(route, (c) => { app.openapi(route, (c) => {
const { id } = c.req.valid('param') const { id } = c.req.valid('param')
return c.jsonT({ return c.json({
id, id,
age: 20, age: 20,
name: 'Ultra-man', name: 'Ultra-man',
@ -157,7 +157,7 @@ app.openapi(
route, route,
(c) => { (c) => {
const { id } = c.req.valid('param') const { id } = c.req.valid('param')
return c.jsonT({ return c.json({
id, id,
age: 20, age: 20,
name: 'Ultra-man', name: 'Ultra-man',
@ -166,7 +166,7 @@ app.openapi(
// Hook // Hook
(result, c) => { (result, c) => {
if (!result.success) { if (!result.success) {
return c.jsonT( return c.json(
{ {
code: 400, code: 400,
message: 'Validation Error', message: 'Validation Error',
@ -186,7 +186,7 @@ In the case that you have a common error formatter, you can initialize the `Open
const app = new OpenAPIHono({ const app = new OpenAPIHono({
defaultHook: (result, c) => { defaultHook: (result, c) => {
if (!result.success) { if (!result.success) {
return c.jsonT( return c.json(
{ {
ok: false, ok: false,
errors: formatZodErrors(result), errors: formatZodErrors(result),
@ -205,7 +205,7 @@ You can still override the `defaultHook` by providing the hook at the call site
// uses the defaultHook // uses the defaultHook
app.openapi(createPostRoute, (c) => { app.openapi(createPostRoute, (c) => {
const { title } = c.req.valid('json') const { title } = c.req.valid('json')
return c.jsonT({ title }) return c.json({ title })
}) })
// override the defaultHook by passing in a hook // override the defaultHook by passing in a hook
@ -213,11 +213,11 @@ app.openapi(
createBookRoute, createBookRoute,
(c) => { (c) => {
const { title } = c.req.valid('json') const { title } = c.req.valid('json')
return c.jsonT({ title }) return c.json({ title })
}, },
(result, c) => { (result, c) => {
if (!result.success) { if (!result.success) {
return c.jsonT( return c.json(
{ {
ok: false, ok: false,
source: 'routeHook' as const, source: 'routeHook' as const,
@ -279,7 +279,7 @@ import { hc } from 'hono/client'
const appRoutes = app.openapi(route, (c) => { const appRoutes = app.openapi(route, (c) => {
const data = c.req.valid('json') const data = c.req.valid('json')
return c.jsonT({ return c.json({
id: data.id, id: data.id,
message: 'Success', message: 'Success',
}) })