Skip to content

Commit

Permalink
fix: skips warning for non-ref response schemas when not content is n…
Browse files Browse the repository at this point in the history
…ot json
  • Loading branch information
SamerJaser96 authored and dpopp07 committed Jun 18, 2019
1 parent 7219f2b commit 624d41a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
37 changes: 37 additions & 0 deletions test/plugins/validation/2and3/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

0 comments on commit 624d41a

Please sign in to comment.