Hey there! I'm from the Radar team in Cloudflare, and we've just released an internal tool we built during Radar 2.0 development that adds OpenAPI schema generation and validation to the popular itty-router package
This new package is a drop-in replacement for existing applications that already use itty-router
Feel free to give feedback in this thread or in the #radar channel
https://github.com/cloudflare/itty-router-openapi
#itty-router-openapi
22 messages · Page 1 of 1 (latest)
I spent the last two weeks mangling openapi-backend and dependencies in order to get them to work on Workers. This Friday, I got it to work... now this drops. Time for refactor!
Nice!
Fwiw @keen heart, you can use /cfrole, and tap the option that shows up to log in with Access and get the orange role showing you're an employee 🙂
Thanks @spiral juniper didn't know that 😃
Totally biased, but I obviously love this! 🙂
Started using it last night and ❤️
I still need to check this out! 🙂
Hey there, I've published a new release yesterday with some neat features, including:
- Support for raw strings, numbers and bools in response schemas
- Support for nested routers
- Support for disabling or modifying swagger ui, redoc and openapi url paths
etc
Is there an example of a parameter that’s an array? Trying to figure it out
like guests: [ { name: "john" }, { name: "Jane" } ]
parameters: {
page: Query(Int, {
description: 'Page number',
default: 1,
required: false,
}),
guests: ...
},
Hey @near sequoia it is not possible to get object arrays in the parameters field, you will have to move that into the requestBody
but if you really want to have that guests field in the url query, you will have to replace the object array with a string array like this guests: ["John", "Jane"]
and then define the parameter like this screenshot
I didnt read the docs properly or check the data being posted lol, makes 100% sense to have it in the body
thought the params where body params
@keen heart would you mind showing me an example of a array of items within the requestBody
@near sequoia to define an array of items, you just need to wrap the item in [ ]
@keen heart Hi! Is itty-router-openapi supposed to be compatible with itty-router middleware? I get TS type errors when trying to use my middleware with an OpenAPIRoute class instance.
For example:
router.get('/', () => console.log('my middleware'), DeviceList);
Hey @near gulch it should be compatible, let me investigate the issue
So everything works, it's just a TS warning, you can ignore that
I will only be able to fix that in the next major release
please open an issue in the GitHub repository describing your bug
Thanks for reporting it
https://github.com/cloudflare/itty-router-openapi/issues/new
@keen heart Ah yes I noticed everything worked as it should, it's just TS that is complaining. Ok will do. Thanks for checking!
Hi @keen heart I was checking this and was able to successfully built a dummy API but at same time I used hono and that also looks promising and the only difference I can understand (as of now, might be wrong) is that this^ let's you create openapi schema centric code and later you'll have /docs and /redocs but I was wondering what other differences are there?
Hello. Grasping for straws here. Trying to migrate to itty-router-openapi 1.0 but the tests are failing. Every test that reference a module which includes 'itty-router-openapi' fails like this:
Require stack:
/home/daniel/projekt/xxxxxx/node_modules/@cloudflare/itty-router-openapi/node_modules/@asteasolutions/zod-to-openapi/dist/index.js
/home/daniel/projekt/xxxxxx/node_modules/@cloudflare/itty-router-openapi/dist/index.js
src/router/api/v1/device.ts
src/router/api/v1/__tests__/device.spec.ts```
Using ts-jest.