aws-cloudformation / aws-cloudformation/cloudformation-resource-schema

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

Open
#70 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
96
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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);
}
```

Contributor guide

Open the contributing guide

Research direction

Start at ResourceTypeSchema.load on line 110 and reproduce the ClassCastException with valid-with-oneof.json. Use the shown validSchema_withOneOf_shouldSucceed test as the check; done means loading the resource returns a ResourceTypeSchema without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.