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

Create types for the OpenAPI specification based on the swagger.json #5307

Closed
lukasholzer opened this issue Oct 2, 2023 · 2 comments · May be fixed by #5308
Closed

Create types for the OpenAPI specification based on the swagger.json #5307

lukasholzer opened this issue Oct 2, 2023 · 2 comments · May be fixed by #5308
Assignees
Labels

Comments

@lukasholzer
Copy link
Contributor

Currently, our OpenAPI client is used everywhere. It's "the way™️" to access our API in all of our JavaScript Node.js projects. Like build, CLI, etc...

Sadly the client we expose don't have any types as it's a JavaScript class that generates the functions on the fly based on the @netlify/open-api package which is the swagger.json we are generating.

Thorough that we don't have any type safety when working with this package.

As a lot of types in the CLI and the build are based on the return types of the API methods we end up not having a proper type safety throughout the whole codebase which puts of in a brittle position when working with any all the time. To fix our upstream types in the CLI or the build it is required to get proper types from the API return methods.

Proposal

To fix our types we should autogenerate the functions on build time before releasing the package. This means we should generate all the JS methods as static functions in code as generating them on the fly in a constructor call. This is not only speeding up the API access (as we don't have to generate all the functions during runtime), furthermore, it helps us troubleshoot issues as we have an actual code generated we can inspect. When generating the code we can generate typescript with proper types by leveraging the typescript AST.

This should ultimately help us work with our API by having types available and should enable customers the same if they want to use the API inside build plugins where currently no documentation is available.

Copy link
Contributor

github-actions bot commented Oct 2, 2024

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale label Oct 2, 2024
Copy link
Contributor

This issue was closed because it had no activity for over 1 year.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant