FasterXML / FasterXML/jackson-module-jsonSchema

Instant serialized to wrong type

Ouverte
#121 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
387
Forks
136
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

# version

2.8

# Description

I have serialized the following entity :

```json
{
"createdDate": {
"nano": 326000000,
"epochSecond": 1484986332
},
"lastModifiedDate": null,
"createdById": null,
"lastModifiedById": null,
"active": true,
"login": "admin",
"roleList": [
"ROLE_MANAGER",
"ROLE_ADMIN"
],
"username": "admin",
"enabled": true,
"authorities": [
{
"authority": "ROLE_MANAGER"
},
{
"authority": "ROLE_ADMIN"
}
],
"accountNonLocked": true,
"credentialsNonExpired": true,
"accountNonExpired": true,
"new": false
}
```

And it's schema json :

```json
{
"title": "Manager",
"properties": {
"new": {
"title": "New",
"readOnly": true,
"type": "boolean"
},
"lastModifiedDate": {
"title": "Last modified date",
"readOnly": false,
"type": "string",
"format": "date-time",
"$ref": "#/definitions/instant"
},
"credentialsNonExpired": {
"title": "Credentials non expired",
"readOnly": true,
"type": "boolean"
},
"active": {
"title": "Active",
"readOnly": false,
"type": "boolean"
},
"login": {
"title": "Login",
"readOnly": false,
"type": "string"
},
"roleList": {
"title": "Role list",
"readOnly": false,
"type": "array",
"items": {
"type": "string"
}
},
"enabled": {
"title": "Enabled",
"readOnly": true,
"type": "boolean"
},
"authorities": {
"title": "Authorities",
"readOnly": true,
"type": "array",
"items": {
"type": "object"
}
},
"createdDate": {
"title": "Created date",
"readOnly": false,
"type": "string",
"format": "date-time",
"$ref": "#/definitions/instant"
},
"lastModifiedById": {
"title": "Last modified by id",
"readOnly": false,
"type": "integer"
},
"accountNonExpired": {
"title": "Account non expired",
"readOnly": true,
"type": "boolean"
},
"createdById": {
"title": "Created by id",
"readOnly": false,
"type": "integer"
},
"username": {
"title": "Username",
"readOnly": true,
"type": "string"
},
"accountNonLocked": {
"title": "Account non locked",
"readOnly": true,
"type": "boolean"
}
},
"definitions": {
"instant": {
"type": "string",
"properties": {
"nano": {
"title": "Nano",
"readOnly": true,
"type": "integer"
},
"epochSecond": {
"title": "Epoch second",
"readOnly": true,
"type": "integer"
}
}
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}
```

I have test on http://www.jsonschemavalidator.net/ :

```ruby
Found 2 error(s)
Message:
Invalid type. Expected String but got Object.
Schema path:
#/definitions/instant/type
Message:
Invalid type. Expected String but got Object.
Schema path:
#/definitions/instant/type
```

It appear jackson try to serialize a java `Instant` but the generated schema contain the wrong type "object" instead of "string"

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.