Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !172

Cli error message improvements

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jim Schubert requested to merge github/fork/jimschubert/cli-error-message-improvements into master May 29, 2018
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 7

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./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\.
  • Filed the PR against the correct branch: Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

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:

  • 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. Improve err messages: config-help/required opts.
  • 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).

Examples

$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar config-help -g asdf
Can't load config class with name 'asdf'
Available:
ada
…(removed)
typescript-node

[error] Check the spelling of the generator's name and try again.
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/temp/specs/petstore-v3.0.yaml -g php2
Can't load config class with name 'php2'
Available:
ada
…(removed)
typescript-node

[error] Check the spelling of the generator's name and try again.
$ 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.
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/temp/specs/petstore-v3.0.yaml -g
[error] Required values for option 'generator name' not provided

All of the above examples exit with status 1.

See #167 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jimschubert/cli-error-message-improvements