2

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"
                    }
                }
Linda Naoui
  • 117
  • 10
  • Could you clarify what you mean by "json mappings"? E.g. add a snippet of your OpenAPI definition and the JSON you want to get. – Helen Jul 15 '19 at 10:12
  • Also check out [Swagger mock server](https://stackoverflow.com/q/38344711/113116) – Helen Jul 15 '19 at 10:35
  • I just added an example in my description, when I say mapping I mean that I don't want a simple conversion from yaml to json but a conversion from an OpenAPI specification to a json file. – Linda Naoui Jul 15 '19 at 12:47
  • 1
    Maybe you could use https://github.com/Masabi/swagwire ? – Stef Heyenrath Jul 17 '19 at 07:59

0 Answers0