【问题标题】:OpenAPI definition error with required path parameter带有所需路径参数的 OpenAPI 定义错误
【发布时间】:2018-09-17 15:18:15
【问题描述】:

我刚刚开始创建我的第一个 OpenAPI 定义(2.0 版),我一直被这个错误困扰:

OpenAPI 文件无效。请修复架构错误:\n\"/parameters/categoryParam\": domain: validation;关键字:oneOf;消息:实例与一个模式不完全匹配;匹配:0"

这只是一个像“/cat/count”这样的查询,它会返回一个整数,表示有多少只猫——“cat”是必需的路径参数。我这里的参数定义到底有什么问题?

swagger: '2.0'
info:
  description: "xxx"
  title: "xxx"
  version: "1.0.0"
host: "xxx"
consumes:
- "application/json"
produces:
- "application/json"
schemes:
- "https"
parameters:
  categoryParam:
    in: path
    name: category
    required: true
    schema:
      type: string
    description: "xxx"
paths:
  "/{category}/count":
    get:
      operationId: "get_category_count"
      parameters:
        - $ref: "#/parameters/categoryParam"
      produces:
        - application/json
      responses:
        '200':
          description: "xxx"
          schema:
            $ref: '#/definitions/Model0'
definitions:
  Model0:
    properties:
      count:
        type: string

【问题讨论】:

    标签: swagger swagger-2.0 openapi


    【解决方案1】:

    没关系,愚蠢的错误。我需要改变:

    schema:
      type: string
    

    只是:

    type: string
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-19
      • 2020-09-25
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 2016-05-01
      • 1970-01-01
      相关资源
      最近更新 更多