diff --git a/src/plugins/validation/2and3/semantic-validators/responses.js b/src/plugins/validation/2and3/semantic-validators/responses.js index 935a5f037..8095b931c 100644 --- a/src/plugins/validation/2and3/semantic-validators/responses.js +++ b/src/plugins/validation/2and3/semantic-validators/responses.js @@ -20,7 +20,10 @@ module.exports.validate = function({ jsSpec, isOAS3 }, config) { if (isOAS3) { each(response.content, (mediaType, mediaTypeKey) => { const hasInlineSchema = mediaType.schema && !mediaType.schema.$ref; - if (hasInlineSchema) { + if ( + hasInlineSchema && + mediaTypeKey.startsWith('application/json') + ) { const checkStatus = config.inline_response_schema; if (checkStatus !== 'off') { result[checkStatus].push({ diff --git a/test/plugins/validation/2and3/responses.js b/test/plugins/validation/2and3/responses.js index b236f575d..3388a5e7f 100644 --- a/test/plugins/validation/2and3/responses.js +++ b/test/plugins/validation/2and3/responses.js @@ -268,6 +268,43 @@ describe('validation plugin - semantic - responses', function() { ); expect(res.errors.length).toEqual(0); }); + + it('should not complain about non-json response that defines an inline schema', function() { + const config = { + responses: { + no_response_codes: 'error', + no_success_response_codes: 'warning' + } + }; + + const spec = { + paths: { + '/pets': { + get: { + summary: 'this is a summary', + operationId: 'operationId', + responses: { + '400': { + description: 'bad request', + content: { + 'plain/text': { + schema: { + type: 'string', + format: 'binary' + } + } + } + } + } + } + } + } + }; + + const res = validate({ jsSpec: spec }, config); + expect(res.warnings.length).toEqual(0); + expect(res.errors.length).toEqual(0); + }); }); }); });