-
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
dependentSchemas and dependentRequired keywords not implemented #321
Comments
@gjvoosten Thanks a lot for raising it up. Several keywords are not implemented as our team is not using them at the moment. They are in the pipeline though when we have time. If would be great if you and others can take the time to get them implemented. |
Hi, I have created pull request resolving this issue #479. |
@gjvoosten, the implementation provided by @kmalski has merged to the master branch already. Once several other pending issues are resolved, we will have a new release. Meanwhile, you can test the new keyword with the master branch code. Thanks @kmalski for your help. |
@gjvoosten Yes. You are right. That is another keyword we need to implement. Let's see if someone can help. Thanks for the reminder. |
@stevehu is there a list of keywords not yet implemented? Besides, should package com.networknt.schema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DependentRequiredTest {
private ObjectMapper mapper = new ObjectMapper();
@Test
public void attributeADependentRequiresB() throws Exception {
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
JsonSchema schema = factory.getSchema("{" +
" \"$id\": \"https://example.com/testingErrorCodes.schema.json\"," +
" \"$schema\": \"http://json-schema.org/draft-07/schema#\"," +
" \"type\": \"object\"," +
" \"properties\": {" +
" \"a\": {" +
" \"type\": \"number\"" +
" }," +
" \"b\": {" +
" \"type\": \"number\"" +
" }" +
" }," +
" \"dependentRequired\": {" +
" \"a\": [\"b\"]" +
" }" +
"}");
JsonNode json = mapper.readTree("{\"a\": 5}");
Set<ValidationMessage> validationMessages = schema.validate(json);
assertEquals(1, validationMessages.size());
}
} It tries to match the object {
"$id": "https://example.com/testingErrorCodes.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"a": {
"type": "number"
},
"b": {
"type": "number"
}
},
"dependentRequired": {
"a": ["b"]
}
} |
@rustermi The keyword is implemented and passed the official test suite. I am not very familiar with the keyword as I haven't used it yet. I am wondering if you could create a test case and debug it into the validator to see why it fails. Thanks. |
We currently don't use the keyword either. When we do, I will follow your proposal. |
@rustermi Thanks for your response. I will close this issue for now and will reopen it if needed. |
From JSON Schema 2019-09, the new keywords
dependentSchemas
anddependentRequired
(replacingdependencies
) are not implemented; see https://json-schema.org/draft/2019-09/release-notes.html#semi-incompatible-changesThe text was updated successfully, but these errors were encountered: