Skip to content

Commit

Permalink
docs: replace jsonT with json (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
sor4chi committed Dec 28, 2023
1 parent 616afbc commit 009cc77
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/zod-openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const app = new OpenAPIHono()

app.openapi(route, (c) => {
const { id } = c.req.valid('param')
return c.jsonT({
return c.json({
id,
age: 20,
name: 'Ultra-man',
Expand Down Expand Up @@ -157,7 +157,7 @@ app.openapi(
route,
(c) => {
const { id } = c.req.valid('param')
return c.jsonT({
return c.json({
id,
age: 20,
name: 'Ultra-man',
Expand All @@ -166,7 +166,7 @@ app.openapi(
// Hook
(result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
code: 400,
message: 'Validation Error',
Expand All @@ -186,7 +186,7 @@ In the case that you have a common error formatter, you can initialize the `Open
const app = new OpenAPIHono({
defaultHook: (result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
ok: false,
errors: formatZodErrors(result),
Expand All @@ -205,19 +205,19 @@ You can still override the `defaultHook` by providing the hook at the call site
// uses the defaultHook
app.openapi(createPostRoute, (c) => {
const { title } = c.req.valid('json')
return c.jsonT({ title })
return c.json({ title })
})

// override the defaultHook by passing in a hook
app.openapi(
createBookRoute,
(c) => {
const { title } = c.req.valid('json')
return c.jsonT({ title })
return c.json({ title })
},
(result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
ok: false,
source: 'routeHook' as const,
Expand Down Expand Up @@ -279,7 +279,7 @@ import { hc } from 'hono/client'

const appRoutes = app.openapi(route, (c) => {
const data = c.req.valid('json')
return c.jsonT({
return c.json({
id: data.id,
message: 'Success',
})
Expand Down

0 comments on commit 009cc77

Please sign in to comment.