Skip to content

using traversable with typed-openapi #456

@astahmer

Description

@astahmer

hey, I'm not sure how I stumbled upon this repo but it seems awesome and I feel like it would make a lot of sense to use it to generate API clients from an OpenAPI schema

tl;dr: I spent a bit trying to figure out how to proceed with your lib but it looks like there's a skill issue on my part and I'm not sure how to integrate traversable into typed-openapi


I've got a library (typed-openapi) that does the OpenAPI -> API client part but it has a weird/crap codebase despite working pretty well to generate a raw TS client (with just typings, no input/output validation); but it is supposed to somewhat-work with different runtime targets (ark, zod, yup etc) using https://github.com/sinclairzx81/typebox-codegen

but the typebox-codegen/workbench lib hasnt been maintained in a while and I also didnt spend much time on it outside of the basics and also didn't care much about having the runtime validation cause I simply didnt have the use case anymore (I used to, and used to solve that with another previous library I made which generates the same thing using zod schemas and is horribly slow past a certain threshold; approximatively 3 or 5k thousand lines, hence why I wanted to get instant suggestions with a types only api client)

prior to finding typebox-codegen I had in mind to make that feature possible (different generation targets) at some point with an intermediate representation which currently only has a single TS implementation, but when I found it I simply switched to using it directly

and then much later I found your repo and figured it might be time to refactor typed-openapi codebase + use traversable to handle runtime generation and it seems like it matches well the use case


I'd love to use traversable to delegate the toString generation (and delete w/e is similar in my codebase) from a schema that is found in the OpenAPI schemas but I'm not sure how to handle the recursion issues / I'm not sure how to handle $ref (ideally I'd want to output the name of the $ref instead of inlining the nested schema; you can see what I mean on https://typed-openapi-web.vercel.app/)

I have a very messy branch here, you can run tests and see the issues here:

cd packages/typed-openapi       
pnpm test /Users/astahmer/dev/alex/typedapi/packages/typed-openapi/tests/openapi-schema-to-ts.test.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions