相关疑难解决方法(0)

要求数组在Swagger架构对象定义中包含至少一个元素

我在我的模式中有这样的模式对象定义swagger.yaml:

User:
  type: object
  properties:
    username:
      type: string
      description: the user name
    colors:
      type: array
      items: {
        type: string,
        enum: [ "red", "blue", "green" ]
      }
      description: user must have one or more colors associated
  required:
    - username
    - colors
Run Code Online (Sandbox Code Playgroud)

但是,生成的服务器仍然很乐意接受使用此架构对象的POST请求作为不包含任何colors字段的必需body参数.

我是否可以在模式对象中color始终需要字段的方式配置Swagger,User理想情况下还必须包含枚举中的至少一个或多个项目?

rest swagger swagger-2.0

11
推荐指数
1
解决办法
5692
查看次数

如何在我的YAML Swagger定义中将属性类型定义为字符串的列表(列表,集合,数组,集合)

我正在为API编写一个昂首阔步的定义文件.API是用于GET请求的

/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"         
Run Code Online (Sandbox Code Playgroud)

...

MyCustomType:
  type: object
  properties: 
    myCustomObject
      type: ??? # list of string?
Run Code Online (Sandbox Code Playgroud)

collections yaml swagger

8
推荐指数
1
解决办法
9668
查看次数

标签 统计

swagger ×2

collections ×1

rest ×1

swagger-2.0 ×1

yaml ×1