diff --git a/package.json b/package.json index 49da995d..96a5ff65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft.azure/autorest.testserver", - "version": "3.0.3", + "version": "3.0.4", "description": "Autorest test server.", "main": "dist/cli/cli.js", "bin": { diff --git a/src/test-routes/incorrect-error-response.ts b/src/test-routes/incorrect-error-response.ts new file mode 100644 index 00000000..b056edc3 --- /dev/null +++ b/src/test-routes/incorrect-error-response.ts @@ -0,0 +1,12 @@ +import { app, json } from "../api"; +app.category("vanilla", () => { + app.get("/incorrectError", "verifyIncorrectErrorParsing", (req) => { + return { + status: 444, + body: { + contentType: "text/html", + rawContent: "foobar", + }, + }; + }); +}); diff --git a/swagger/incorrect-error-response.json b/swagger/incorrect-error-response.json new file mode 100644 index 00000000..667b5352 --- /dev/null +++ b/swagger/incorrect-error-response.json @@ -0,0 +1,51 @@ +{ + "swagger": "2.0", + "info": { + "title": "Incorrect Returned Error Model", + "description": "Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors", + "version": "1.0.0" + }, + "host": "localhost:3000", + "schemes": [ + "http" + ], + "produces": [ + "text/html" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/incorrectError": { + "get": { + "operationId": "getIncorrectErrorFromServer", + "description": "Get an error response from the server that is not as described in our Error object. Want to swallow the deserialization error and still return an HttpResponseError to the users.", + "responses": { + "200": { + "description": "We will only return an error, so should expect a call to this service to fail." + }, + "default": { + "description": "Error response from server. Will not abide by the defined Error model. Want to swallow the deserialization error and still return the overall HttpResponseError to users.", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "Error": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } \ No newline at end of file