APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

Console exit status is 0 on error #1

Closed johndaviddunlap closed 8 years ago

johndaviddunlap commented 8 years ago

I'm integrating swagger-cli into a custom build script for our application. The problem that I've run into is that our build fails if any of the commands it runs returns a non-zero exist status. However, when swagger-cli finds an error in the swagger spec file, it still sets a 0 exit status, which doesn't fail our build. By convention, all command line scripts return 0 on success and non-zero on error so that shell scripts which invoke them can determine if they completed successfully or not. I would ask that you add support for this convention as it would make it considerably more useful from the command line.

For the time being, I've implemented an ugly ugly hack where I capture the complete output of the command and fail the build if the output of the validator contains the word "error".

JamesMessinger commented 8 years ago

Hmmm... sounds like something's not working right then. The swagger validate and swagger bundle commands both return non-zero if the API is invalid. Or, at least, that's what they're supposed to do. Can you post the exact command that you're using, and a sample API that reproduces the problem?

johndaviddunlap commented 8 years ago

It would appear that the problem was in my scripts. The non-zero exit status was not propagating up to the parent script because of a scripting error on my part. My apologies for disturbing you and thank you for your prompt reply.

Cheers! John

JamesMessinger commented 8 years ago

Ok, cool. Glad to help. ;) (and glad you solved the problem)