[core] Initial implementation of a validation framework in core#3183
Merged
jimschubert merged 5 commits intoOpenAPITools:masterfrom Jun 24, 2019
Merged
[core] Initial implementation of a validation framework in core#3183jimschubert merged 5 commits intoOpenAPITools:masterfrom
jimschubert merged 5 commits intoOpenAPITools:masterfrom
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
4 tasks
Member
Author
|
This replaces #3067. Package name chosen in the other PR/branch caused issues. |
* master: Prepare 4.0.3-SNAPSHOT (OpenAPITools#3185) 4.0.2 release (OpenAPITools#3181)
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif 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\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master,4.1.x,5.0.x. Default:master.Description of the PR
This adds a simple validation framework to the core module, which aims to give us a consistent way of applying errors/warnings. I'm opening this to generate some discussion about the usability of it.
I intend to use this in #2946 to pull validations out of
CodegenConfiguratorinto a self-contained and testable type. I also intend to look into applying this to #1086. I could also see this being useful to validate certain conditions we assume to be required for passing data context to templates (see #837).The goal here is to create a generic validator which can be applied to an OpenAPI Document, allowing us to provide warnings and errors specific to openapi-generator (in addition to those provided by swagger-parser). This has been made generic so, for example, we could apply validations to other spec documents if/when we support them. We could also create an interface which allows a generator to provide conventional typed validations for that generator.
For example:
This could be applied to a generator so we can provide errors and warnings prior to generation. Applying this to a generator might look like this:
With the above, we could allow options to treat warnings as errors and fail before writing any files.
cc @OpenAPITools/generator-core-team @OpenAPITools/openapi-generator-collaborators