|
4 | 4 | collectException, handleInternalError, |
5 | 5 | } from './utils/collectionUtils.js'; |
6 | 6 | import { resolveObject } from './utils/componentUtils.js'; |
7 | | -import { getSchemaNameFromRef } from './utils/methodUtils.js'; |
| 7 | +//import { getSchemaNameFromRef } from './utils/methodUtils.js'; |
8 | 8 |
|
9 | 9 | const RULE_NAME = 'xgen-IPA-114-error-responses-refer-to-api-error'; |
10 | 10 |
|
@@ -39,15 +39,19 @@ function checkViolationsAndReturnErrors(apiResponseObject, oas, path, errorCode) |
39 | 39 | const errors = []; |
40 | 40 | let content; |
41 | 41 |
|
| 42 | + /*else if (apiResponseObject.$ref) { |
| 43 | + const schemaName = getSchemaNameFromRef(apiResponseObject.$ref); |
| 44 | + const responseSchema = resolveObject(oas, ['components', 'responses', schemaName]); |
| 45 | + content = responseSchema.content; |
| 46 | +} */ |
| 47 | + |
42 | 48 | if (apiResponseObject.content) { |
43 | 49 | content = apiResponseObject.content; |
44 | | - } else if (apiResponseObject.$ref) { |
45 | | - const schemaName = getSchemaNameFromRef(apiResponseObject.$ref); |
46 | | - const responseSchema = resolveObject(oas, ['components', 'responses', schemaName]); |
47 | | - content = responseSchema.content; |
48 | | - } else { |
| 50 | + } |
| 51 | + else { |
49 | 52 | return [{ path, message: `${errorCode} response must define content with ApiError schema reference.` }]; |
50 | 53 | } |
| 54 | + console.log('content', content); |
51 | 55 |
|
52 | 56 | /* |
53 | 57 | for (const [mediaType, mediaTypeObj] of Object.entries(content)) { |
|
0 commit comments