Response validation, incorrect `originalResponse`
Failed response validation message contains the wrong type of the original response.
{
"code": "SCHEMA_VALIDATION_FAILED",
"message": "Response validation failed: failed schema validation",
"failedValidation": true,
"results": {
"errors": [
{
"code": "OBJECT_MISSING_REQUIRED_PROPERTY",
"message": "Missing required property: token",
"path": []
}
],
"warnings": []
},
"originalResponse": {
"type": "Buffer",
"data": [
123,
34,
119,
116,
102,
34,
58,
116,
114,
117,
101,
125
]
}
}
Even though I send a simple string.
Seems like your string comes in as a buffer in your response ...
Is this "intended" application-wise (configured so in your controller)?
Is this "allowed" schema-wise (declared so by in your swagger.yaml by schema and type for your response)?
Controller:
res.json({notToken: '123'})
Response schema:
Session:
required:
- token
properties:
token:
type: string
Controller:
The required property key is token (notToken is what causes:
"Missing required property: token"
unless of course it was manually adapted for copy pasting here).
So this should be the correct format:
res.json({'token': '123'})
(For testing purposes you could also drop the required constraint in your response schema so that it passes the validation).
Schema:
You could try some of the following in your response definition:
Session:
type: object
<...>
And in your route defitnition (in the swagger.yaml):
<url>:
x-swagger-router-controller: <...>
<METHOD>:
<...>
operationId: <...>
produces:
- application/json
@arne-at-daten-und-bass when the response is correct, there is no issue. The issue is that the validation error shows originalResponse as a byte buffer
Sorry ... could not reproduce that here ... I am afraid I can't help any further.
@arne-at-daten-und-bass thank you, but I'm not asking for help, I'm reporting a bug