似乎几乎拥有它......
试图让swagger在请求体中发送匿名参数哈希值。
我有一个匿名哈希,其中包含一个名为list的键,其中包含一个数组。
尝试发送此参数(text / json):
{
list : [ 'string1', 'string2' ]
}
Swagger正在构建正确的curl语句,但不是通过UI发送参数。
Swagger构建它(从命令行工作):
/usr/bin/curl -H 'Content-Type: text/json' -X GET -d '{ "list" : [ "text:/export/home/ihome/perl5/our_modules/check_parse_lib_rest/t/data/hosts:/export/home/ihome/perl5/our_modules/check_parse_lib_rest/t/data/hosts", "text:/export/home/ihome/perl5/our_modules/check_parse_lib_rest/t/data/hosts:/export/home/ihome/perl5/our_modules/check_parse_lib_rest/t/data/hosts.1" ] }' 'https://localhost.localdomain:9086/library/check_diff_batch'
但Swagger-ui没有显示模型示例,也没有在请求体中发送任何参数。
在编辑器中,我看到列表显示为未定义。
Schema
⇄
Comparison {
list:
ComparisonList undefined *
}
定义 -
paths:
/check_diff_batch:
get:
summary: Compare a list of file comparrison objects using diff.
description: |
FIXME: Takes an array of colon delimited comparrison objects.
Required parameter Comparrison object format = type:file1:file2
**RC** will return false if there are differences or a failure.
**FAULT_MSG** will return No Faults or a failure message.
parameters:
- $ref: "#/parameters/ComparrisonList"
responses:
200:
description: Successful response
examples:
text/json:
...
parameters:
ComparrisonList:
name: list
in: body
description: List of comparrison objects
schema:
$ref: "#/definitions/Comparisons"
definitions:
Comparisons:
required:
- list
properties:
list:
$ref: "#/definitions/ComparisonList"
ComparisonList:
additionalProperties:
type: string
答案 0 :(得分:0)
additionalProperties
用于定义关联数组/散列映射,而不是常规数组。常规字符串数组定义为:
definitions:
ComparisonList:
type: array
items:
type: string
您还应该使用post
操作,而不是get
,因为请求正文在does not have defined semantics内符合RFC 7231 section 4.3.1。