in src/main/java/software/amazon/cloudformation/resource/Validator.java [82:110]
public Schema loadResourceDefinitionSchema(final JSONObject resourceDefinition) {
// inject/replace $schema URI to ensure that provider definition schema is used
resourceDefinition.put("$schema", RESOURCE_DEFINITION_SCHEMA_URI.toString());
try {
// step 1: validate resourceDefinition as a JSON object
// this validator cannot validate schema-specific attributes. For example if definition
// contains "propertyA": { "$ref":"./some-non-existent-location.json#definitions/PropertyX"}
// validateObject will succeed, because all it cares about is that "$ref" is a URI
// In order to validate that $ref points at an existing location in an existing document
// we have to "load" the schema
Schema resourceDefValidator = makeResourceDefinitionSchema();
resourceDefValidator.validate(resourceDefinition);
// step 2: load resource definition as a Schema that can be used to validate resource models;
// definitionSchemaJsonObject becomes a meta-schema
SchemaLoaderBuilder builder = getSchemaLoader();
registerMetaSchema(builder, resourceDefinition);
registerMetaSchema(builder, typeConfigurationDefinitionJson);
builder.schemaJson(resourceDefinition);
// when resource definition is loaded as a schema, $refs are resolved and validated
return builder.build().load().build();
} catch (final org.everit.json.schema.ValidationException e) {
throw ValidationException.newScrubbedException(e);
} catch (final org.everit.json.schema.SchemaException e) {
throw new ValidationException(e.getMessage(), e.getSchemaLocation(), e);
}
}