Hi There,
I import an OAS Api to tyk. And want to enable a mock response for the imported API with the ‘Mock Reponse’ plugin.
Below is my definition, do I miss something? Why my API can’t be mocked?
{
"components": {
"requestBodies": {
"Pet": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
},
"description": "Pet object that needs to be added to the store",
"required": true
}
},
"schemas": {
"Pet": {
"properties": {
"category": {
"type": "string"
},
"id": {
"format": "int64",
"type": "integer"
},
"name": {
"example": "doggie",
"type": "string"
},
"status": {
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
],
"type": "string"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name"
],
"type": "object"
}
},
"securitySchemes": {
"api_key": {
"in": "header",
"name": "api_key",
"type": "apiKey"
}
}
},
"info": {
"description": "This is a sample server Petstore server.",
"title": "OAS Petstore",
"version": "1.0.0"
},
"openapi": "3.0.3",
"paths": {
"/pet": {
"post": {
"operationId": "addPet",
"requestBody": {
"$ref": "#/components/requestBodies/Pet"
},
"responses": {
"405": {
"description": "Invalid input"
}
},
"summary": "Add a new pet to the store",
"tags": [
"pet"
]
},
"put": {
"operationId": "updatePet",
"requestBody": {
"$ref": "#/components/requestBodies/Pet"
},
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
},
"405": {
"description": "Validation exception"
}
},
"summary": "Update an existing pet",
"tags": [
"pet"
]
}
},
"/pet/{petId}": {
"get": {
"description": "Returns a single pet",
"operationId": "getPetById",
"parameters": [
{
"description": "ID of pet to return",
"in": "path",
"name": "petId",
"required": true,
"schema": {
"format": "int64",
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"examples": {
"example1": {
"value": {
"id": 100,
"name": "dog"
}
},
"example2": {
"value": {
"id": 87283939390,
"name": "amazing-cat"
}
}
},
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
},
"description": "successful operation"
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
}
},
"summary": "Find pet by ID",
"tags": [
"pet"
]
}
}
},
"servers": [
{
"url": "https://petstore.swagger.io/v2"
},
{
"url": "http://petstore.swagger.io/v2"
}
],
"tags": [
{
"description": "Everything about your Pets",
"name": "pet"
}
],
"x-tyk-api-gateway": {
"info": {
"id": "14def1d9d3a6445e634fca80a79b6600",
"dbId": "64d48942b049f200017e439d",
"orgId": "64d057ca9dcda6000109211a",
"name": "petstore",
"state": {
"active": true
}
},
"upstream": {
"url": "https://petstore.swagger.io/v2"
},
"server": {
"listenPath": {
"value": "/petstore-test/",
"strip": true
}
},
"middleware": {
"operations": {
"addPet": {
"allow": {
"enabled": true
},
"ignoreAuthentication": {
"enabled": true
}
},
"getPetById": {
"allow": {
"enabled": true,
"ignoreCase": true
},
"ignoreAuthentication": {
"enabled": true
},
"mockResponse": {
"enabled": true,
"fromOASExamples": {
"enabled": true,
"code": 200,
"contentType": "application/json",
"exampleName": "example1"
}
}
}
}
}
}
}