我需要将OpenAPI规范转换为json映射,以便可以在Wiremock服务器中使用它们,但是我不确定是否有可用的插件来进行这种类型的转换。
这是我正在使用的OpenAPI的示例
openapi: "3.0.0"
paths:
/fraudcheck:
put:
summary: Perform Fraud Check
x-contracts:
- contractId: 1
name: Should Mark Client as Fraud
priority: 1
requestBody:
content:
application/json:
schema:
type: object
properties:
"client.id":
type: integer
loanAmount:
type: integer
x-contracts:
- contractId: 1
headers:
Content-Type: application/json
body:
"client.id": 1234567890
loanAmount: 99999
matchers:
body:
- path: $.['client.id']
type: by_regex
value: "[0-9]{10}"
responses:
'200':
description: created ok
content:
application/json:
schema:
type: object
properties:
fraudCheckStatus:
type: string
"rejection.reason":
type: string
这是我想要的json输出
{
"id" : "d5966bb3-554e-4b83-b18b-77ca22e2a439",
"request" : {
"url" : "/fraudcheck",
"method" : "PUT",
"headers" : {
"Content-Type" : {
"equalTo" : "application/json"
}
},
"response" : {
"status" : 200,
"body" : "{\"fraudCheckStatus\":\"FRAUD\",\"rejection.reason\":\"Amount too high\"}",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
}
}