type TestRecord = { Example: Choice<string, int> }
This generates the following crazy schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "TestRecord",
"type": "object",
"additionalProperties": false,
"properties": {
"example": {
"$ref": "#/definitions/FSharpChoiceOfStringAndInteger"
}
},
"definitions": {
"FSharpChoiceOfStringAndInteger": {
"definitions": {
"Choice1Of2": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"item"
],
"properties": {
"kind": {
"type": "string",
"default": "Choice1Of2",
"x-enumNames": [
"Choice1Of2"
],
"enum": [
"Choice1Of2"
]
},
"item": {
"type": "string"
}
}
},
"Choice2Of2": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"item"
],
"properties": {
"kind": {
"type": "string",
"default": "Choice2Of2",
"x-enumNames": [
"Choice2Of2"
],
"enum": [
"Choice2Of2"
]
},
"item": {
"type": "integer",
"format": "int32"
}
}
}
},
"anyOf": [
{
"$ref": "#/definitions/FSharpChoiceOfStringAndInteger/definitions/Choice1Of2"
},
{
"$ref": "#/definitions/FSharpChoiceOfStringAndInteger/definitions/Choice2Of2"
}
]
}
}
}
But the expected output should be:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "TestRecord",
"type": "object",
"additionalProperties": false,
"properties": {
"example": {
"type": [
"integer",
"string"
]
}
}
}
F# 7.0, .NET 7.0, FSharp.Data.JsonSchema 2.0.2
This generates the following crazy schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "TestRecord", "type": "object", "additionalProperties": false, "properties": { "example": { "$ref": "#/definitions/FSharpChoiceOfStringAndInteger" } }, "definitions": { "FSharpChoiceOfStringAndInteger": { "definitions": { "Choice1Of2": { "type": "object", "additionalProperties": false, "required": [ "kind", "item" ], "properties": { "kind": { "type": "string", "default": "Choice1Of2", "x-enumNames": [ "Choice1Of2" ], "enum": [ "Choice1Of2" ] }, "item": { "type": "string" } } }, "Choice2Of2": { "type": "object", "additionalProperties": false, "required": [ "kind", "item" ], "properties": { "kind": { "type": "string", "default": "Choice2Of2", "x-enumNames": [ "Choice2Of2" ], "enum": [ "Choice2Of2" ] }, "item": { "type": "integer", "format": "int32" } } } }, "anyOf": [ { "$ref": "#/definitions/FSharpChoiceOfStringAndInteger/definitions/Choice1Of2" }, { "$ref": "#/definitions/FSharpChoiceOfStringAndInteger/definitions/Choice2Of2" } ] } } }But the expected output should be:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "TestRecord", "type": "object", "additionalProperties": false, "properties": { "example": { "type": [ "integer", "string" ] } } }F# 7.0, .NET 7.0, FSharp.Data.JsonSchema 2.0.2