Skip to content

Commit 8814cfa

Browse files
authored
Add Java Syntax Highlighting to specversion.md (#483)
1 parent 4a3d23a commit 8814cfa

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/specversion.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,59 @@ The library supports V4, V6, V7, and V2019-09 JSON schema specifications. By def
44

55
#### To create a draft V4 JsonSchemaFactory
66

7-
```
7+
```java
88
ObjectMapper mapper = new ObjectMapper();
99
JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).objectMapper(mapper).build();
1010
```
1111
or with default configuration
12-
```
12+
```java
1313
JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4));
1414
```
1515

1616
Please avoid using default getInstance(), which, internally, defaults to the SpecVersion.VersionFlag.V4 as the parameter. This is deprecated.
1717

1818
#### To create a draft V6 JsonSchemaFactory
1919

20-
```
20+
```java
2121
ObjectMapper mapper = new ObjectMapper();
2222
JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V6)).objectMapper(mapper).build();
2323
```
2424
or with default configuration
25-
```
25+
```java
2626
JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V6));
2727
```
2828

2929
#### To create a draft V7 JsonSchemaFactory
3030

31-
```
31+
```java
3232
ObjectMapper mapper = new ObjectMapper();
3333
JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).objectMapper(mapper).build();
3434
```
3535
or with default configuration
36-
```
36+
```java
3737
JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7));
3838
```
3939

4040
#### To create a draft 2019-09 JsonSchemaFactory
4141

42-
```
42+
```java
4343
ObjectMapper mapper = new ObjectMapper();
4444
JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).objectMapper(mapper).build();
4545
```
4646
or with default configuration
47-
```
47+
```java
4848
JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909));
4949
```
5050

5151
#### To create a JsonSchemaFactory, automatically detecting schema version
5252

53-
```
53+
```java
5454
ObjectMapper mapper = new ObjectMapper();
5555
JsonNode jsonNode = mapper.readTree(/* schema / schema input steam etc. */);
5656
JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersionDetector.detect(jsonNode))).objectMapper(mapper).build();
5757
```
5858
or with default configuration
59-
```
59+
```java
6060
ObjectMapper mapper = new ObjectMapper();
6161
JsonNode jsonNode = mapper.readTree(/* schema / schema input steam etc. */);
6262
JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersionDetector.detect(jsonNode));
@@ -68,7 +68,7 @@ JsonSchemaFactory validatorFactory = JsonSchemaFactory.getInstance(SpecVersionDe
6868

6969
A new class SpecVersion has been introduced to indicate which version of the specification is used when creating the JsonSchemaFactory. The SpecVersion has an enum and two methods to convert a long to an EnumSet or a set of VersionFlags to a long value.
7070

71-
```
71+
```java
7272
public enum VersionFlag {
7373

7474
V4(1<<0),
@@ -115,7 +115,7 @@ EXCLUSIVE_MAXIMUM("exclusiveMaximum", "1038", new MessageFormat("{0}: must have
115115

116116
The getNonFormatKeywords method is updated to accept a SpecVersion.VersionFlag so that only the keywords supported by the specification will be loaded.
117117

118-
```
118+
```java
119119
public static List<ValidatorTypeCode> getNonFormatKeywords(SpecVersion.VersionFlag versionFlag) {
120120
final List<ValidatorTypeCode> result = new ArrayList<ValidatorTypeCode>();
121121
for (ValidatorTypeCode keyword: values()) {
@@ -137,7 +137,7 @@ For the BUILDIN_FORMATS, there is a common section, and each static class has it
137137

138138
The getInstance supports a parameter SpecVersion.VersionFlag to get the right instance of the JsonMetaShema to create the factory. If there is no parameter, then V4 is used by default.
139139

140-
```
140+
```java
141141
@Deprecated
142142
public static JsonSchemaFactory getInstance() {
143143
return getInstance(SpecVersion.VersionFlag.V4);
@@ -170,7 +170,7 @@ public static JsonSchemaFactory getInstance(SpecVersion.VersionFlag versionFlag)
170170

171171
This class detects schema version based on the schema tag.
172172

173-
```
173+
```java
174174
private static final String SCHEMA_TAG = "$schema";
175175

176176
public static SpecVersion.VersionFlag detect(JsonNode jsonNode) {

0 commit comments

Comments
 (0)