Skip to content

Commit

Permalink
Test the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Jun 27, 2024
1 parent 9ea5be0 commit d3a513e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/example-todo-app/pages/api/todo/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const jsonBody = z.object({
---
This is an unused, deprecated field.
`),
description: z.string().nullable(),
})

export const route_spec = checkRouteSpec({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ test("should generate openapi with expected properties", async (t) => {
)
t.deepEqual(typeof openapiJson, "object")
})

test("nullable param is correctly parsed", async (t) => {
const openapiJson = JSON.parse(
await generateOpenAPI({
packageDir: ".",
})
)

const routeSpec = openapiJson.paths["/api/todo/add"].post
const descriptionParam =
routeSpec.requestBody.content["application/json"].schema.properties
.description

t.truthy(descriptionParam)
t.is(descriptionParam.type, "string")
t.true(descriptionParam.nullable)
})

0 comments on commit d3a513e

Please sign in to comment.