【发布时间】: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