-
-
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
Validate spec on generation by default #251
Validate spec on generation by default #251
Conversation
Adds a validation parameter to CodegenConfigurator, and passes through options from CLI, Maven Plugin and Gradle Plugin to that property. Default is to validate the spec during generation. If spec has errors, we will output errors as well as warnings to the user. Option can be disabled by passing false to validateSpec (Maven/Gradle) or --validate-spec (CLI).
@jimschubert Can we run a validate without generate? |
@etherealjoy the CLI has a validate command. Our Homebrew formula can't be merged until the repo is 30 days old (3 days from now). I created a script that you can use to run the last snapshot: https://gist.github.com/jimschubert/ce241b0c78140e364f46914ef8ec4103 |
see related #142 |
* master: (26 commits) Prepare 3.0.1 release (OpenAPITools#280) [typescript-angular] strict type checking (OpenAPITools#218) [C++ server] Adjust the names (script, sample folder, generator) to lang option (OpenAPITools#250) Removed warnings for packages included in SDK for Net Core 2.0 (OpenAPITools#269) [cli] Completions command for suggestions (OpenAPITools#213) [Java][RestTemplate] Fix query parameter URL encoding (OpenAPITools#260) [cpp-qt5] Remove std::shared_ptr from Qt5 (OpenAPITools#267) Adds some links to the README (OpenAPITools#261) Update sec.gpg.enc to binary encoded secret Add gpg --check-trustdb, limit gpg to master Re-do encrypted gpg and reference in settings.xml Fix trailing semicolons in after_success Travis CI scripts Use ubuntu keyserver instead of mit (due to timeout) [gradle] Plugin release management (OpenAPITools#201) Updates small typo in qna.md (OpenAPITools#262) Fix ModelUtils.getUnusedSchema() (OpenAPITools#253) Add JaxRS to bin/ensure-up-to-date (OpenAPITools#248) feat(security): add cookie-auth support (OpenAPITools#240) Add 'unblu inc.' to company list (OpenAPITools#246) put company list in alphabetical order (OpenAPITools#244) ...
@wing328 do you have any concerns if we merge this? |
I did some tests locally but got errors with
Am I doing something wrong here? (clearly I don't have enough sleep these days...) |
How about |
* master: (116 commits) 3.1.0 release (OpenAPITools#486) Fix broken link to openapi generator plugin README (OpenAPITools#484) show warning message for nodejs server only (OpenAPITools#481) Add grokify to Go technical committee (OpenAPITools#479) [Slim] Improve codebase decouple (OpenAPITools#438) Ensure typescript samples are up to date (OpenAPITools#444) Update README.md [Golang][client] delete sample output dir before rebuild (OpenAPITools#477) update petstore samples (OpenAPITools#478) Revert "Improve Docker Tags (OpenAPITools#390)" update go client test dependencies (OpenAPITools#468) [Golang][client] fix for schema definition name `file` (OpenAPITools#433) Fix '.travis' file (syntax) make LICENSE GitHub display compatible (OpenAPITools#467) Improve Docker Tags (OpenAPITools#390) [Golang][client] fix file suffix for _test.go (OpenAPITools#449) Remove copy section (OpenAPITools#463) Add link to presentation (OpenAPITools#465) Use postProcessOperationsWithModels(Map, List) (OpenAPITools#431) [C] Adding petstore sample written in C (OpenAPITools#306) ...
…dation-option * origin/prepare_311: Update README.md Use last prod version for the sample fix version Prepare version 3.1.1-SNAPSHOT
@ackintosh great suggestion. Having a true-only switch really only makes sense on the CLI because the option parser doesn't support full range of boolean inputs. This means the CLI will have CLI ExampleCLI:
Default: fails on invalid spec
Maven Example
Modify
Gradle PluginExample, meant to fail:
Modify build.gradle in the samples directory to say
@wing328 this should be ready to re-evaluate. Sorry for the confusion with that CLI parameter. I know I had tested it, but I don't recall what I did because it was so long ago. Maybe I had originally implemented it as a String rather than a Boolean property (that's all I can think of). |
* master: [CLI] Add --generator-name / -g to config-help (OpenAPITools#491) Update README.md (OpenAPITools#493) Update README.md (OpenAPITools#488) Prepare version 3.1.1-SNAPSHOT (OpenAPITools#487)
Changed base branch: |
Thanks. |
The AppVeyor test passed via https://ci.appveyor.com/project/WilliamCheng/openapi-generator/build/jimschubert-generator-validation-option-1682. Shippable CI failure was not repeatable locally. Let's merge this to see if the Shippable build still occurs. |
Upgrade NoteThe default is to validate the spec during generation. If the spec has errors, The option can be disabled by passing false to |
@jmini you're right. Just updated the note above. |
* Validate spec on generation by default Adds a validation parameter to CodegenConfigurator, and passes through options from CLI, Maven Plugin and Gradle Plugin to that property. Default is to validate the spec during generation. If spec has errors, we will output errors as well as warnings to the user. Option can be disabled by passing false to validateSpec (Maven/Gradle) or --validate-spec (CLI). * Prepare version 3.1.1-SNAPSHOT * fix version * Use last prod version for the sample * Update README.md Fix * [cli] Option parser does not support true/false for boolean options
Adds a validation parameter to CodegenConfigurator, and passes through
options from CLI, Maven Plugin and Gradle Plugin to that property.
Default is to validate the spec during generation. If spec has errors,
we will output errors as well as warnings to the user.
Option can be disabled by passing false to skipValidateSpec (Maven/Gradle)
or --skip-validate-spec (CLI).
This was brought up in #208. We want to validate the spec on generation to prevent OpenAPI Spec 3.x options from creeping into OpenAPI Spec 2.0 support. I would also consider this a bug fix, because as a user I would be surprised to find that generation succeeds when my spec is invalid by default.
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
.