We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity:
public class Wound { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "UTC") @JsonProperty("createdAt") @JsonPropertyDescription("A date time object w/o timezone.") @NotNull private LocalDateTime createdAt; }
When I generate with JavaTimeModule(), I get an array of integer in the json schema:
JavaTimeModule()
ObjectMapper objectMapper = new ObjectMapper(); .registerModule(new JavaTimeModule()); JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator(objectMapper); JsonNode jsonSchema = jsonSchemaGenerator.generateJsonSchema(Wound.class); String jsonSchemaAsString = objectMapper.writeValueAsString(jsonSchema);
"createdAt": { "type": "array", "items": { "type": "integer" }, "description": "A date time object w/o timezone." }
When I omit the JavaTimeModule, I a get a LocalDateTimeObject with Java members:
JavaTimeModule
"LocalDateTime": { "type": "object", "additionalProperties": false, "properties": { "dayOfYear": { "type": "integer" }, "dayOfWeek": { "type": "string", "enum": [ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY" ] }, "year": { "type": "integer" }, ...
EXPECTED RESULT:
"dateTime": { "description": "A date time object w/o timezone.", "type": "string", "format": "date-time", "javaType": "java.time.LocalDateTime", "customDateTimePattern" : "yyyy-MM-dd'T'HH:mm:ss" }
The text was updated successfully, but these errors were encountered:
I am having the same issue. I am pretty new to the schema generation but have been trying to get java.util.Date to be formatted with this annotation:
java.util.Date
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "UTC") @JsonSchema( description = "When the contact address is valid from", required = true) private Date effectiveFrom;
Right now I am trying to use the addon module instead and then set it like this instead:
@JsonSchema( description = "When the contact address is valid to", required = false, format=TypeFormat.DATE_TIME) private Date effectiveTo;
However I am not sure it solves your more advanced example :) and I am not sure if it will be strict enough for our schemas to be honest
Sorry, something went wrong.
No branches or pull requests
Entity:
When I generate with
JavaTimeModule()
, I get an array of integer in the json schema:When I omit the
JavaTimeModule
, I a get a LocalDateTimeObject with Java members:EXPECTED RESULT:
The text was updated successfully, but these errors were encountered: