如何在OpenAPI3.0的参数中定义自由形式对象

2024-09-28 20:44:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图为OpenAPI编写配置,以解决如下请求: http://127.0.0.1:5000/api/v1/statistics?stratifications=color,blue,bodytype,normalhttp://127.0.0.1:5000/api/v1/statistics?stratifications=color,blue,bodytype,normal,height,170 或者只是 http://127.0.0.1:5000/api/v1/statistics?stratifications=color,grey

进入将传递给我的函数的对象。这是我在配置中写的内容:

    get:
      tags: [statistics]
      operationId: api.v1.statistics.endpoints.get_statistics
      {% if not disable_security %}
      security:
        - jwt: [statistics]
        {% endif %}

      parameters:
        - in: query
          name: stratifications
          description: Stratifications of statistic
          schema:
            type: object
          style: form
          explode: false

但这导致了

is not of type 'object'

jsonschema中出现错误,因为jsonschema需要字典,而需要字符串color,blue,bodytype,normal,height,170。有没有办法在那里添加编码器?我认为风格定义编码器,但似乎不是这样


Tags: ofapihttpgettypenotbluecolor