RicoSuter/NJsonSchema
Voir sur GitHubRecursive refs on JSON Schema from JSON example
Open
#1 252 ouverte le 22 sept. 2020
help wantedtype: bugtype: enhancement
Métriques du dépôt
- Stars
- (1 578 stars)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
Hi! The JSON
{
"Publications": [{
"Author": {
"Name": "Joaquin Phoenix",
"FullInfo": {
"Name": "Joaquin Phoenix"
}
},
"Collaborator": {
"Name": "Robert DeNiro",
"FullInfo": {
"Name": "Robert DeNiro"
}
}
}
]
}
when run by the code
var schema = JsonSchema.FromSampleJson(data); var json = schema.ToJson();
generates schema with self-referencial refs:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"Publications": {
"type": "array",
"items": {
"$ref": "#/definitions/Publication"
}
}
},
"definitions": {
"Author": {
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"FullInfo": {
"$ref": "#/definitions/Author"
}
}
},
"Publication": {
"type": "object",
"properties": {
"Author": {
"$ref": "#/definitions/Author"
},
"Collaborator": {
"$ref": "#/definitions/Author"
}
}
}
}
}