Skip to content

Commit 53b04b8

Browse files
1 parent c0f679d commit 53b04b8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsRequestSuffixedObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ const ERROR_MESSAGE_SCHEMA_REF = 'The response body schema is defined inline and
1111
export default (input, _, { path, documentInventory }) => {
1212
const oas = documentInventory.unresolved;
1313
const resourcePath = path[1];
14+
const contentMediaType = path[path.length - 1];
1415

15-
if (isCustomMethodIdentifier(resourcePath)) {
16+
if (isCustomMethodIdentifier(resourcePath) || !contentMediaType.endsWith('json')) {
1617
return;
1718
}
1819

@@ -24,7 +25,6 @@ export default (input, _, { path, documentInventory }) => {
2425
}
2526

2627
if (contentPerMediaType.schema) {
27-
console.log(contentPerMediaType);
2828
const schema = contentPerMediaType.schema;
2929
const schemaRef = getSchemaRef(schema);
3030
if (!schemaRef) {

tools/spectral/ipa/rulesets/functions/getMethodReturnsResponseSuffixedObject.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ const ERROR_MESSAGE_SCHEMA_REF = 'The response body schema is defined inline and
1616
export default (input, _, { path, documentInventory }) => {
1717
const resourcePath = path[1];
1818
const responseCode = path[4];
19+
const contentMediaType = path[path.length - 1];
1920
const oas = documentInventory.unresolved;
2021
const resourcePaths = getResourcePathItems(resourcePath, oas.paths);
2122

2223
if (
2324
responseCode.startsWith('2') &&
24-
(isResourceCollectionIdentifier(resourcePath) ||
25-
(isSingleResourceIdentifier(resourcePath) && isSingletonResource(resourcePaths)))
25+
contentMediaType.endsWith('json') &&
26+
(isSingleResourceIdentifier(resourcePath) ||
27+
(isResourceCollectionIdentifier(resourcePath) && isSingletonResource(resourcePaths)))
2628
) {
2729
const contentPerMediaType = resolveObject(oas, path);
2830

0 commit comments

Comments
 (0)