aws-cloudformation / cloudformation-resource-schema

The CloudFormation Resource Schema defines the shape and semantic for resources provisioned by CloudFormation. It is used by provider developers using the CloudFormation RPDK.
Apache License 2.0
90 stars 38 forks source link

ResourceTypeSchema fails when loading resource definitions using 'oneOf', 'if' keywords #70

Open vladtsir opened 4 years ago

vladtsir commented 4 years ago

Error:

java.lang.ClassCastException: org.everit.json.schema.CombinedSchema$Builder cannot be cast to org.everit.json.schema.ObjectSchema$Builder
    at software.amazon.cloudformation.resource.ResourceTypeSchema.load(ResourceTypeSchema.java:110)

To reproduce create a schema file as follows:

valid-with-oneof.json:

{
  "typeName": "AWS::Test::TestModel",
  "description": "A test schema for unit tests.",
  "sourceUrl": "https://mycorp.com/my-repo.git",
  "properties": {
    "propertyA": {
      "type": "string"
    },
    "propertyB": {
      "type": "string"
    }
  },
  "oneOf": [
    { "required":  ["propertyA"]},
    { "required" : ["propertyB"]}
  ],
  "primaryIdentifier": [
    "/properties/propertyA"
  ],
  "additionalProperties": false
}
public void validSchema_withOneOf_shouldSucceed() {
        JSONObject resource = loadJSON("/valid-with-oneof.json");
        final ResourceTypeSchema schema = ResourceTypeSchema.load(resource);
}
PatMyron commented 3 years ago

@vladtsir does https://github.com/aws-cloudformation/aws-cloudformation-resource-schema/pull/81 fix this?