Swagger/OpenAPI conversion endpoint in Admin API #504

Closed
opened 2025-12-29 15:25:31 +01:00 by adam · 8 comments
Owner

Originally created by @laslanian on GitHub (Mar 24, 2023).

Originally assigned to: @StefH on GitHub.

Hello, first off I'd like to thank everyone who contributed to the making of WireMock.Net!

I was wondering if it would be possible, and what would be the best way, to expose some of the OpenAPIParser methods in the Admin API?
The goal is to be able to submit a POST request to the Admin API containing Swagger/OpenAPI within the body, and receive back the converted WireMock mappings in the response.

Originally created by @laslanian on GitHub (Mar 24, 2023). Originally assigned to: @StefH on GitHub. Hello, first off I'd like to thank everyone who contributed to the making of WireMock.Net! I was wondering if it would be possible, and what would be the best way, to expose some of the OpenAPIParser methods in the Admin API? The goal is to be able to submit a POST request to the Admin API containing Swagger/OpenAPI within the body, and receive back the converted WireMock mappings in the response.
adam added the question label 2025-12-29 15:25:31 +01:00
adam closed this issue 2025-12-29 15:25:31 +01:00
Author
Owner

@StefH commented on GitHub (Mar 26, 2023):

The logic for parsing an swagger/openapi document to a wiremock.net mapping is done via the WireMock.Net.OpenApiParser NuGet.

And because this NuGet does not support all frameworks used in WireMock.Net, this is a separate package.

However, there are some extension methods which can you use:
https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net.OpenApiParser/Extensions/WireMockServerExtensions.cs

Note that this is not exactly what you ask, you want an API Admin endpoint to convert Swagger/OpenAPI and get back the mappings.

I'll take a look if that can be added.

@StefH commented on GitHub (Mar 26, 2023): The logic for parsing an swagger/openapi document to a wiremock.net mapping is done via the **WireMock.Net.OpenApiParser** NuGet. And because this NuGet does not support all frameworks used in WireMock.Net, this is a separate package. However, there are some extension methods which can you use: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net.OpenApiParser/Extensions/WireMockServerExtensions.cs Note that this is not exactly what you ask, you want an API Admin endpoint to convert Swagger/OpenAPI and get back the mappings. I'll take a look if that can be added.
Author
Owner

@StefH commented on GitHub (Mar 28, 2023):

@laslanian

I've create a preview version (1.5.21-ci-17268) (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions) which you can use to convert an openapi/swagger document to mappings.

  1. Do a POST to /__admin/openapi/convert to convert a openapi/swagger document to mappings (the mappings are only returned)

  2. Do a POST to /__admin/openapi/save to convert a openapi/swagger document to mappings + save the mappings in WireMock Server

@StefH commented on GitHub (Mar 28, 2023): @laslanian I've create a preview version (1.5.21-ci-17268) (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions) which you can use to convert an openapi/swagger document to mappings. 1. Do a POST to `/__admin/openapi/convert` to convert a openapi/swagger document to mappings (the mappings are only returned) 2. Do a POST to `/__admin/openapi/save` to convert a openapi/swagger document to mappings + save the mappings in WireMock Server
Author
Owner

@laslanian commented on GitHub (Mar 28, 2023):

@StefH Thank you so much for such a quick turnaround on this! To be honest I was not expecting this to be added in, but thank you for that. I will try this out and let you know how it went.

@laslanian commented on GitHub (Mar 28, 2023): @StefH Thank you so much for such a quick turnaround on this! To be honest I was not expecting this to be added in, but thank you for that. I will try this out and let you know how it went.
Author
Owner

@laslanian commented on GitHub (Mar 29, 2023):

@StefH The endpoints are working as expected with __admin/openapi/convert returning the mapping, and __admin/openapi/save persisting it to WireMock instance.

I did notice an inconsistency with the returned mappings.

The new endpoint (__admin/openapi/convert) returns the mappings in a different format than the existing __admin/mappings endpoint, which is also different than the mappings used in WireMock Java version (WireMock.org) as seen below.

Due to this inconsistency, importing the converted mappings into the Java version has many issues. Would it be possible to align these formats? I would be happy to contribute my time to working on this if there is initiative on this subject.

Original Swagger Json

