-
-
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
Improve error message when the spec is not found #1495
Conversation
An error message after merging this PR. 📝 $ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g go -i foo.yaml
[error] The spec file is not found: foo.yaml
[error] Check the path of the OpenAPI spec and try again. |
https://circleci.com/gh/OpenAPITools/openapi-generator/3517#tests/containers/2
Probably we need to use https://hub.docker.com/r/openapitools/openapi-petstore/ to resolve the error. It will be done in other PR. |
cc @OpenAPITools/generator-core-team |
@@ -246,6 +247,11 @@ public void run() { | |||
} | |||
|
|||
if (isNotEmpty(spec)) { | |||
if (!spec.matches("^http(s)?://.*") && !new File(spec).exists()) { | |||
System.out.println("[error] The spec file is not found: " + spec); |
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.
Do you mean to write an error message to System.out here? This would be surprising to me as a user. Seems like maybe a typo?
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.
Oops it's typo. 😅
@jimschubert Thanks for pointing it out. Fixed the typo. |
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.
LGTM
* Improve error message when spec not found * Add test yaml * Fix invalid yaml file path * Fix typo
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
,3.4.x
,4.0.x
. Default:master
.Description of the PR
This PR closes #1449