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

Allow partial generation #40

Open
nfroidure opened this issue Dec 11, 2024 · 0 comments
Open

Allow partial generation #40

nfroidure opened this issue Dec 11, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@nfroidure
Copy link
Owner

nfroidure commented Dec 11, 2024

In the context of a framework, generating the whole schema types in a single pass and to a single file is not always suitable.

The best would be to allow to build partial schema based on some rules and a context.

For example, we could generate an API endpoint schema only for a single Whook's handler:
https://github.com/nfroidure/whook/blob/1cc395665c5c69e38d4f36612b16d5fc3dd92e72/packages/whook-example/src/handlers/putEcho.ts#L12-L111

Here we would export a src/handlers/putEcho.d.ts file containing the types for the schemas and the operation.

References to external schema could be imported or generated where they actually live and rebuild only when their contents change (via the watch function).

We will need a service that take the various file path for each generated schema (to compute imports) or the recipe to compute them. Also, the first run will probably need to generate the whole schema

The API interface could be something like:

type TypeGeneratorService = {
  generateSchemas: (names: strings[]) => { path: string, contents: string }[];
  generateOpenAPISchema: (content: string) => { path: string, contents: string }[];
}
@nfroidure nfroidure added the enhancement New feature or request label Dec 11, 2024
@nfroidure nfroidure self-assigned this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant