Skip to content

Check/verify functionality for CLI #1615

Closed
@JohanAlteruna

Description

@JohanAlteruna

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs welcomePRs are welcome to solve this issue!enhancementNew feature or requestgood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions