Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Option for generating schema only #3

Open
ChilloManiac opened this issue Aug 28, 2023 · 4 comments
Open

Feature request: Option for generating schema only #3

ChilloManiac opened this issue Aug 28, 2023 · 4 comments

Comments

@ChilloManiac
Copy link

ChilloManiac commented Aug 28, 2023

Hi

I'm working on an API where we write do api-spec-first development. Currently we are manually creating the schemas using Zod and keeping them aligned. This tool seems promising, but the generated EndpointSchema and ApiClient is unneeded, it would be neat if there was a flag to only generate the schemas.

@astahmer
Copy link
Owner

astahmer commented Aug 28, 2023

got it, I see the point.

that's why there are some comments, so that you can just find their start/end index and remove what's in between
comments like

  • // <EndpointByMethod> and // </EndpointByMethod>
  • // <EndpointByMethod.Shorthands> and // </EndpointByMethod.Shorthands>
  • // <ApiClientTypes> and // </ApiClientTypes>
  • // <ApiClient> and // </ApiClient>

so, for example, if you just want to keep the schemas + endpoint definitions, you can do something like:

const schemasOnlyFile = generated.slice(0, generated.indexOf("// <EndpointByMethod>"))

also, if you just want the schemas with a runtime, without even the endpoints definitions, you should directly use the tool that is used internally: https://github.com/sinclairzx81/typebox-codegen see the live online demo here https://sinclairzx81.github.io/typebox-workbench/

@the-ult
Copy link

the-ult commented Jan 24, 2024

The comments are usefull.
But it would be great if the generated code wouldn't need any altering.

Is it possible to add an option to skip the APIClient and/OR Endpoints?

The difference with typebox-codegen seems like that's only typescript -> runtime..
Instead of OpenAPI -> runtime, like this great library.

@astahmer
Copy link
Owner

feel free to send a PR that adds an option / CLI flag for that

@the-ult
Copy link

the-ult commented Jan 24, 2024

I'll see/hope to make some time in the near future and see if I can contribute.
(bit to busy atm I'm afraid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants