typeCombinations = getSimpleTypeCombinations().collect(Collectors.toList());
+ return EnumSet.allOf(SchemaVersion.class).stream()
+ .flatMap(schemaVersion -> typeCombinations.stream()
+ .map(entry -> Arguments.of(entry.get()[0], entry.get()[1], entry.get()[3], schemaVersion)));
+ }
+
@ParameterizedTest
@MethodSource("parametersForTestGenerateSchema_SimpleTypeWithoutFormat")
public void testGenerateSchema_SimpleTypeWithoutFormat(Class> targetType, SchemaKeyword expectedJsonSchemaType, SchemaVersion schemaVersion)
@@ -141,4 +151,27 @@ public void testGenerateSchema_SimpleType_withAdditionalPropertiesOption(Class
result.get(SchemaKeyword.TAG_TYPE.forVersion(schemaVersion)).asText());
}
}
+
+ @ParameterizedTest
+ @MethodSource("parametersForTestGenerateSchema_SimpleTypeWithStandardFormat")
+ public void testGenerateSchema_SimpleTypeWithStandardFormat(Class> targetType, SchemaKeyword expectedJsonSchemaType, String expectedFormat,
+ SchemaVersion schemaVersion) throws Exception {
+ SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(schemaVersion)
+ .with(Option.ADDITIONAL_FIXED_TYPES, Option.STANDARD_FORMATS)
+ .build();
+ SchemaGenerator generator = new SchemaGenerator(config);
+ JsonNode result = generator.generateSchema(targetType);
+ if (expectedJsonSchemaType == null) {
+ Assertions.assertTrue(result.isEmpty());
+ } else if (expectedFormat == null) {
+ Assertions.assertEquals(1, result.size());
+ Assertions.assertEquals(expectedJsonSchemaType.forVersion(schemaVersion),
+ result.get(SchemaKeyword.TAG_TYPE.forVersion(schemaVersion)).asText());
+ } else {
+ Assertions.assertEquals(2, result.size());
+ Assertions.assertEquals(expectedJsonSchemaType.forVersion(schemaVersion),
+ result.get(SchemaKeyword.TAG_TYPE.forVersion(schemaVersion)).asText());
+ Assertions.assertEquals(expectedFormat, result.get(SchemaKeyword.TAG_FORMAT.forVersion(schemaVersion)).asText());
+ }
+ }
}
diff --git a/slate-docs/source/includes/_main-generator-options.md b/slate-docs/source/includes/_main-generator-options.md
index c2111135..fe02215e 100644
--- a/slate-docs/source/includes/_main-generator-options.md
+++ b/slate-docs/source/includes/_main-generator-options.md
@@ -61,7 +61,7 @@ configBuilder.without(
Option.EXTRA_OPEN_API_FORMAT_VALUES |
- Include extra "format" values (e.g. "int32" , "int64" , "date" , "date-time" , "uuid" ) for fixed types (primitive/basic types, plus some of the Option.ADDITIONAL_FIXED_TYPES if they are enabled as well). |
+ Include extra "format" values (e.g. "int32" , "int64" , "date" , "time" , "date-time" , "duration" , "uuid" , "uri" ) for fixed types (primitive/basic types, plus some of the Option.ADDITIONAL_FIXED_TYPES if they are enabled as well). Only works if Option.ADDITIONAL_FIXED_TYPES is set and it overrides Option.STANDARD_FORMATS. |
no automatic "format" values are being included. |
@@ -323,6 +323,15 @@ configBuilder.without(
As final step in the schema generation process, ensure all sub schemas containing keywords implying a particular "type" (e.g., "properties" implying an "object") have this "type" declared explicitly – this also affects the results from custom definitions. |
No additional "type" indication will be added for each sub schema, e.g. on the collected attributes where the "allOf" clean-up could not be applied or was disabled. |
+
+ 35 |
+ Option.STANDARD_FORMATS |
+
+
+ Same as Option.EXTRA_OPEN_API_FORMAT_VALUES but only for built-in supported "format" values ("date" , "time" , "date-time" , "duration" , "uuid" , "uri" ).
+ Only works if Option.ADDITIONAL_FIXED_TYPES is set and it is overriden by Option.EXTRA_OPEN_API_FORMAT_VALUES |
+ no automatic "format" values are being included. |
+
@@ -368,3 +377,4 @@ Below, you can find the lists of Option
s included/excluded in the r
| 32 | `PLAIN_DEFINITION_KEYS` | ⬜️ | ⬜️ | ⬜️ |
| 33 | `ALLOF_CLEANUP_AT_THE_END` | ✅ | ✅ | ✅ |
| 34 | `STRICT_TYPE_INFO` | ⬜️ | ⬜️ | ⬜️ |
+| 35 | `STANDARD_FORMATS` | ⬜️ | ⬜️ | ⬜️ |