本文介绍了如何在YAML Swagger定义中将属性类型定义为字符串列表(列表,集合,数组,集合)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为API编写一个庞大的定义文件。该API适用于GET请求
I am writing a swagger definition file for an API. The API is a for a GET request
/path/to/my/api:
get:
summary: My Custom API
description: |
Gets a List of FooBar IDs
produces:
- application/json
tags:
- FooBar
responses:
"200":
description: successful operation
schema:
$ref: "#/definitions/MyCustomType"
...
MyCustomType:
type: object
properties:
myCustomObject
type: ??? # list of string?
推荐答案
对于字符串列表,可以描述如下:
For a list of strings, you can describe as follows:
type: array
items:
type: string
参考:
示例:
- (OpenAPI v2)
- (OpenAPI v3)
- https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml#L93-L100 (OpenAPI v2)
- https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml#L71-L78 (OpenAPI v3)
这篇关于如何在YAML Swagger定义中将属性类型定义为字符串列表(列表,集合,数组,集合)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!