3
我想從自定義對象中創建一個模式。自定義對象具有一些字符串屬性,這些屬性的模式化類型爲String|Null
。如何修改JSonSchemaGenerator
以將字符串轉換爲String
而不是String|Null
? 換句話說,如果我序列化Jsonschema我don'w想這樣的:JsonSchemaGenerator字符串的自定義ContractResolver
{
"title":"myObject",
"type":"object",
"properties":{
"ID":{
"required":true,
"type":["string","null"]
}
}
}
但這:
{
"title":"myObject",
"type":"object",
"properties":{
"ID":{
"required":true,
"type":"string"
}
}
}
所有字符串都默認爲空的。非空字符串不存在於C#中 – rwisch45
當然,但我們正在討論json模式,而不是c#。在jsonSchema你不會被強迫這樣:' 「顏色」:{ 「需要」:真實, 「類型」: 「串」, 「空」 ] }',你可以有這個'」顏色「:{ 」required「:true, 」type「:」string「 },' –