Skip to content
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

additionalProperties needs to be enforced to false #33

Open
chgeorgeamzn opened this issue Sep 18, 2019 · 1 comment
Open

additionalProperties needs to be enforced to false #33

chgeorgeamzn opened this issue Sep 18, 2019 · 1 comment
Labels
bug Something isn't working high

Comments

@chgeorgeamzn
Copy link

chgeorgeamzn commented Sep 18, 2019

At several points in the schema, there are JSON schema blocks that force additionalProperties to be false:

https://github.com/aws-cloudformation/aws-cloudformation-resource-schema/blob/6db79a6253e65ee97c55aacfdb7c67f408d2d573/src/main/resources/schema/provider.definition.schema.v1.json#L167-L171

However at no point in the schema is the field marked as required so that this validation applies. This poses a problem since the default value is true.

We need to make a change so this field has to be present. Adding it to the required arrays where necessary is one possible avenue.

@aygold92
Copy link
Contributor

aygold92 commented Sep 21, 2019

definnitely agree, but this is difficult because additionalProperties does not play nicely with oneOf, anyOf, etc.

For example, if you wanted to express "you must specify property A or property B for this object", you could do:

{
  "SomeProperty": {
    "type": "object",
    "oneOf": [
      {
        "properties": {
          "PropertyA": {
            "type": "string"
          }
        },
        "additionalProperties": false,
      },
      {
        "properties": {
          "PropertyB": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false,
    ]
  }
}

However, if we forced "additionalProperties": false on every subSchema, we would also have to put "additionalProperties": false on the SomeProperty schema, and since no properties are defined there it would break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high
Projects
None yet
Development

No branches or pull requests

3 participants