|
| 1 | +package com.networknt.schema.oas; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | + |
| 5 | +import com.networknt.schema.AnnotationKeyword; |
| 6 | +import com.networknt.schema.Formats; |
| 7 | +import com.networknt.schema.JsonMetaSchema; |
| 8 | +import com.networknt.schema.NonValidationKeyword; |
| 9 | +import com.networknt.schema.SchemaId; |
| 10 | +import com.networknt.schema.SpecVersion; |
| 11 | +import com.networknt.schema.ValidatorTypeCode; |
| 12 | + |
| 13 | +/** |
| 14 | + * OpenAPI 3.0. |
| 15 | + */ |
| 16 | +public class OpenApi30 { |
| 17 | + private static final String IRI = SchemaId.OPENAPI_3_0; |
| 18 | + private static final String ID = "id"; |
| 19 | + |
| 20 | + private static class Holder { |
| 21 | + private static final JsonMetaSchema INSTANCE; |
| 22 | + static { |
| 23 | + INSTANCE = JsonMetaSchema.builder(IRI) |
| 24 | + .specification(SpecVersion.VersionFlag.V4) |
| 25 | + .idKeyword(ID) |
| 26 | + .formats(Formats.DEFAULT) |
| 27 | + .keywords(Arrays.asList( |
| 28 | + new AnnotationKeyword("title"), |
| 29 | + ValidatorTypeCode.PATTERN, |
| 30 | + ValidatorTypeCode.REQUIRED, |
| 31 | + ValidatorTypeCode.ENUM, |
| 32 | + ValidatorTypeCode.MINIMUM, |
| 33 | + ValidatorTypeCode.MAXIMUM, |
| 34 | + ValidatorTypeCode.EXCLUSIVE_MINIMUM, |
| 35 | + ValidatorTypeCode.EXCLUSIVE_MAXIMUM, |
| 36 | + ValidatorTypeCode.MULTIPLE_OF, |
| 37 | + ValidatorTypeCode.MIN_LENGTH, |
| 38 | + ValidatorTypeCode.MAX_LENGTH, |
| 39 | + ValidatorTypeCode.MIN_ITEMS, |
| 40 | + ValidatorTypeCode.MAX_ITEMS, |
| 41 | + ValidatorTypeCode.UNIQUE_ITEMS, |
| 42 | + ValidatorTypeCode.MIN_PROPERTIES, |
| 43 | + ValidatorTypeCode.MAX_PROPERTIES, |
| 44 | + |
| 45 | + ValidatorTypeCode.TYPE, |
| 46 | + ValidatorTypeCode.FORMAT, |
| 47 | + new AnnotationKeyword("description"), |
| 48 | + ValidatorTypeCode.ITEMS, |
| 49 | + ValidatorTypeCode.PROPERTIES, |
| 50 | + ValidatorTypeCode.ADDITIONAL_PROPERTIES, |
| 51 | + new AnnotationKeyword("default"), |
| 52 | + ValidatorTypeCode.ALL_OF, |
| 53 | + ValidatorTypeCode.ONE_OF, |
| 54 | + ValidatorTypeCode.ANY_OF, |
| 55 | + ValidatorTypeCode.NOT, |
| 56 | + |
| 57 | + new AnnotationKeyword("deprecated"), |
| 58 | + ValidatorTypeCode.DISCRIMINATOR, |
| 59 | + new AnnotationKeyword("example"), |
| 60 | + new AnnotationKeyword("externalDocs"), |
| 61 | + new NonValidationKeyword("nullable"), |
| 62 | + ValidatorTypeCode.READ_ONLY, |
| 63 | + ValidatorTypeCode.WRITE_ONLY, |
| 64 | + new AnnotationKeyword("xml"), |
| 65 | + |
| 66 | + ValidatorTypeCode.REF |
| 67 | + )) |
| 68 | + .build(); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + public static JsonMetaSchema getInstance() { |
| 73 | + return Holder.INSTANCE; |
| 74 | + } |
| 75 | +} |
0 commit comments