Conversation
…so present When encountering a CRD that has a 'properties' field in its spec the script would incorrectly add an `"additionalProperties": false` field, which made the generated jsonschema and invalid draft 04 schema. The script now checks that there is a `type` field next to `properties` with the value either "object" or an array containing "object", before adding the `additionalProperties` field.
3 tasks
This branch has not been deployed
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.
The
openapi2jsonschema.pyscript assumes that apropertiesfield will never appear in a CRD and produces invalid schemas if it does.The following OpenAPI schema
{ "type": "object", "properties": { "properties": { "type": "object", "additionalProperties": { "type": "string" } } } }is transformed into
{ "type": "object", "properties": { "properties": { "type": "object", "additionalProperties": { "type": "string" } }, "additionalProperties": false } "additionalProperties": false }when it should be just
{ "type": "object", "properties": { "properties": { "type": "object", "additionalProperties": { "type": "string" } } } "additionalProperties": false }You can see this happening in
policies.kyverno.io/policyexception_v1.jsonwhere the addition of aspec.propertiesfield in the PolicyException CRD caused the script to generate an invalid schema.CRDs-catalog/policies.kyverno.io/policyexception_v1.json
Line 102 in 866b265