-
Notifications
You must be signed in to change notification settings - Fork 325
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
Validation error for "id" field in referenced schema #1093
Comments
This is intentional behavior to catch bugs as previously in Draft 4 unique identifiers are declared using the For users who really legitimately have a custom JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012())
.keyword(new AnnotationKeyword("id")).build();
JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012,
builder -> builder.metaSchema(metaSchema)); This isn't what is happening here though, this looks like you aren't using the If you look again at your schema below, you have {
"$schema": "http://json-schema.org/draft/2019-09/schema",
"$defs": {
"definitions": {
"$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "object",
"id": {
"description": "Unique identifier",
"type": "string",
"minLength": 5,
"maxLength": 100
}
}
},
"properties": {
"id": {
"description": "Unique identifier of an account as provided by the FI",
"dataPrivacyLevel": "sensitive",
"label": "Account ID",
"$ref": "#/$defs/definitions/id"
}
}
} Not knowing your intent, I would just suggest to remove {
"$schema": "http://json-schema.org/draft/2019-09/schema",
"$defs": {
"id": {
"description": "Unique identifier",
"type": "string",
"minLength": 5,
"maxLength": 100
}
},
"properties": {
"id": {
"description": "Unique identifier of an account as provided by the FI",
"dataPrivacyLevel": "sensitive",
"label": "Account ID",
"$ref": "#/$defs/id"
}
}
} |
Library is giving error java.lang.UnsupportedOperationException: No suitable validator for id
PFA java class to reproduce issue version 1.4.0 and 1.5.0. Issue is not produced in old version of library version 1.0.86
New folder.zip
Run attached java class issue will be reproduced, replace line 81 with main1.json, and notice data validated without id field in ref schema
StackTrace
Exception in thread "main" com.networknt.schema.JsonSchemaException: java.lang.UnsupportedOperationException: No suitable validator for id
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:508)
at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:63)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:545)
at com.networknt.schema.JsonSchema.getValidators(JsonSchema.java:1325)
at com.networknt.schema.JsonSchema.(JsonSchema.java:151)
at com.networknt.schema.JsonSchema.from(JsonSchema.java:66)
at com.networknt.schema.JsonSchemaFactory.doCreate(JsonSchemaFactory.java:369)
at com.networknt.schema.JsonSchemaFactory.create(JsonSchemaFactory.java:365)
at com.networknt.schema.ValidationContext.newSchema(ValidationContext.java:58)
at com.networknt.schema.NonValidationKeyword$Validator.(NonValidationKeyword.java:46)
at com.networknt.schema.NonValidationKeyword.newValidator(NonValidationKeyword.java:66)
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:496)
at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:63)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:545)
at com.networknt.schema.JsonSchema.getValidators(JsonSchema.java:1325)
at com.networknt.schema.JsonSchema.(JsonSchema.java:151)
at com.networknt.schema.JsonSchema.from(JsonSchema.java:66)
at com.networknt.schema.JsonSchemaFactory.doCreate(JsonSchemaFactory.java:369)
at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:334)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:526)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:509)
at NetworkNtIssue.main(NetworkNtIssue.java:80)
Caused by: java.lang.UnsupportedOperationException: No suitable validator for id
at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:161)
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:496)
... 21 more
The text was updated successfully, but these errors were encountered: