Код: Выделить всё
var type = ...; // e.g. List
var settings = new SystemTextJsonSchemaGeneratorSettings()
{
SchemaType = SchemaType.OpenApi3,
};
var schema = JsonSchema.FromType(type, settings);
document.Components.Schemas.Add(key, schema);
Код: Выделить всё
"components": {
"schemas": {
"ListOfUser": {
"title": "ListOfUser",
"type": "array",
"items": {
"$ref": "#/components/schemas/ListOfUser/definitions/User"
},
"definitions": {
"User": {
"type": "object",
"additionalProperties": false,
"properties": {
"ID": {
"type": "integer",
"format": "int32"
},
"Name": {
"type": "string"
}
}
}
}
}
}
},
Код: Выделить всё
Structural error at components.schemas.ListOfUser
should NOT have additional properties
additionalProperty: definitions
Jump to line 30
Нужно ли мне самому создавать две записи и вручную корректировать запись списка, чтобы это работало?
Подробнее здесь: https://stackoverflow.com/questions/790 ... with-nswag
Мобильная версия