我试图根据以下定义在SwaggerHub模拟POST请求:
post:
summary: "Creates order"
description: ""
consumes:
- application/json
parameters:
- name: "order"
in: body
description: "New order"
schema:
$ref: "#/definitions/Order"
responses:
201:
description: "Order succesfully created."
400:
description: "Order can't be created"模型被定义为:
definitions:
Order:
type: object
properties:
id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
marketPair:
type: integer
format: "int64"
example: "BTC_TRY"
amount:
type: number
format: "int64"
example: "1.3"
price:
type: integer
format: "int32"
example: "467"
operationType:
type: string
description: "Type of operation"
enum:
- "buy"
- "sell"
example: "buy"
orderType:
type: string
description: "Order Type"
enum:
- "limit"
- "market"
- "stop"
default: "limit"
example: "limit"
xml:
name: "Order"每次我试图发布带有缺失字段甚至没有JSON的坏JSON时,我仍然收到201代码,这绝对不应该是201。
我的配置中是否缺少了什么,或者SwaggerHub需要哪些更改来识别我的规范并开始检查有效负载是否符合这个端点的规范要求?
发布于 2018-05-28 15:35:37
模拟不以任何方式验证输入。它只是从那些为操作定义的HTTP状态代码中返回最低的HTTP状态代码--在您的示例中,状态201。
请注意,模拟不支持业务逻辑,也就是说,它不能根据输入发送特定的响应。 ..。 模拟根据其响应和规范中定义的响应媒体类型为每个API操作生成静态响应。 如果一个操作有多个响应代码,则模拟以最低状态代码返回响应。例如,如果操作具有响应201、202和400,则模拟返回201响应。
您可能需要使用SwaggerHub devs提交一个特性请求。
https://stackoverflow.com/questions/50569368
复制相似问题