Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"Unknown keyword exclusiveMinimun" when validating an OpenAPI 3.0 document #1119

Closed
sonallux opened this issue Oct 12, 2024 · 4 comments · Fixed by #1127
Closed

"Unknown keyword exclusiveMinimun" when validating an OpenAPI 3.0 document #1119

sonallux opened this issue Oct 12, 2024 · 4 comments · Fixed by #1127

Comments

@sonallux
Copy link

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 the JsonSchema object:

[main] WARN com.networknt.schema.UnknownKeywordFactory - Unknown keyword exclusiveMinimum - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword or if it should generate annotations AnnotationKeyword

I am using this code to create the JsonSchema object:

return JsonSchemaFactory
    .getInstance(SpecVersion.VersionFlag.V4)
    .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.0/schema/latest"));

What is wrong with this and why am I getting the message printed to the console?

@jkosternl
Copy link
Contributor

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.

@sonallux
Copy link
Author

sonallux commented Nov 2, 2024

@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());
}

@stevehu
Copy link
Contributor

stevehu commented Nov 2, 2024

You cannot use v4 for OpenAPI 3.0. Try the latest version and let us know if it works.

@sonallux
Copy link
Author

sonallux commented Nov 2, 2024

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants