My controller
function putAReview(req, res){
fakeDB.addReview(req.body.reviewObject.id, req.body.reviewObject.reviewInteger)
.then( res => {
res.json({result: {result: res}}); //Outputs : { result: { result: 'success' } }
})
.catch( err =>{
res.status(500).json({error: {error: err}});
});
}
My route (YAML)
/review:
x-swagger-router-controller: wine
put:
operationId: putAReview
description: Review a wine based on ID
parameters:
- name: reviewObject
description: The ID and review integer of the wine to review
in: body
required: true
schema:
$ref: "#/definitions/ReviewWineByID"
# define the type of response for Success "200" and Error
responses:
"200":
description: Success
schema:
$ref: "#/definitions/ReviewWineByIDResponse"
default:
description: Error
schema:
$ref: "#/definitions/ReviewWineByIDErrorResponse"
My schema
ReviewWineByIDResponse:
required:
- result
properties:
result:
type: object
properties:
result:
type: string