-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat: error for oneOf, anyOf, allOf schema that does not use array #143
Conversation
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
=========================================
+ Coverage 92.88% 92.9% +0.02%
=========================================
Files 61 61
Lines 2109 2115 +6
=========================================
+ Hits 1959 1965 +6
Misses 150 150
Continue to review full report at Codecov.
|
83d976c
to
987b863
Compare
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.
Looks good! Just a couple minor changes
987b863
to
b010206
Compare
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.
Looks good. I recommend removing the configuration of this check altogether -- then we can avoid the need to come up with a concise but descriptive name for what is essentially an OpenAPI requirement.
README.md
Outdated
@@ -251,6 +251,7 @@ The supported rules are described below: | |||
| no_property_description | Flag any schema that contains a 'property' without a `description` field. | shared | | |||
| description_mentions_json | Flag any schema with a 'property' description that mentions the word 'JSON'. | shared | | |||
| array_of_arrays | Flag any schema with a 'property' of type `array` with items of type `array`. | shared | | |||
| compose_model_field_not_array | Flag any compose model schema that does not use an array. | shared | |
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.
If we keep this configurable, I think we want a clearer name and description. "compose model" is a term from the SDK generator -- not used in OpenAPI or JSON Schema. So better to use something like "allOf_value_not_array" and "Flag any allOf
schema attribute whose value is not an array".
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.
I chose to use compose model because this PR checks that allOf
, anyOf
, and oneOf
use arrays. In the following changes, I am going to remove the configuration option, but I want to make sure you agree with the choice to include anyOf
and oneOf
.
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.
Yes -- we should check all three. I made my suggestion before I saw the code below.
invalid_type_format_pair: 'error' | ||
} | ||
}; | ||
|
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.
All the changes above here appear to be unrelated to this feature.
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.
Yes, while I was introducing tests to this module, I thought it would be a good idea to clean up the individual declarations of config and replace them with one import. I changed the config name to customConfig for the cases where the test uses a custom value.
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.
^ I support these changes
b010206
to
793308a
Compare
2a2d7a3
to
302c499
Compare
…r parameter - added a findOctetSequences function to handle the logic of finding schema type: string, format: binary for cases of nested arrays, objects, nested arrays of type object, objects with properties that are nested arrays, and objects with properties that are objects, and the simple case where a schema uses type: string, format: binary directly. This function takes a schema object from a resolvedSpec and returns a list of paths to octet sequences (empty list if none found). - added logic to handle application/json request bodies that use schema type: string, format: binary - added logic to handle application/json response bodies of type: string, format: binary - added logic to handle parameters of type: string, format: binary - removed 'binary' as a valid format for type: string parameters. parameters of type: string, format: binary will result in "type+format not well-defined" error - added tests to ensure warnings are issued for request bodies, response bodies, and parameters with schema, type: string, format: binary - added complex tests to exercise combinations of nested arrays and objects that contain schema type: string, format: binary (complex tests done on response bodies) - added "json_or_param_binary_string" as to .defaultsForValidator as a warning in the shared.schemas section - added "json_or_param_binary_string" configuration option to the README.md rules and defaults sections in the schemas section
…r parameter - added a findOctetSequences function to handle the logic of finding schema type: string, format: binary for cases of nested arrays, objects, nested arrays of type object, objects with properties that are nested arrays, and objects with properties that are objects, and the simple case where a schema uses type: string, format: binary directly. This function takes a schema object from a resolvedSpec and returns a list of paths to octet sequences (empty list if none found). - added logic to handle application/json request bodies that use schema type: string, format: binary - added logic to handle application/json response bodies of type: string, format: binary - added logic to handle parameters of type: string, format: binary - removed 'binary' as a valid format for type: string parameters. parameters of type: string, format: binary will result in "type+format not well-defined" error - added tests to ensure warnings are issued for request bodies, response bodies, and parameters with schema, type: string, format: binary - added complex tests to exercise combinations of nested arrays and objects that contain schema type: string, format: binary (complex tests done on response bodies) - added "binary_string" as to .defaultsForValidator as a warning in the shared.schemas section - added "binary_string" configuration option to the README.md rules and defaults sections in the schemas section
…r parameter - added a hasOctetSequence module to handle the logic of finding schema type: string, format: binary for cases of nested arrays, objects, nested arrays of type object, objects with properties that are nested arrays, and objects with properties that are objects, and the simple case where a schema uses type: string, format: binary directly. This function takes a schema object from a resolvedSpec and returns a list of paths to octet sequences (empty list if none found). - added logic to handle application/json request bodies that use schema type: string, format: binary - added logic to handle application/json response bodies of type: string, format: binary - added logic to handle parameters of type: string, format: binary - removed 'binary' as a valid format for type: string parameters. parameters of type: string, format: binary will result in "type+format not well-defined" error - added tests to ensure warnings are issued for request bodies, response bodies, and parameters with schema, type: string, format: binary - added complex tests to exercise combinations of nested arrays and objects that contain schema type: string, format: binary (complex tests done on response bodies) - added "binary_string" as to .defaultsForValidator as a warning in the shared.schemas section - added "binary_string" configuration option to the README.md rules and defaults sections in the schemas section
…rrors - introduced MessageCarrier class to centralize the logic/checks for adding warnings and errors. - introduced an instance of this class in each semantic validator to provide uniform warning and error reporting - added unit tests for the MessageCarrier class
- added error for oneOf, anyOf, or allOf schema that is not use top-level array - updated schema-ibm test to import the default config values and made necessary changes to test to account for unexpected errors and warnings resulting from having all default values present - added tests when oneOf, anyOf, or allOf schemas are nested ("oneOf allOf," for example), when oneOf, anyOf, or allOf schema is used as a property in an obect, and when oneOf, anyOf, or allOf schema used as items in array - added test to ensure errors not issued when compose models use an array
302c499
to
ec7c365
Compare
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.
Looks good to me! I'll give @mkistler one more change to review before merging
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.
Looks good! 👍
# [0.23.0](v0.22.0...v0.23.0) (2020-02-24) ### Features * error for oneOf, anyOf, allOf schema that does not use array ([#143](#143)) ([1db6b27](1db6b27))
🎉 This PR is included in version 0.23.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Changes:
Tests: