问题
I need to convert OpenAPI specifications into json mappings so I could use them in my wiremock server, but I'm not sure if there is an available plugin to do this type of conversion.
This is an example of an OpenAPI I'm using
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
And this is the json output I would like to have
{
"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"
}
}
来源:https://stackoverflow.com/questions/57036547/is-there-a-way-to-convert-openapi-specifications-to-json-mappings-in-maven