During implementation of yaml to json converter for swagger schema I was faced with the problem: default setup of deserialization builder
var deserializer = new DeserializerBuilder().Build()
cannot recognize 'integer', 'boolean' types. The deserializer converts those types to strings. For ex: i have yaml:
EntityId:
type: integer
example: 1245
EntityIds:
type: array
items:
$ref: EntityId
example: [152, 6542, 23]
The result of conversion is:
"EntityId":{
"type":"integer",
"example":"1245"
},
"EntityIds":{
"type":"array",
"items":{
"$ref":"EntityId"
},
"example":[ "152","6542","23"]
}
but if I put input yaml to any of the online converters I get correct json result:
"EntityId": {
"type": "integer",
"example": 1245
},
"EntityIds": {
"type": "array",
"items": {
"$ref": "EntityId"
},
"example": [
152,
6542,
23
]
}
also behavior for Boolean types.
The question is how to set up the deserializer for proper conversion.
Currently, this is not supported by YamlDotNet. There is work in progress to support schemas, which would enable this, but it is not yet complete.