e2e type safety with case transformations
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
looking at e.g., hono/elysia/oRPC/ts-rest, i haven't quite found what i'm looking for yet:
- a standard REST API implemented with nextjs app router, with kebab-cased routes (e.g.,
- a Swagger/OpenAPI UI automatically generated representing these casings
- a universal client with idiomatic camelCase identifiers e.g.,
- a standard REST API implemented with nextjs app router, with kebab-cased routes (e.g.,
POST /api/some-path
) and snake_cased request/response payload keys (e.g., { is_foo: true }
)- a Swagger/OpenAPI UI automatically generated representing these casings
- a universal client with idiomatic camelCase identifiers e.g.,
await client.somePath.create({ isFoo: true })
7 Replies
@Transvaal lion looking at e.g., hono/elysia/oRPC/ts-rest, i haven't quite found what i'm looking for yet:
- a standard REST API implemented with nextjs app router, with kebab-cased routes (e.g., `POST /api/some-path`) and snake_cased request/response payload keys (e.g., `{ is_foo: true }`)
- a Swagger/OpenAPI UI automatically generated representing these casings
- a universal client with idiomatic camelCase identifiers e.g., `await client.somePath.create({ isFoo: true })`
Transvaal lionOP
so far, if i get the routes & payloads i want, the clients are not what i want. so for example with elysia, seems like i'd have to do e.g.,
await client['some-path'].create({ is_foo: true })
has anyone found an approach that works well towards these goals?
@Transvaal lion looking at e.g., hono/elysia/oRPC/ts-rest, i haven't quite found what i'm looking for yet:
- a standard REST API implemented with nextjs app router, with kebab-cased routes (e.g., `POST /api/some-path`) and snake_cased request/response payload keys (e.g., `{ is_foo: true }`)
- a Swagger/OpenAPI UI automatically generated representing these casings
- a universal client with idiomatic camelCase identifiers e.g., `await client.somePath.create({ isFoo: true })`
American Sable
- Write API handlers in Next.js App Router using kebab-case folders.
- Use Zod schemas (snake_case) and zod-openapi or ts-rest for OpenAPI generation.
- Serve Swagger UI in /api/docs.
- Generate client with OpenAPI → TS tool, then camelCase transform the client.
- Use Zod schemas (snake_case) and zod-openapi or ts-rest for OpenAPI generation.
- Serve Swagger UI in /api/docs.
- Generate client with OpenAPI → TS tool, then camelCase transform the client.
Transvaal lionOP
👍 thanks, def heading in that direction, just seems a bit laborious so wondering if something handles this OOTB and/or if anyone can point to an example repo that demos this outcome
somewhat surprising that afaict a lot of these tools have docs & examples that demo camelCase routes & payload keys
@Transvaal lion 👍 thanks, def heading in that direction, just seems a bit laborious so wondering if something handles this OOTB and/or if anyone can point to an example repo that demos this outcome
American Sable
I uh think TS-Rest has some examples. To help you get started, let me know if this helps in some way.