Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使requestBody属性在OpenAPI中成为可选属性?_Python_Swagger_Openapi_Swagger Editor - Fatal编程技术网

Python 如何使requestBody属性在OpenAPI中成为可选属性?

Python 如何使requestBody属性在OpenAPI中成为可选属性?,python,swagger,openapi,swagger-editor,Python,Swagger,Openapi,Swagger Editor,我在python flask中实现了一个OpenAPI3 POST方法,其请求体如下: /DoSomething: post: operationId: postDoSomething requestBody: content: application/json: schema: $ref: '#/components/schemas/MyBody' required: true compo

我在python flask中实现了一个OpenAPI3 POST方法,其请求体如下:

/DoSomething:
  post:
    operationId: postDoSomething
    requestBody:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MyBody'
      required: true

components:
  schemas:

    MyBody:
      type: object
        properties:
          Images:
            type: array
            items:
              $ref: '#/components/schemas/Image'
          Ids:
            type: array
            items:
              $ref: '#/components/schemas/Ids'
          Date:
            type: string
            format: date-time
我需要属性(图像、ID、日期)作为可选参数

例如,当我从一个C#应用程序将Images数组设置为null时,我在服务器上得到以下错误

validation error: None is not of type 'array'

如何使参数可选?

默认情况下,它们是可选的。请张贴您的C#代码。如Helen所示,它们是可选的。问题似乎是,正如您所说,您将图像数组作为null传递。而是一起排除图像数组。如果您有非可选的参数,则应指出它们是必需的。