FasterXML / FasterXML/jackson-module-jsonSchema

JsonFormat not supported?

Open
#133 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
387
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Entity:

```java
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:

```java
ObjectMapper objectMapper = new ObjectMapper();
.registerModule(new JavaTimeModule());

JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator(objectMapper);
JsonNode jsonSchema = jsonSchemaGenerator.generateJsonSchema(Wound.class);
String jsonSchemaAsString = objectMapper.writeValueAsString(jsonSchema);
```

```json
"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:

```json
"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**:

```json
"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"
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.