Generate a zodios (typescript http client with zod validation) from an OpenAPI spec (json/yaml)
Generate a zodios (typescript http client with zod validation) from an OpenAPI spec (json/yaml)
Generates a zodios (typescript http client with zod validation) from a (json/yaml) OpenAPI spec (or just use the generated schemas/endpoints/etc !)
can be used programmatically (do w/e you want with the computed schemas/endpoints)
or used as a CLI (generates a prettier .ts file with deduplicated variables when pointing to the same schema/$ref)
client typesafety and runtime validation using zodios
tested (using vitest) against official OpenAPI specs samples
Sometimes you don't have control on your API, maybe you need to consume APIs from other teams (who might each use a different language/framework), you only have their Open API spec as source of truth, then this might help
You could use openapi-zod-client to automate the API integration part (doesn't matter if you consume it in your front or back-end, zodios is agnostic) on your CI and just import the generated api client
If you do have control on your API/back-end, you should probably use a RPC-like solution like tRPC, zodios or ts-rest instead of this.
openapi-zod-client is a CLI that generates a zodios API client (typescript http client with zod validation), currently using axios as http clienttyped-openapi is a CLI/library that generates a headless (bring your own fetcher : fetch, axios, ky, etc...) Typescript API client from an OpenAPI spec, that can output schemas as either just TS types (providing instant suggestions in your IDE) or different runtime validation schemas (zod, typebox, arktype, valibot, io-ts, yup)with local install:
pnpm i -D openapi-zod-clientpnpm openapi-zod-client "./input/file.json" -o "./output/client.ts"or directly (no install)
pnpx openapi-zod-client "./input/file.yaml" -o "./output/client.ts"https://paka.dev/npm/openapi-zod-client
…bash
pnpm install pnpm test
Assuming no issue were raised by the tests, you may use `pnpm dev` to watch for code changes during development.
If you fix an edge case please make a dedicated minimal reproduction test in the [`tests`](./tests) folder so that it doesn't break in future versions
Make sure to generate a [changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) before submitting your PR.No open issues yet, or sync has not completed.