Check/verify functionality for CLI #1615
Labels
enhancement
New feature or request
good first issue
Straightforward problem, solvable for first-time contributors without deep knowledge of the project
openapi-ts
Relevant to the openapi-typescript library
PRs welcome
PRs are welcome to solve this issue!
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 code1
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.
The text was updated successfully, but these errors were encountered: