Repository: Redocly/redocly-cli
Pull request #981 (2023-01-04 08:52:10)

fix: resolve refs inside spec extensions
## What/Why/How?
Resolve an issue where refs aren't resolved inside specification extensions while linting.

## Reference
https://redoc-ly.slack.com/archives/C02UHE7EL3E/p1672777257007459

## Testing
Locally

## Screenshots (optional)
N/a

## Check yourself

- [ ] Code is linted
- [ ] Tested with redoc/reference-docs/workflows
- [ ] All new/updated code is covered with tests

## Security

- [ ] Security impact of change has been considered
- [ ] Code follows company security practices and guidelines


github-actions[bot]: <!-- jest coverage report action for options with hash 3339ae53a38c44382c0fb4491bdb282d -->

## Coverage report 



| <div title="Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold">St.<sup>:grey_question:</sup></div> | Category   | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
|                                                                           🟡                                                                           | Statements | 73.95%     |    3417/4621    |
|                                                                           🟡                                                                           | Branches   | 65.82%     |    1935/2940    |
|                                                                           🟡                                                                           | Functions  | 66.59%     |     580/871     |
|                                                                           🟡                                                                           | Lines      | 73.97%     |    3177/4295    |


## Test suite run success
538 tests passing in 85 suites.

<p align="right">Report generated by <a href="https://github.com/ArtiomTr/jest-coverage-report-action">🧪jest coverage report action</a> from a6bbc0fda891919303f9b64ad8cb8b898df79084</p>


Patch:
diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/index.ts
index 1e4277f0..e3406726 100755
--- a/packages/core/src/types/index.ts
+++ b/packages/core/src/types/index.ts
@@ -67,7 +67,7 @@ export const SpecExtension: NormalizedNodeType = {
   name: 'SpecExtension',
   properties: {},
   // skip validation of additional properties for unknown extensions
-  additionalProperties: null,
+  additionalProperties: { resolvable: true },
 };
 
 export function normalizeTypes(


Test patch:
diff --git a/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts b/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts
index 5c7160c2..7a9dd2ae 100644
--- a/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts
+++ b/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts
@@ -165,4 +165,35 @@ describe('oas3 boolean-parameter-prefixes', () => {
       ]
     `);
   });
+
+  it('should not report on refs inside specification extensions', async () => {
+    const document = parseYamlToDocument(
+      outdent`
+        openapi: 3.0.0
+        components:
+          requestBodies:
+            a:
+              content:
+                application/json:
+                  schema:
+                    type: object
+        x-webhooks:
+          test:
+            put:
+              requestBody:
+                $ref: '#/components/requestBodies/a'
+      `,
+      path.join(__dirname, 'foobar.yaml')
+    );
+
+    const results = await lintDocument({
+      externalRefResolver: new BaseResolver(),
+      document,
+      config: await makeConfig({
+        'no-unresolved-refs': 'error',
+      }),
+    });
+
+    expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`);
+  });
 });