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

"type" has to be singular by flattener code but can be an array by schema validation #1059

Open
kddejong opened this issue Feb 15, 2024 · 2 comments

Comments

@kddejong
Copy link
Contributor

This is to track if we should support multiple types or fix the code in cloudformation-cli to support multiple types. Right now the flatenner will fail when doing the following. Additionally the schema allows for multiple types.

{
  "type": ["array", "object"],
  "properties": {
    "a": {}
  },
  "items": {
    "properties": {
      "b": {}
    }
  }
}

2) Each property can only be a single type.
A) For primitive types, combiners (``anyOf``, ``allOf``, and ``oneOf``)
B) For object types, the flattener will attempt to squash all properties
specified in combiners into the object, and will fail if multiple types are
declared.

Schema definition: https://github.com/aws-cloudformation/cloudformation-resource-schema/blob/master/src/main/resources/schema/schema#L145-L155

{
    "type": {
      "anyOf": [
        { "$ref": "#/definitions/simpleTypes" },
        {
          "type": "array",
          "items": { "$ref": "#/definitions/simpleTypes" },
          "minItems": 1,
          "uniqueItems": true
        }
      ]
    }
}
@ericzbeard
Copy link
Contributor

Are there any existing types that do this?

@kddejong
Copy link
Contributor Author

Not if they are using the cloudformation-cli cause it would fail.

This shows up the most as a result of inline policies or definitions (like step functions).

"type": [
    "object",
    "string"
   ]

There are some other random multi types... none that specify array and objects together. In general the flattener is used in a lot of places in the cloudformation-cli and we make an assumption that we only support singular types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants