@Test public void supportsDefaultTimestampFormat() { TimestampShape shape = TimestampShape.builder().id("smithy.example#Timestamp").build(); JsonSchemaConfig config = new JsonSchemaConfig(); config.setDefaultTimestampFormat(TimestampFormatTrait.Format.DATE_TIME); Schema schema = new TimestampMapper().updateSchema(shape, Schema.builder(), config).build(); assertThat(schema.getType().get(), equalTo("string")); assertThat(schema.getFormat().get(), equalTo("date-time")); }
@Override public Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config) { String format = extractTimestampFormat(shape, config); if (format == null) { return builder; } switch (format) { case TimestampFormatTrait.DATE_TIME: return builder.type("string").format(format); case TimestampFormatTrait.HTTP_DATE: return builder.type("string"); case TimestampFormatTrait.EPOCH_SECONDS: return builder.format(null).type("number"); default: return format.startsWith("epoch-") ? builder.type("number") : builder.type("string"); } }
TimestampMapper implements JsonSchemaMapper { @Override public Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config) { String format = extractTimestampFormat(shape, config); if (format == null) { return builder; } switch (format) { case TimestampFormatTrait.DATE_TIME: return builder.type("string").format(format); case TimestampFormatTrait.HTTP_DATE: return builder.type("string"); case TimestampFormatTrait.EPOCH_SECONDS: return builder.format(null).type("number"); default: return format.startsWith("epoch-") ? builder.type("number") : builder.type("string"); } } }
TimestampMapper implements JsonSchemaMapper { @Override public Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config) { String format = extractTimestampFormat(shape, config); if (format == null) { return builder; } switch (format) { case TimestampFormatTrait.DATE_TIME: return builder.type("string").format(format); case TimestampFormatTrait.HTTP_DATE: return builder.type("string"); case TimestampFormatTrait.EPOCH_SECONDS: return builder.format(null).type("number"); default: return format.startsWith("epoch-") ? builder.type("number") : builder.type("string"); } }  }
TimestampMapper implements JsonSchemaMapper { @Override public Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config) { String format = extractTimestampFormat(shape, config); if (format == null) { return builder; } switch (format) { case TimestampFormatTrait.DATE_TIME: return builder.type("string").format(format); case TimestampFormatTrait.HTTP_DATE: return builder.type("string"); case TimestampFormatTrait.EPOCH_SECONDS: return builder.format(null).type("number"); default: return format.startsWith("epoch-") ? builder.type("number") : builder.type("string"); } }  @Override byte getOrder(); @Override Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config); }
TimestampMapper implements JsonSchemaMapper { @Override public Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config) { String format = extractTimestampFormat(shape, config); if (format == null) { return builder; } switch (format) { case TimestampFormatTrait.DATE_TIME: return builder.type("string").format(format); case TimestampFormatTrait.HTTP_DATE: return builder.type("string"); case TimestampFormatTrait.EPOCH_SECONDS: return builder.format(null).type("number"); default: return format.startsWith("epoch-") ? builder.type("number") : builder.type("string"); } }  @Override byte getOrder(); @Override Schema.Builder updateSchema(Shape shape, Schema.Builder builder, JsonSchemaConfig config);  }