Closed sonallux closed 2 weeks ago
Which version of the library did you use @sonallux? Please always specify that in a question.
In v.1.5.2 that keyword was changed a bit in OpenAPI 3.0, see #1114
Make sure you are using it in the right way.
You can also check src/test/java/com/networknt/schema/oas/OpenApi30Test.java
as an example.
@jkosternl I am using the v1.5.2. But the Issue is also present in the recently released v1.5.3.
The examples in src/test/java/com/networknt/schema/oas/OpenApi30Test.java
are different to the use case I have. I want to validate a complete OpenAPI 3.0 definition file against the official OpenAPI 3.0 schema.
Here is a more complete example:
@Test
void testOpenApiValidation() throws Exception {
var schema = JsonSchemaFactory
.getInstance(VersionFlag.V4)
.getSchema(SchemaLocation.of("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/refs/heads/main/schemas/v3.0/schema.yaml"));
var result = schema.validate(Files.readString(Path.of("petstore.yaml")), InputFormat.YAML);
assertEquals(0, result.size());
}
You cannot use v4 for OpenAPI 3.0. Try the latest version and let us know if it works.
You cannot use v4 for OpenAPI 3.0. Try the latest version and let us know if it works.
@stevehu thanks for your reply. But I do not understand it.
The OpenAPI 3.0 Schema file is explicitly mentioning it is using JsonSchema v4 here. Also the SpecVersionDetector
is is reporting v4 for the OpenAPI 3.0 Schema.
I am currently trying to validate an OpenAPI 3.0 document using the
json-schema-validator
library and I am getting the following warning when creating theJsonSchema
object:I am using this code to create the
JsonSchema
object:What is wrong with this and why am I getting the message printed to the console?