JSON .Net generates schema incorrectly (type as an array)

asp.net-mvc, asp.net-web-api, json, json.net, jsonschema

Solution

It is not an array of strings, it is a nullable string.

`{ "type": [ "string", "null" ] }` means that a valus is either a string or null. Array of strings would be `{ "type": "array", "items": { "type": "string" } }`

Problem

When using the JSON.Net JsonSchemaGenerator to generate JSON Schema for my object: ``` Public Class Host Public Property uid() As String End Class ``` It generates the type property as an array of strings: ``` { "type": "object", "properties": { "uid": { "required": true, "type": [ "string", "null" ] } } } ``` The proper JSON Schema should be: ``` { "type": "object", "properties": { "uid": { "required": true, "type": "string" } } } ``` Has anyone seen this before?

Original source

Related problems