Is there a way to convert OpenAPI specifications to json mappings in maven?

一笑奈何 提交于 2019-12-11 10:03:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!