Мы работаем с сервисом Do tnet Core 2.2, используя ServiceStack 5.7, и нам нужно его ограничить. Поэтому мы хотим поместить его за Azure Api Management Gateway (apim) - он работает в Azure службе приложений.
Мы включили функцию OpenApi, используя
self .Plugins.Add (new OpenApiFeature ());
Когда мы экспортируем наше определение OpenApi, мы получаем следующее:
"paths": {
...
"/api/search": {
"post": {
"tags": [
"api"
],
"operationId": "SearchRequestsearch_Post",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "Filters",
"in": "formData",
"type": "array",
"items": {
"$ref": "#/definitions/FilterDto"
},
"collectionFormat": "multi",
"required": false
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/SearchResponse"
}
}
},
"deprecated": false,
"security": [
{
"Bearer": []
}
]
},
"parameters": [
{
"$ref": "#/parameters/Accept"
}
]
}
}
...
"definitions": {
"FilterDto": {
"title": "FilterDto",
"properties": {
"Field": {
"description": "The field to filter on",
"type": "string",
"enum": [
"None",
"DestinationName",
"DocumentId"
]
},
"Values": {
type": "array",
"items": {
"type": "string"
}
},
"Type": {
"type": "string",
"enum": [
"Equals",
"NotEquals",
"RangeNumeric",
"RangeDate"
]
}
},
"description": "FilterDto",
"type": "object"
}
...
}
Проблема в том, что он не поддерживается, чтобы иметь параметр с массивом типа (определенный в # / definitions / FilterDto). И происходит сбой с: Ошибка синтаксического анализа (-ов): JSON действителен без схем из 'oneOf'. Path 'paths [' / api / search ']. Post.parameters [1]', строка 1, позиция 666. Ошибка синтаксического анализа: входной файл OpenAPI недопустим для спецификаций OpenAPI https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md (схема https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json).
В портале Azure.
В c# (ServiceStack) мы определили следующее:
public class SearchRequest : SearchRequestBase, IReturn<SearchResponse>
{
public SearchRequest()
{
Filters = new List<FilterDto>();
}
[ApiMember(Name = "Filters"]
public List<FilterDto> Filters { get; set; }
}
public class FilterDto
{
[ApiMember(Name = "Field"]
[ApiAllowableValues("Field", typeof(FilterAndFacetField))]
public FilterAndFacetField Field { get; set; }
[ApiMember(Name = "Values")]
public List<string> Values { get; set; }
[ApiMember(Name = "Type")]
[ApiAllowableValues("Type", typeof(FilterType))]
public FilterType Type { get; set; }
public FilterDto()
{
Values = new List<string>();
}
}
Кому-нибудь удалось успешно импортировать OpenApi с использованием массива $ ref в параметрах из ServiceStack в Api Management?