{
	"swagger": "2.0",
	"info": {
		"version": "1.0.0",
		"title": "Swagger Petstore",
		"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
		"termsOfService": "http://swagger.io/terms/",
		"contact": {
			"name": "Swagger API Team"
		},
		"license": {
			"name": "MIT"
		}
	},
	"host": "petstore.swagger.io",
	"basePath": "/api",
	"schemes": ["http"],
	"consumes": ["application/json"],
	"produces": ["application/json"],
	"paths": {
		"/pets": {
			"get": {
				"description": "Returns all pets from the system that the user has access to",
				"operationId": "findPets",
				"produces": ["application/json", "application/xml", "text/xml", "text/html"],
				"parameters": [{
					"name": "tags",
					"in": "query",
					"description": "tags to filter by",
					"required": false,
					"type": "array",
					"items": {
						"type": "string"
					},
					"collectionFormat": "csv"
				}, {
					"name": "limit",
					"in": "query",
					"description": "maximum number of results to return",
					"required": false,
					"type": "integer",
					"format": "int32"
				}],
				"responses": {
					"200": {
						"description": "pet response",
						"schema": {
							"example": [{
								"name": "MEXAMPLE",
								"tag": "MEXAMPLE",
								"id": 9988
							}, {
								"name": "OtherExample",
								"tag": "OtherExample",
								"id": 8877
							}],
							"type": "array",
							"items": {
								"$ref": "#/definitions/Pet"
							}
						}
					},
					"default": {
						"description": "unexpected error",
						"schema": {
							"$ref": "#/definitions/ErrorModel"
						}
					}
				}
			},
			"post": {
				"description": "Creates a new pet in the store.  Duplicates are allowed",
				"operationId": "addPet",
				"produces": ["application/json"],
				"parameters": [{
					"name": "pet",
					"in": "body",
					"description": "Pet to add to the store",
					"required": true,
					"schema": {
						"$ref": "#/definitions/NewPet"
					}
				}],
				"responses": {
					"200": {
						"description": "pet response",
						"schema": {
							"$ref": "#/definitions/Pet"
						}
					},
					"default": {
						"description": "unexpected error",
						"schema": {
							"$ref": "#/definitions/ErrorModel"
						}
					}
				}
			}
		},
		"/pet": {
			"get": {
				"description": "Returns a pet from the system that the user has access to",
				"operationId": "findPet",
				"produces": ["application/json", "application/xml", "text/xml", "text/html"],
				"parameters": [{
					"name": "tags",
					"in": "query",
					"description": "tags to filter by",
					"required": false,
					"type": "array",
					"items": {
						"type": "string"
					},
					"collectionFormat": "csv"
				}, {
					"name": "limit",
					"in": "query",
					"description": "maximum number of results to return",
					"required": false,
					"type": "integer",
					"format": "int32"
				}],
				"responses": {
					"200": {
						"description": "pet response",
						"schema": {
							"$ref": "#/definitions/Pet"
						}
					},
					"default": {
						"description": "unexpected error",
						"schema": {
							"$ref": "#/definitions/ErrorModel"
						}
					}
				}
			}
		},
		"/pets/{id}": {
			"get": {
				"description": "Returns a user based on a single ID, if the user does not have access to the pet",
				"operationId": "findPetById",
				"produces": ["application/json", "application/xml", "text/xml", "text/html"],
				"parameters": [{
					"name": "id",
					"in": "path",
					"description": "ID of pet to fetch",
					"required": true,
					"type": "integer",
					"format": "int64"
				}],
				"responses": {
					"200": {
						"description": "pet response",
						"schema": {
							"$ref": "#/definitions/Pet"
						}
					},
					"default": {
						"description": "unexpected error",
						"schema": {
							"$ref": "#/definitions/ErrorModel"
						}
					}
				}
			},
			"delete": {
				"description": "deletes a single pet based on the ID supplied",
				"operationId": "deletePet",
				"parameters": [{
					"name": "id",
					"in": "path",
					"description": "ID of pet to delete",
					"required": true,
					"type": "integer",
					"format": "int64"
				}],
				"responses": {
					"204": {
						"description": "pet deleted"
					},
					"default": {
						"description": "unexpected error",
						"schema": {
							"$ref": "#/definitions/ErrorModel"
						}
					}
				}
			}
		}
	},
	"definitions": {
		"Pet": {
			"type": "object",
			"allOf": [{
				"$ref": "#/definitions/NewPet"
			}, {
				"required": ["id"],
				"properties": {
					"id": {
						"type": "integer",
						"format": "int64"
					}
				}
			}]
		},
		"NewPet": {
			"type": "object",
			"required": ["name"],
			"properties": {
				"name": {
					"type": "string"
				},
				"tag": {
					"type": "string"
				}
			}
		},
		"ErrorModel": {
			"type": "object",
			"required": ["code", "message"],
			"properties": {
				"code": {
					"type": "integer",
					"format": "int32"
				},
				"message": {
					"type": "string"
				}
			}
		}
	}
}

WireMock.Net Mapping (POST __admin/openapi/convert)

[
    {
        "Guid": "04ceff4c-da4a-440d-affa-22b0adb1158a",
        "Request": {
            "Path": "/api/pets",
            "Methods": [
                "GET"
            ],
            "Body": {}
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": [
                {
                    "name": "MEXAMPLE",
                    "tag": "MEXAMPLE",
                    "id": 9988
                },
                {
                    "name": "OtherExample",
                    "tag": "OtherExample",
                    "id": 8877
                }
            ],
            "Headers": {
                "Content-Type": "application/json"
            }
        }
    },
    {
        "Guid": "5b51fedd-a29e-4176-94cf-cf1d569bceb2",
        "Request": {
            "Path": "/api/pets",
            "Methods": [
                "POST"
            ],
            "Body": {
                "Matcher": {
                    "Name": "JsonMatcher",
                    "Pattern": "{\n  \"name\": \"example-string\",\n  \"tag\": \"example-string\"\n}",
                    "IgnoreCase": true
                }
            }
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        }
    },
    {
        "Guid": "514b05e5-72dc-4de5-87e5-c715be3b33dd",
        "Request": {
            "Path": "/api/pet",
            "Methods": [
                "GET"
            ],
            "Body": {}
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        }
    },
    {
        "Guid": "3654675a-c55f-4b7e-aba0-e40c696ed570",
        "Request": {
            "Path": "/api/pets/42",
            "Methods": [
                "GET"
            ],
            "Body": {}
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        }
    },
    {
        "Guid": "ed128a76-2888-420f-b4a7-914110b68a13",
        "Request": {
            "Path": "/api/pets/42",
            "Methods": [
                "DELETE"
            ],
            "Body": {}
        },
        "Response": {
            "StatusCode": 204,
            "Headers": {
                "Content-Type": "application/json"
            }
        }
    }
]

