我正在尝试使用 Swagger-ui(swagger 2.0 版)编写 Open API 规范,但我不确定如何用POST
参数表示path
参数
POST /ping/{text}
我的规格如下,
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Mock API
description: Mock API
version: "1.0.0"
# the domain of the service
host: api.mock.com
# array of all schemes that your API supports
schemes:
- https
# will be prefixed to all paths
basePath: /v1
produces:
- application/json
paths:
/ping:
get:
summary: Ping
description: |
Respond to PING requests, similar to heart beat
parameters:
- name: path
in: path
description: String input for echo service
required: false
type: string
tags:
- ping
responses:
200:
description: The text passed in the request
schema:
type: string
default:
description: Empty response for request passed
schema:
type: string
并且招摇 ui 显示错误如下 -
code: "ONE_OF_MISSING"
message: "Not a valid parameter definition"
但如果我将其更改为in: query
错误消失。我究竟做错了什么?或者在开放 API 规范中指定路径参数的正确方法是什么?