forked from networknt/json-schema-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
1,286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.networknt.schema; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class Issue673Test { | ||
private static JsonSchema schema; | ||
|
||
@BeforeAll | ||
static void init() { | ||
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); | ||
String schemaPath = "/schema/issue673-openapi-schema.json"; | ||
InputStream schemaInputStream = Issue673Test.class.getResourceAsStream(schemaPath); | ||
schema = factory.getSchema(schemaInputStream); | ||
} | ||
|
||
@Test | ||
void testInvalidTimeRepresentations() throws IOException { | ||
String validationPath = "/schema/issue673-validation.json"; | ||
Set<ValidationMessage> errors = schema.validate(new ObjectMapper().readTree(Issue673Test.class.getResourceAsStream(validationPath))); | ||
|
||
System.out.println(errors.stream().map(ValidationMessage::getMessage).collect(Collectors.joining("\n"))); | ||
|
||
Assertions.assertTrue(errors.isEmpty()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$id": "https://spec.openapis.org/oas/3.1/schema-base/2022-10-07", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
|
||
"description": "The description of OpenAPI v3.1.x documents using the OpenAPI JSON Schema dialect, as defined by https://spec.openapis.org/oas/v3.1.0", | ||
|
||
"$ref": "https://spec.openapis.org/oas/3.1/schema/2022-10-07", | ||
"properties": { | ||
"jsonSchemaDialect": { "$ref": "#/$defs/dialect" } | ||
}, | ||
|
||
"$defs": { | ||
"dialect": { "const": "https://spec.openapis.org/oas/3.1/dialect/base" }, | ||
|
||
"schema": { | ||
"$dynamicAnchor": "meta", | ||
"$ref": "https://spec.openapis.org/oas/3.1/dialect/base", | ||
"properties": { | ||
"$schema": { "$ref": "#/$defs/dialect" } | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.