WireMock.Net Mapping (GET __admin/mappings)

[
    {
        "Guid": "04ceff4c-da4a-440d-affa-22b0adb1158a",
        "UpdatedAt": "2023-03-29T15:03:30.901085Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": [
                {
                    "name": "MEXAMPLE",
                    "tag": "MEXAMPLE",
                    "id": 9988
                },
                {
                    "name": "OtherExample",
                    "tag": "OtherExample",
                    "id": 8877
                }
            ],
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "ed128a76-2888-420f-b4a7-914110b68a13",
        "UpdatedAt": "2023-03-29T15:03:30.901251Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/42",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "DELETE"
            ]
        },
        "Response": {
            "StatusCode": 204,
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "62e94c7d-b759-4149-ad63-4ab15ff80748",
        "UpdatedAt": "2023-03-29T13:36:04.21745Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pet",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "58IRODG19",
                "tag": "24DWVNF85",
                "id": 600476729
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "cd9e861e-01bd-4396-801c-0af436f84e2d",
        "UpdatedAt": "2023-03-29T13:38:59.660078Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "POST"
            ],
            "Body": {
                "Matcher": {
                    "Name": "JsonMatcher",
                    "Pattern": "{\n  \"name\": \"example-string\",\n  \"tag\": \"example-string\"\n}",
                    "IgnoreCase": true
                }
            }
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "18fb3b31-2b60-4ee2-9c12-6f0909bbc96d",
        "UpdatedAt": "2023-03-29T13:38:59.660274Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/42",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "1124a0e4-9b31-4a74-9a32-80818429c6f2",
        "UpdatedAt": "2023-03-29T13:36:04.217495Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/*",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "65YQEYR03",
                "tag": "27JULEE15",
                "id": 210834234
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "3654675a-c55f-4b7e-aba0-e40c696ed570",
        "UpdatedAt": "2023-03-29T15:03:30.901223Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/42",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "0a2ed1b6-f5b9-4537-b7f0-cd1cc7325449",
        "UpdatedAt": "2023-03-29T13:36:04.217392Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "POST"
            ],
            "Body": {
                "Matcher": {
                    "Name": "JsonMatcher",
                    "Pattern": "{\n  \"name\": \"73AFJNQ46\",\n  \"tag\": \"86LUYCN69\"\n}",
                    "IgnoreCase": true
                }
            }
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "58JHZXB07",
                "tag": "64EKSES53",
                "id": 1317851855
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "d5853f62-dbda-431a-8f0e-63fd75f7b01b",
        "UpdatedAt": "2023-03-29T13:36:27.446133Z",
        "Request": {
            "Url": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/one",
                        "IgnoreCase": false
                    }
                ]
            }
        },
       "Response": {
            "Body": "Success\n"
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "1a9447d1-b77e-43a5-be37-9837f49ec1cc",
        "UpdatedAt": "2023-03-29T13:38:59.66013Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pet",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "3df8383e-693d-4e37-ad58-d0f573554564",
        "UpdatedAt": "2023-03-29T13:36:04.217532Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/*",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "DELETE"
            ]
        },
        "Response": {
            "StatusCode": 204,
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "5b51fedd-a29e-4176-94cf-cf1d569bceb2",
        "UpdatedAt": "2023-03-29T15:03:30.901149Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "POST"
            ],
            "Body": {
                "Matcher": {
                    "Name": "JsonMatcher",
                    "Pattern": "{\n  \"name\": \"example-string\",\n  \"tag\": \"example-string\"\n}",
                    "IgnoreCase": true
                }
            }
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "89e9d0a1-d38a-4169-8ddd-3cb0bb669e7b",
        "UpdatedAt": "2023-03-29T13:38:59.660321Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets/42",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "DELETE"
            ]
        },
        "Response": {
            "StatusCode": 204,
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "850cf4cd-a445-4945-ae42-a55bb0cd1b20",
        "UpdatedAt": "2023-03-29T13:36:04.209317Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": [
                {
                    "name": "MEXAMPLE",
                    "tag": "MEXAMPLE",
                    "id": 9988
                },
                {
                    "name": "OtherExample",
                    "tag": "OtherExample",
                    "id": 8877
                }
            ],
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "a7127f45-93d8-4cd9-8b64-fa5ad0a83756",
        "UpdatedAt": "2023-03-29T13:38:59.659977Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pets",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": [
                {
                    "name": "MEXAMPLE",
                    "tag": "MEXAMPLE",
                    "id": 9988
                },
                {
                    "name": "OtherExample",
                    "tag": "OtherExample",
                    "id": 8877
                }
            ],
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "514b05e5-72dc-4de5-87e5-c715be3b33dd",
        "UpdatedAt": "2023-03-29T15:03:30.901184Z",
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/api/pet",
                        "IgnoreCase": false
                    }
                ]
            },
            "Methods": [
                "GET"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "name": "example-string",
                "tag": "example-string",
                "id": 42
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        },
        "UseWebhooksFireAndForget": false
    },
    {
        "Guid": "2cc1f813-f389-4ecb-9e21-d6ec789b3aa3",
        "UpdatedAt": "2023-03-29T13:36:27.446068Z",
        "Request": {
            "Url": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/two",
                        "IgnoreCase": false
                    }
                ]
            }
        },
        "Response": {
            "Body": "Error\n"
        },
        "UseWebhooksFireAndForget": false
    }
]

