-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Cli error message improvements #172
Cli error message improvements #172
Conversation
Generate and Validate exposed exceptions rather than user-friendly messages when an error occurred. In generate, this could happen for numerous reasons, but the most likely is a user typing (or guessing) an invalid generator name. In Validate, an error was exposed if there were any validation errors in a spec. New behavior: * Generate now exposes a typed exception when a generator cannot be loaded by name. This allows consistent messaging for load failures. * Generate now presents guidance on failure (check the spelling and try again). This is purely a usability improvement. * Validate now writes validation errors to stderr and exits with code 1.
config-help now presents same error for invalid generator names as the 'generate' command. Options which are required, and those which require a value, now present a user-friendly hint at the error and exit with code 1 (rather than an uncaught exception).
We don't really have a usability-related label, so I've tagged this Enhancement: General + OpenAPI CLI. |
@jimschubert please feel free to create the "Enhancement: Usability" label 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, too. Thanks ✨
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
.Description of the PR
Errors in Generate/Validate print to stderr/exit 1
Generate and Validate exposed exceptions rather than user-friendly
messages when an error occurred. In generate, this could happen for
numerous reasons, but the most likely is a user typing (or guessing) an
invalid generator name. In Validate, an error was exposed if there were
any validation errors in a spec.
New behavior:
loaded by name. This allows consistent messaging for load failures.
again). This is purely a usability improvement.
Improve err messages: config-help/required opts.
'generate' command.
a user-friendly hint at the error and exit with code 1 (rather than an
uncaught exception).
Examples
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar validate -i ~/temp/specs/petstore-v3.0-invalid.yaml Validating spec (/Users/jim/temp/specs/petstore-v3.0-invalid.yaml) - attribute info is missing [error] Spec is invalid.
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/temp/specs/petstore-v3.0.yaml [error] A generator name (--generator-name / -g) is required.
All of the above examples exit with status 1.
See #167