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

Check/verify functionality for CLI #1615

Open
1 task
JohanAlteruna opened this issue Apr 10, 2024 · 1 comment
Open
1 task

Check/verify functionality for CLI #1615

JohanAlteruna opened this issue Apr 10, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library

Comments

@JohanAlteruna
Copy link

JohanAlteruna commented Apr 10, 2024

Description

Sometimes, for example as part of CI workflows, one might want to check that types generated by this library are up to date rather than actually write them to a file. For example, this could ensure that noone made changes to an OpenAPI specification and forgot to re-generate the types for it. This could for example be done by running the generator and inspecting the git status before and after doing so, however that approach seems clunky. It would be convenient if this library provided an easy way to do this.

Proposal

A similar workflow is supported by some other codegen tools including graphql-codegen and kysely-codegen. Here is a concrete implementation suggestion for this project.

Add a flag called check to the CLI. This could be specified as follows:
"Instead of writing the types to the output destination, compare the output with the file at the destination. Exit with exit code 0 if the destination file exists and its content is equal to the output, and exit code 1 otherwise. If this flag is used, the --output option must also be specified."

Checklist

I guess I could open a PR, but I don't know if I'll be able to work on it and this is intended as a feature request/suggestion.

@JohanAlteruna JohanAlteruna added enhancement New feature or request help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library labels Apr 10, 2024
@drwpow drwpow added the good first issue Good for newcomers label Apr 16, 2024
@drwpow
Copy link
Owner

drwpow commented Apr 16, 2024

That makes sense! I’d be in support of this. The idea of linting schemas is something I’ve had good luck with Redocly with, which is why 7.x has it built-in. But this is something beyond linting, and something only openapi-typescript could do.

Also in 7.x with the improved Node.js API this should be easier to compare 2 outputs as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

No branches or pull requests

2 participants