Comments (2)
Hi @tgfjt
Try this:
const ParamsSchema = z.object({
keys: z.union([
z
.string()
.array()
.openapi({
example: ['foo', 'bar']
}),
z.string().openapi({
example: 'foo'
})
])
})
const testRoute = createRoute({
method: 'get',
path: '/test',
request: {
query: ParamsSchema
},
responses: {
200: {
content: {
'application/json': {
schema: ParamsSchema
}
},
description: 'foo'
}
}
})
app.openapi(testRoute, (c) => {
const { keys } = c.req.valid('query') ?? []
return c.jsonT({
keys
})
})
from middleware.
@yusukebe
Understood, thank you so much!
Actually, I've tried not to use z.union
as I heard that anyOf
is not supported by OpenAPITools/openapi-generator.
That's can't be helped. I will try z.union
. 👍
OpenAPITools/openapi-generator#10514
from middleware.
Related Issues (20)
- route not adding base path for OpenAPIHono HOT 2
- No sourcemaps when using Sentry middleware HOT 1
- Can't get Bearer Auth to work on Swagger UI at all HOT 7
- Test Suite in OpenAPI Hono Won't Compile HOT 3
- Clerk middleware 401 errors HOT 6
- General oauth middlewear for custom integrations
- Nested route doesn't work with nested routes using zod-openapi HOT 2
- Sentry: request body not available HOT 5
- @hono/zod-openapi: Global error handler HOT 2
- Context usage not possible HOT 2
- Open api typescript error HOT 3
- Vercel Edge - Zod Openapi HOT 6
- @hono/trpc-server `createContext` isn't working HOT 1
- Firebase Auth returns 500s HOT 2
- improve docs to recommend patterns for error handling HOT 2
- Clerk getAuth inside the app.post
- [trpc] access bindings HOT 1
- Bun TypeScript Transpiler Middleware
- @hono/zod-validator doesn't support nullable values HOT 2
- Type Error when trying to validate 'params' with zValidator - Types of parameters 'c' and 'c' are incompatible HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from middleware.