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

Add commands for generating and comparing JSON schemas #90

Merged
merged 10 commits into from
Jun 3, 2021

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented May 27, 2021

schema:generate

Uses regex to determine the return types of each command and then uses ts-json-schema-generator to generate JSON schemas for those types.

By default the schemas are split into one file per command and placed under the schemas directory. There's a --singlefile flag to put all of the schemas into a single schemas.json file

~/code/plugin-command-snapshot [mdonnalley/schemas] : bin/run schema:generate --help
USAGE
  $ oclif-example schema:generate

OPTIONS
  --filepath=filepath  [default: ./schemas] directory to save the generated schema files; can use "{version}" to insert the current CLI/plugin version
  --singlefile         put generated schema into a single file

schema:compare

Uses just-diff to find differences between the existing schema and the latest schema. Command exists with code 1 if any differences are found

~/code/plugin-command-snapshot [mdonnalley/schemas] : bin/run schema:compare --help
USAGE
  $ oclif-example schema:compare

OPTIONS
  --filepath=filepath  [default: ./schemas] path of the generated snapshot file

Screen Shot 2021-05-27 at 2 30 54 PM

@mdonnalley mdonnalley self-assigned this May 27, 2021
@mdonnalley mdonnalley requested review from amphro and RodEsp May 28, 2021 19:28
"Schema": {
"$ref": "#/definitions/JSONSchema7"
},
"JSONSchema7": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it useful to have this be the output? What if it was just an array of output files or something like that?

@mdonnalley mdonnalley merged commit 0e31395 into master Jun 3, 2021
@mdonnalley mdonnalley deleted the mdonnalley/schemas branch June 3, 2021 14:20
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 this pull request may close these issues.

2 participants