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

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

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

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

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.

@lukasholzer lukasholzer linked a pull request Oct 2, 2023 that will close this issue
5 tasks
@lukasholzer lukasholzer self-assigned this Oct 3, 2023
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

Successfully merging a pull request may close this issue.

1 participant