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

Support for allOf, anyOf and oneOf keywords #16

Closed
ewbankkit opened this issue Aug 25, 2021 · 3 comments · Fixed by #17
Closed

Support for allOf, anyOf and oneOf keywords #16

ewbankkit opened this issue Aug 25, 2021 · 3 comments · Fixed by #17

Comments

@ewbankkit
Copy link
Contributor

Support schema composition via the allOf, anyOf and oneOf keywords.

@ewbankkit
Copy link
Contributor Author

ewbankkit commented Aug 25, 2021

Some example usage:

In a property definition
    "Action": {
      "type": "object",
      "properties": {
        "Operation": {
          "description": "Step action operation",
          "type": "string"
        },
        "Parameters": {
          "anyOf": [
            {
              "$ref": "#/definitions/RecipeParameters"
            },
            {
              "$ref": "#/definitions/ParameterMap"
            }
          ]
        }
      },
      "additionalProperties": false,
      "required": ["Operation"]
    },

    "FilterAndOperator": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "Tags"
          ],
          "properties": {
            "Prefix": {
              "description": "Prefix identifies one or more objects to which the rule applies.",
              "$ref": "#/definitions/FilterPrefix"
            },
            "Tags": {
              "description": "All of these tags must exist in the object's tag set in order for the rule to apply.",
              "type": "array",
              "uniqueItems": true,
              "minItems": 1,
              "items": {
                "$ref": "#/definitions/FilterTag"
              }
            }
          }
        }
      ]
    }

    "CapacityProvider": {
      "description": "If using ec2 auto-scaling, the name of the associated capacity provider. Otherwise FARGATE, FARGATE_SPOT.",
      "type": "string",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "FARGATE",
            "FARGATE_SPOT"
          ]
        },
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        }
      ]
    },

    "OneDriveUsers": {
      "type": "object",
      "properties": {
        "OneDriveUserList": {
          "$ref": "#/definitions/OneDriveUserList"
        },
        "OneDriveUserS3Path": {
          "$ref": "#/definitions/S3Path"
        }
      },
      "additionalProperties": false,
      "oneOf": [
        {
          "required": [
            "OneDriveUserList"
          ]
        },
        {
          "required": [
            "OneDriveUserS3Path"
          ]
        }
      ]
    },
At the top level
    "anyOf": [
        {
            "required": [
                "FirehoseArn",
                "RoleArn",
                "OutputFormat"
            ]
        },
        {
            "allOf": [
                {
                    "required": [
                        "FirehoseArn",
                        "RoleArn",
                        "OutputFormat"
                    ]
                },
                {
                    "oneOf": [
                        {
                            "required": ["IncludeFilters"]
                        },
                        {
                            "required": ["ExcludeFilters"]
                        }
                    ]
                }
            ]
        }
    ],

  "allOf": [
    {
      "required": [
        "EC2InstanceType",
        "Name"
      ]
    },
    {
      "oneOf": [
        {
          "required": [
            "BuildId"
          ]
        },
        {
          "required": [
            "ScriptId"
          ]
        }
      ]
    },
    {
      "oneOf": [
        {
          "required": [
            "RuntimeConfiguration"
          ]
        },
        {
          "required": [
            "ServerLaunchParameters",
            "ServerLaunchPath"
          ]
        }
      ]
    }
  ],

@ewbankkit
Copy link
Contributor Author

Don't do anything with the top-level occurrences - How they are meant to work is not (yet) documented: aws-cloudformation/cloudformation-resource-schema#94.

@ewbankkit
Copy link
Contributor Author

At this stage we will only address the nested anyOf, allOf and oneOf with required.

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