Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for error deserialization in op with param name 'models' #234

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion legacy/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ var coverage = {
"intError":0,
"stringError":0,
"animalNotFoundError":0,
"linkNotFoundError":0
"linkNotFoundError":0,
"sendErrorWithParamNameModels": 0
};

// view engine setup
Expand Down
10 changes: 10 additions & 0 deletions legacy/routes/errorStatusCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ var pathitem = function(coverage) {
res.status(402).end("That's all folks!!");
}
});

router.post('/Pets/hasModelsParam', function(req, res, next) {
models_param = req.query['models']
if (models_param == 'value1') {
res.status(500).json(sadCasper);
coverage['sendErrorWithParamNameModels']++;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it optional, since this might be python specific

} else {
utils.send400(res, next, "The value of input param models is " + models_param + " and not the client default value of 'value1'");
}
});
}

pathitem.prototype.router = router;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest.testserver",
"version": "2.10.62",
"version": "2.10.63",
"main": "./legacy/startup/www.js",
"bin": {
"start-autorest-express": "./.scripts/start-autorest-express.js",
Expand Down
55 changes: 41 additions & 14 deletions swagger/xms-error-responses.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"schemes": [
"http"
],
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"paths": {
"/errorStatusCodes/Pets/{petId}/GetPet": {
"get": {
Expand Down Expand Up @@ -57,13 +63,7 @@
"default": {
"description": "default stuff"
}
},
"produces": [
"application/json"
],
"consumes": [
"application/json"
]
}
}
},
"/errorStatusCodes/Pets/doSomething/{whatAction}": {
Expand Down Expand Up @@ -99,14 +99,41 @@
"$ref": "#/definitions/PetActionError"
}
}
},
"produces": [
"application/json"
],
"consumes": [
"application/json"
]
}
}
},
"/errorStatusCodes/Pets/hasModelsParam": {
"post": {
"operationId": "Pet_HasModelsParam",
"description": "Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't conflict with the input param name 'models'",
"parameters": [
{
"name": "models",
"in": "query",
"type": "string",
"x-ms-client-default": "value1",
"description": "Make sure model deserialization doesn't conflic with this param name, which has input name 'models'. Use client default value in call"
}
],
"responses": {
"200": {
"description": "OK. We will be returning an error though"
},
"500": {
"description": "Will return error. Make sure the error can be correctly deserialized",
"schema": {
"$ref": "#/definitions/PetActionError"
},
"x-ms-error-response": true
},
"default": {
"description": "Default",
"schema": {
"$ref": "#/definitions/PetActionError"
}
}
}
}
}
},
"definitions": {
Expand Down