WireMock.org Mapping (GET __admin/mappings)

{
  "mappings" : [ {
    "id" : "4dfc5125-ae12-4140-b355-ac0b1bf55f3d",
    "name" : "Returns all pets from the system that the user has access to (application/json)",
    "request" : {
      "urlPath" : "/pets",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "application/json"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "[ {\n  \"name\" : \"MEXAMPLE\",\n  \"tag\" : \"MEXAMPLE\",\n  \"id\" : 9988\n}, {\n  \"name\" : \"OtherExample\",\n  \"tag\" : \"OtherExample\",\n  \"id\" : 8877\n} ]",
      "headers" : {
        "Content-Type" : "application/json"
      }
    },
    "uuid" : "4dfc5125-ae12-4140-b355-ac0b1bf55f3d",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.24685715Z",
         "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "79ab973d-bfbb-44ec-839b-e655fc31efae",
    "name" : "Returns all pets from the system that the user has access to (application/xml)",
    "request" : {
      "urlPath" : "/pets",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "application/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "[ {\n  \"name\" : \"MEXAMPLE\",\n  \"tag\" : \"MEXAMPLE\",\n  \"id\" : 9988\n}, {\n  \"name\" : \"OtherExample\",\n  \"tag\" : \"OtherExample\",\n  \"id\" : 8877\n} ]",
      "headers" : {
        "Content-Type" : "application/xml"
      }
    },
    "uuid" : "79ab973d-bfbb-44ec-839b-e655fc31efae",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.229477902Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "1dbd8099-1029-4e0f-8220-7e423f6fde7f",
    "name" : "Returns all pets from the system that the user has access to (text/xml)",
    "request" : {
      "urlPath" : "/pets",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "text/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "[ {\n  \"name\" : \"MEXAMPLE\",\n  \"tag\" : \"MEXAMPLE\",\n  \"id\" : 9988\n}, {\n  \"name\" : \"OtherExample\",\n  \"tag\" : \"OtherExample\",\n  \"id\" : 8877\n} ]",
      "headers" : {
        "Content-Type" : "text/xml"
      }
    },
    "uuid" : "1dbd8099-1029-4e0f-8220-7e423f6fde7f",
    "persistent" : true,
   "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.21617373Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "52082f62-237c-4332-a37a-26cbcc507e4a",
    "name" : "Returns all pets from the system that the user has access to (text/html)",
    "request" : {
      "urlPath" : "/pets",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "text/html"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "[ {\n  \"name\" : \"MEXAMPLE\",\n  \"tag\" : \"MEXAMPLE\",\n  \"id\" : 9988\n}, {\n  \"name\" : \"OtherExample\",\n  \"tag\" : \"OtherExample\",\n  \"id\" : 8877\n} ]",
      "headers" : {
        "Content-Type" : "text/html"
      }
    },
    "uuid" : "52082f62-237c-4332-a37a-26cbcc507e4a",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.201907354Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "17712159-4fb0-4cfe-8928-7f34111dd86e",
    "name" : "Creates a new pet in the store.  Duplicates are allowed",
    "request" : {
      "urlPath" : "/pets",
      "method" : "POST"
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Phebe Lehner\",\n  \"tag\" : \"expedita\",\n  \"id\" : 6137546356583794141\n}",
     "headers" : {
        "Content-Type" : "application/json"
      }
    },
    "uuid" : "17712159-4fb0-4cfe-8928-7f34111dd86e",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.187457222Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "f9be50e2-42c3-4bb8-a079-49de71621a95",
    "name" : "Returns a pet from the system that the user has access to (application/json)",
    "request" : {
      "urlPath" : "/pet",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "application/json"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Mickey Stoltenberg\",\n  \"tag\" : \"dolores\",\n  \"id\" : 8114084322863460068\n}",
      "headers" : {
        "Content-Type" : "application/json"
      }
    },
    "uuid" : "f9be50e2-42c3-4bb8-a079-49de71621a95",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.17249502Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "bf48b99f-2a22-4702-9d1c-fb992c1dc845",
    "name" : "Returns a pet from the system that the user has access to (application/xml)",
    "request" : {
      "urlPath" : "/pet",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "application/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Isaiah Gibson\",\n  \"tag\" : \"aut\",\n  \"id\" : 6410576364588137014\n}",
      "headers" : {
        "Content-Type" : "application/xml"
      }
    },
    "uuid" : "bf48b99f-2a22-4702-9d1c-fb992c1dc845",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.158558557Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "11f69bae-4bde-4b72-a3bd-f1f9adea90a5",
    "name" : "Returns a pet from the system that the user has access to (text/xml)",
    "request" : {
      "urlPath" : "/pet",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "text/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Evangeline Hauck\",\n  \"tag\" : \"dignissimos\",\n  \"id\" : 4990506160824429965\n}",
      "headers" : {
        "Content-Type" : "text/xml"
      }
    },
    "uuid" : "11f69bae-4bde-4b72-a3bd-f1f9adea90a5",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.133442907Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "0556a129-4a48-40fe-bd00-982cb488bd23",
    "name" : "Returns a pet from the system that the user has access to (text/html)",
    "request" : {
      "urlPath" : "/pet",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "text/html"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Mrs. Sau Conn\",\n  \"tag\" : \"quibusdam\",\n  \"id\" : 6996166806619036751\n}",
      "headers" : {
        "Content-Type" : "text/html"
      }
    },
    "uuid" : "0556a129-4a48-40fe-bd00-982cb488bd23",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.11803822Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "a18461a9-2a23-4a8a-a2c6-a0d219861a71",
    "name" : "Returns a user based on a single ID, if the user does not have access to the pet (application/json)",
    "request" : {
      "urlPath" : "/pets/3781766237141047736",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "application/json"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Leandro Windler\",\n  \"tag\" : \"vero\",\n  \"id\" : 431986847459427401\n}",
      "headers" : {
        "Content-Type" : "application/json"
      }
    },
    "uuid" : "a18461a9-2a23-4a8a-a2c6-a0d219861a71",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.102232818Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "c8e1343f-2f99-460f-9169-8fc348191b68",
    "name" : "Returns a user based on a single ID, if the user does not have access to the pet (application/xml)",
    "request" : {
      "urlPath" : "/pets/5055682315482875233",
      "method" : "GET",
     "headers" : {
        "Accept" : {
          "contains" : "application/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Leila Bogan\",\n  \"tag\" : \"vitae\",\n  \"id\" : 8391991623360526064\n}",
      "headers" : {
        "Content-Type" : "application/xml"
      }
    },
    "uuid" : "c8e1343f-2f99-460f-9169-8fc348191b68",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.087112011Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "5e84c57a-6096-4c33-8962-e7054bce7326",
    "name" : "Returns a user based on a single ID, if the user does not have access to the pet (text/xml)",
    "request" : {
      "urlPath" : "/pets/745194311211497449",
      "method" : "GET",
      "headers" : {
        "Accept" : {
          "contains" : "text/xml"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Rheba O'Reilly MD\",\n  \"tag\" : \"voluptates\",\n  \"id\" : 3284532136690698432\n}",
      "headers" : {
        "Content-Type" : "text/xml"
      }
    },
    "uuid" : "5e84c57a-6096-4c33-8962-e7054bce7326",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.059045686Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "234d5a9a-c026-47fa-88f4-a2fdf0a5d33d",
    "name" : "Returns a user based on a single ID, if the user does not have access to the pet (text/html)",
    "request" : {
      "urlPath" : "/pets/8298080729035708675",
      "method" : "GET",
      "headers" : {
        "Accept" : {
         "contains" : "text/html"
        }
      }
    },
    "response" : {
      "status" : 200,
      "body" : "{\n  \"name\" : \"Alejandra Glover PhD\",\n  \"tag\" : \"repellendus\",\n  \"id\" : 7499354754298413200\n}",
      "headers" : {
        "Content-Type" : "text/html"
      }
    },
    "uuid" : "234d5a9a-c026-47fa-88f4-a2fdf0a5d33d",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:14.014731023Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  }, {
    "id" : "97c60d18-c90b-470e-8b03-48e9e7bf0f09",
    "name" : "deletes a single pet based on the ID supplied - 204",
    "request" : {
      "urlPath" : "/pets/383307658688532299",
      "method" : "DELETE"
    },
    "response" : {
      "status" : 204
    },
    "uuid" : "97c60d18-c90b-470e-8b03-48e9e7bf0f09",
    "persistent" : true,
    "metadata" : {
      "mocklab" : {
        "created" : {
          "at" : "2023-03-29T14:57:13.999809143Z",
          "via" : "IMPORT",
          "by" : "y82mo"
        }
      }
    }
  } ],
  "meta" : {
    "total" : 14
  }
}
@laslanian commented on GitHub (Mar 29, 2023): @StefH The endpoints are working as expected with __admin/openapi/convert returning the mapping, and __admin/openapi/save persisting it to WireMock instance. I did notice an inconsistency with the returned mappings. The new endpoint (__admin/openapi/convert) returns the mappings in a different format than the existing __admin/mappings endpoint, which is also different than the mappings used in WireMock Java version (WireMock.org) as seen below. Due to this inconsistency, importing the converted mappings into the Java version has many issues. Would it be possible to align these formats? I would be happy to contribute my time to working on this if there is initiative on this subject. **Original Swagger Json** ``` json { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team" }, "license": { "name": "MIT" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": ["http"], "consumes": ["application/json"], "produces": ["application/json"], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "findPets", "produces": ["application/json", "application/xml", "text/xml", "text/html"], "parameters": [{ "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv" }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" }], "responses": { "200": { "description": "pet response", "schema": { "example": [{ "name": "MEXAMPLE", "tag": "MEXAMPLE", "id": 9988 }, { "name": "OtherExample", "tag": "OtherExample", "id": 8877 }], "type": "array", "items": { "$ref": "#/definitions/Pet" } } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", "produces": ["application/json"], "parameters": [{ "name": "pet", "in": "body", "description": "Pet to add to the store", "required": true, "schema": { "$ref": "#/definitions/NewPet" } }], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } }, "/pet": { "get": { "description": "Returns a pet from the system that the user has access to", "operationId": "findPet", "produces": ["application/json", "application/xml", "text/xml", "text/html"], "parameters": [{ "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv" }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" }], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } }, "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "findPetById", "produces": ["application/json", "application/xml", "text/xml", "text/html"], "parameters": [{ "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, "type": "integer", "format": "int64" }], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "delete": { "description": "deletes a single pet based on the ID supplied", "operationId": "deletePet", "parameters": [{ "name": "id", "in": "path", "description": "ID of pet to delete", "required": true, "type": "integer", "format": "int64" }], "responses": { "204": { "description": "pet deleted" }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } } }, "definitions": { "Pet": { "type": "object", "allOf": [{ "$ref": "#/definitions/NewPet" }, { "required": ["id"], "properties": { "id": { "type": "integer", "format": "int64" } } }] }, "NewPet": { "type": "object", "required": ["name"], "properties": { "name": { "type": "string" }, "tag": { "type": "string" } } }, "ErrorModel": { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } } } ``` **WireMock.Net Mapping (POST __admin/openapi/convert)** ``` json [ { "Guid": "04ceff4c-da4a-440d-affa-22b0adb1158a", "Request": { "Path": "/api/pets", "Methods": [ "GET" ], "Body": {} }, "Response": { "StatusCode": 200, "BodyAsJson": [ { "name": "MEXAMPLE", "tag": "MEXAMPLE", "id": 9988 }, { "name": "OtherExample", "tag": "OtherExample", "id": 8877 } ], "Headers": { "Content-Type": "application/json" } } }, { "Guid": "5b51fedd-a29e-4176-94cf-cf1d569bceb2", "Request": { "Path": "/api/pets", "Methods": [ "POST" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "{\n \"name\": \"example-string\",\n \"tag\": \"example-string\"\n}", "IgnoreCase": true } } }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } } }, { "Guid": "514b05e5-72dc-4de5-87e5-c715be3b33dd", "Request": { "Path": "/api/pet", "Methods": [ "GET" ], "Body": {} }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } } }, { "Guid": "3654675a-c55f-4b7e-aba0-e40c696ed570", "Request": { "Path": "/api/pets/42", "Methods": [ "GET" ], "Body": {} }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } } }, { "Guid": "ed128a76-2888-420f-b4a7-914110b68a13", "Request": { "Path": "/api/pets/42", "Methods": [ "DELETE" ], "Body": {} }, "Response": { "StatusCode": 204, "Headers": { "Content-Type": "application/json" } } } ] ``` **WireMock.Net Mapping (GET __admin/mappings)** ``` json [ { "Guid": "04ceff4c-da4a-440d-affa-22b0adb1158a", "UpdatedAt": "2023-03-29T15:03:30.901085Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": [ { "name": "MEXAMPLE", "tag": "MEXAMPLE", "id": 9988 }, { "name": "OtherExample", "tag": "OtherExample", "id": 8877 } ], "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "ed128a76-2888-420f-b4a7-914110b68a13", "UpdatedAt": "2023-03-29T15:03:30.901251Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/42", "IgnoreCase": false } ] }, "Methods": [ "DELETE" ] }, "Response": { "StatusCode": 204, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "62e94c7d-b759-4149-ad63-4ab15ff80748", "UpdatedAt": "2023-03-29T13:36:04.21745Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pet", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "58IRODG19", "tag": "24DWVNF85", "id": 600476729 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "cd9e861e-01bd-4396-801c-0af436f84e2d", "UpdatedAt": "2023-03-29T13:38:59.660078Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "POST" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "{\n \"name\": \"example-string\",\n \"tag\": \"example-string\"\n}", "IgnoreCase": true } } }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "18fb3b31-2b60-4ee2-9c12-6f0909bbc96d", "UpdatedAt": "2023-03-29T13:38:59.660274Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/42", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "1124a0e4-9b31-4a74-9a32-80818429c6f2", "UpdatedAt": "2023-03-29T13:36:04.217495Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/*", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "65YQEYR03", "tag": "27JULEE15", "id": 210834234 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "3654675a-c55f-4b7e-aba0-e40c696ed570", "UpdatedAt": "2023-03-29T15:03:30.901223Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/42", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "0a2ed1b6-f5b9-4537-b7f0-cd1cc7325449", "UpdatedAt": "2023-03-29T13:36:04.217392Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "POST" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "{\n \"name\": \"73AFJNQ46\",\n \"tag\": \"86LUYCN69\"\n}", "IgnoreCase": true } } }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "58JHZXB07", "tag": "64EKSES53", "id": 1317851855 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "d5853f62-dbda-431a-8f0e-63fd75f7b01b", "UpdatedAt": "2023-03-29T13:36:27.446133Z", "Request": { "Url": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/one", "IgnoreCase": false } ] } }, "Response": { "Body": "Success\n" }, "UseWebhooksFireAndForget": false }, { "Guid": "1a9447d1-b77e-43a5-be37-9837f49ec1cc", "UpdatedAt": "2023-03-29T13:38:59.66013Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pet", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "3df8383e-693d-4e37-ad58-d0f573554564", "UpdatedAt": "2023-03-29T13:36:04.217532Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/*", "IgnoreCase": false } ] }, "Methods": [ "DELETE" ] }, "Response": { "StatusCode": 204, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "5b51fedd-a29e-4176-94cf-cf1d569bceb2", "UpdatedAt": "2023-03-29T15:03:30.901149Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "POST" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "{\n \"name\": \"example-string\",\n \"tag\": \"example-string\"\n}", "IgnoreCase": true } } }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "89e9d0a1-d38a-4169-8ddd-3cb0bb669e7b", "UpdatedAt": "2023-03-29T13:38:59.660321Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets/42", "IgnoreCase": false } ] }, "Methods": [ "DELETE" ] }, "Response": { "StatusCode": 204, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "850cf4cd-a445-4945-ae42-a55bb0cd1b20", "UpdatedAt": "2023-03-29T13:36:04.209317Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": [ { "name": "MEXAMPLE", "tag": "MEXAMPLE", "id": 9988 }, { "name": "OtherExample", "tag": "OtherExample", "id": 8877 } ], "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "a7127f45-93d8-4cd9-8b64-fa5ad0a83756", "UpdatedAt": "2023-03-29T13:38:59.659977Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pets", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": [ { "name": "MEXAMPLE", "tag": "MEXAMPLE", "id": 9988 }, { "name": "OtherExample", "tag": "OtherExample", "id": 8877 } ], "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "514b05e5-72dc-4de5-87e5-c715be3b33dd", "UpdatedAt": "2023-03-29T15:03:30.901184Z", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/api/pet", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "name": "example-string", "tag": "example-string", "id": 42 }, "Headers": { "Content-Type": "application/json" } }, "UseWebhooksFireAndForget": false }, { "Guid": "2cc1f813-f389-4ecb-9e21-d6ec789b3aa3", "UpdatedAt": "2023-03-29T13:36:27.446068Z", "Request": { "Url": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/two", "IgnoreCase": false } ] } }, "Response": { "Body": "Error\n" }, "UseWebhooksFireAndForget": false } ] ``` **WireMock.org Mapping (GET __admin/mappings)** ``` json { "mappings" : [ { "id" : "4dfc5125-ae12-4140-b355-ac0b1bf55f3d", "name" : "Returns all pets from the system that the user has access to (application/json)", "request" : { "urlPath" : "/pets", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/json" } } }, "response" : { "status" : 200, "body" : "[ {\n \"name\" : \"MEXAMPLE\",\n \"tag\" : \"MEXAMPLE\",\n \"id\" : 9988\n}, {\n \"name\" : \"OtherExample\",\n \"tag\" : \"OtherExample\",\n \"id\" : 8877\n} ]", "headers" : { "Content-Type" : "application/json" } }, "uuid" : "4dfc5125-ae12-4140-b355-ac0b1bf55f3d", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.24685715Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "79ab973d-bfbb-44ec-839b-e655fc31efae", "name" : "Returns all pets from the system that the user has access to (application/xml)", "request" : { "urlPath" : "/pets", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/xml" } } }, "response" : { "status" : 200, "body" : "[ {\n \"name\" : \"MEXAMPLE\",\n \"tag\" : \"MEXAMPLE\",\n \"id\" : 9988\n}, {\n \"name\" : \"OtherExample\",\n \"tag\" : \"OtherExample\",\n \"id\" : 8877\n} ]", "headers" : { "Content-Type" : "application/xml" } }, "uuid" : "79ab973d-bfbb-44ec-839b-e655fc31efae", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.229477902Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "1dbd8099-1029-4e0f-8220-7e423f6fde7f", "name" : "Returns all pets from the system that the user has access to (text/xml)", "request" : { "urlPath" : "/pets", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/xml" } } }, "response" : { "status" : 200, "body" : "[ {\n \"name\" : \"MEXAMPLE\",\n \"tag\" : \"MEXAMPLE\",\n \"id\" : 9988\n}, {\n \"name\" : \"OtherExample\",\n \"tag\" : \"OtherExample\",\n \"id\" : 8877\n} ]", "headers" : { "Content-Type" : "text/xml" } }, "uuid" : "1dbd8099-1029-4e0f-8220-7e423f6fde7f", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.21617373Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "52082f62-237c-4332-a37a-26cbcc507e4a", "name" : "Returns all pets from the system that the user has access to (text/html)", "request" : { "urlPath" : "/pets", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/html" } } }, "response" : { "status" : 200, "body" : "[ {\n \"name\" : \"MEXAMPLE\",\n \"tag\" : \"MEXAMPLE\",\n \"id\" : 9988\n}, {\n \"name\" : \"OtherExample\",\n \"tag\" : \"OtherExample\",\n \"id\" : 8877\n} ]", "headers" : { "Content-Type" : "text/html" } }, "uuid" : "52082f62-237c-4332-a37a-26cbcc507e4a", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.201907354Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "17712159-4fb0-4cfe-8928-7f34111dd86e", "name" : "Creates a new pet in the store. Duplicates are allowed", "request" : { "urlPath" : "/pets", "method" : "POST" }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Phebe Lehner\",\n \"tag\" : \"expedita\",\n \"id\" : 6137546356583794141\n}", "headers" : { "Content-Type" : "application/json" } }, "uuid" : "17712159-4fb0-4cfe-8928-7f34111dd86e", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.187457222Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "f9be50e2-42c3-4bb8-a079-49de71621a95", "name" : "Returns a pet from the system that the user has access to (application/json)", "request" : { "urlPath" : "/pet", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/json" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Mickey Stoltenberg\",\n \"tag\" : \"dolores\",\n \"id\" : 8114084322863460068\n}", "headers" : { "Content-Type" : "application/json" } }, "uuid" : "f9be50e2-42c3-4bb8-a079-49de71621a95", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.17249502Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "bf48b99f-2a22-4702-9d1c-fb992c1dc845", "name" : "Returns a pet from the system that the user has access to (application/xml)", "request" : { "urlPath" : "/pet", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/xml" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Isaiah Gibson\",\n \"tag\" : \"aut\",\n \"id\" : 6410576364588137014\n}", "headers" : { "Content-Type" : "application/xml" } }, "uuid" : "bf48b99f-2a22-4702-9d1c-fb992c1dc845", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.158558557Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "11f69bae-4bde-4b72-a3bd-f1f9adea90a5", "name" : "Returns a pet from the system that the user has access to (text/xml)", "request" : { "urlPath" : "/pet", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/xml" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Evangeline Hauck\",\n \"tag\" : \"dignissimos\",\n \"id\" : 4990506160824429965\n}", "headers" : { "Content-Type" : "text/xml" } }, "uuid" : "11f69bae-4bde-4b72-a3bd-f1f9adea90a5", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.133442907Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "0556a129-4a48-40fe-bd00-982cb488bd23", "name" : "Returns a pet from the system that the user has access to (text/html)", "request" : { "urlPath" : "/pet", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/html" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Mrs. Sau Conn\",\n \"tag\" : \"quibusdam\",\n \"id\" : 6996166806619036751\n}", "headers" : { "Content-Type" : "text/html" } }, "uuid" : "0556a129-4a48-40fe-bd00-982cb488bd23", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.11803822Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "a18461a9-2a23-4a8a-a2c6-a0d219861a71", "name" : "Returns a user based on a single ID, if the user does not have access to the pet (application/json)", "request" : { "urlPath" : "/pets/3781766237141047736", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/json" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Leandro Windler\",\n \"tag\" : \"vero\",\n \"id\" : 431986847459427401\n}", "headers" : { "Content-Type" : "application/json" } }, "uuid" : "a18461a9-2a23-4a8a-a2c6-a0d219861a71", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.102232818Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "c8e1343f-2f99-460f-9169-8fc348191b68", "name" : "Returns a user based on a single ID, if the user does not have access to the pet (application/xml)", "request" : { "urlPath" : "/pets/5055682315482875233", "method" : "GET", "headers" : { "Accept" : { "contains" : "application/xml" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Leila Bogan\",\n \"tag\" : \"vitae\",\n \"id\" : 8391991623360526064\n}", "headers" : { "Content-Type" : "application/xml" } }, "uuid" : "c8e1343f-2f99-460f-9169-8fc348191b68", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.087112011Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "5e84c57a-6096-4c33-8962-e7054bce7326", "name" : "Returns a user based on a single ID, if the user does not have access to the pet (text/xml)", "request" : { "urlPath" : "/pets/745194311211497449", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/xml" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Rheba O'Reilly MD\",\n \"tag\" : \"voluptates\",\n \"id\" : 3284532136690698432\n}", "headers" : { "Content-Type" : "text/xml" } }, "uuid" : "5e84c57a-6096-4c33-8962-e7054bce7326", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.059045686Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "234d5a9a-c026-47fa-88f4-a2fdf0a5d33d", "name" : "Returns a user based on a single ID, if the user does not have access to the pet (text/html)", "request" : { "urlPath" : "/pets/8298080729035708675", "method" : "GET", "headers" : { "Accept" : { "contains" : "text/html" } } }, "response" : { "status" : 200, "body" : "{\n \"name\" : \"Alejandra Glover PhD\",\n \"tag\" : \"repellendus\",\n \"id\" : 7499354754298413200\n}", "headers" : { "Content-Type" : "text/html" } }, "uuid" : "234d5a9a-c026-47fa-88f4-a2fdf0a5d33d", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:14.014731023Z", "via" : "IMPORT", "by" : "y82mo" } } } }, { "id" : "97c60d18-c90b-470e-8b03-48e9e7bf0f09", "name" : "deletes a single pet based on the ID supplied - 204", "request" : { "urlPath" : "/pets/383307658688532299", "method" : "DELETE" }, "response" : { "status" : 204 }, "uuid" : "97c60d18-c90b-470e-8b03-48e9e7bf0f09", "persistent" : true, "metadata" : { "mocklab" : { "created" : { "at" : "2023-03-29T14:57:13.999809143Z", "via" : "IMPORT", "by" : "y82mo" } } } } ], "meta" : { "total" : 14 } } ```
Author
Owner

@StefH commented on GitHub (Mar 29, 2023):

I did some quick tests using your example pet store json. And it seems that the mappings are the same, although the ordering is different.

And about WireMock.Org --> https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock.Org

@StefH commented on GitHub (Mar 29, 2023): I did some quick tests using your example pet store json. And it seems that the mappings are the same, although the ordering is different. And about WireMock.Org --> https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock.Org
Author
Owner

@StefH commented on GitHub (Apr 1, 2023):

@laslanian
Is this clear?

@StefH commented on GitHub (Apr 1, 2023): @laslanian Is this clear?
Author
Owner

@StefH commented on GitHub (Apr 5, 2023):

@laslanian
Can I merge this code change to the master?

@StefH commented on GitHub (Apr 5, 2023): @laslanian Can I merge this code change to the master?
Author
Owner

@StefH commented on GitHub (Apr 8, 2023):

PR is merged

@StefH commented on GitHub (Apr 8, 2023): PR is merged
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#504