Repository: Redocly/redocly-cli
Pull request #1005 (2023-01-30 13:37:59)

chore: adjust types for 3.1
## What/Why/How?
Make 3.1 types inline with the ones from 3.0.
Also, fix the Server Variables `description` type and delete a test type.

## Reference
https://redoc-ly.slack.com/archives/C02UHE7EL3E/p1674924924112719
https://redoc-ly.slack.com/archives/C02UHE7EL3E/p1674929643562679
https://redoc-ly.slack.com/archives/C02UHE7EL3E/p1674947396298019

## Testing

## Screenshots (optional)

## Check yourself

- [x] Code is linted
- [ ] Tested with redoc/reference-docs/workflows
- [ ] All new/updated code is covered with tests

## Security

- [x] Security impact of change has been considered
- [x] 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.79%     |    3432/4651    |
|                                                                           🟡                                                                           | Branches   | 65.28%     |    1952/2990    |
|                                                                           🟡                                                                           | Functions  | 66.06%     |     578/875     |
|                                                                           🟡                                                                           | Lines      | 73.81%     |    3191/4323    |


## Test suite run success
561 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 50f9adc953a395574c5abd00a5be219b67471295</p>


Patch:
diff --git a/packages/core/src/types/oas3.ts b/packages/core/src/types/oas3.ts
index 0960db45..58358b1f 100755
--- a/packages/core/src/types/oas3.ts
+++ b/packages/core/src/types/oas3.ts
@@ -66,7 +66,7 @@ const ServerVariable: NodeType = {
       items: { type: 'string' },
     },
     default: { type: 'string' },
-    description: null,
+    description: { type: 'string' },
   },
   required: ['default'],
   extensionsPrefix: 'x-',
diff --git a/packages/core/src/types/oas3_1.ts b/packages/core/src/types/oas3_1.ts
index 598e2d2a..4a8a49ef 100755
--- a/packages/core/src/types/oas3_1.ts
+++ b/packages/core/src/types/oas3_1.ts
@@ -5,9 +5,9 @@ const Root: NodeType = {
   properties: {
     openapi: null,
     info: 'Info',
-    servers: listOf('Server'),
-    security: listOf('SecurityRequirement'),
-    tags: listOf('Tag'),
+    servers: 'ServerList',
+    security: 'SecurityRequirementList',
+    tags: 'TagList',
     externalDocs: 'ExternalDocs',
     paths: 'Paths',
     webhooks: 'WebhooksMap',
@@ -70,15 +70,15 @@ const Operation: NodeType = {
     description: { type: 'string' },
     externalDocs: 'ExternalDocs',
     operationId: { type: 'string' },
-    parameters: listOf('Parameter'),
-    security: listOf('SecurityRequirement'),
-    servers: listOf('Server'),
+    parameters: 'ParameterList',
+    security: 'SecurityRequirementList',
+    servers: 'ServerList',
     requestBody: 'RequestBody',
     responses: 'Responses',
     deprecated: { type: 'boolean' },
-    callbacks: mapOf('Callback'),
-    'x-codeSamples': listOf('XCodeSample'),
-    'x-code-samples': listOf('XCodeSample'), // deprecated
+    callbacks: 'CallbacksMap',
+    'x-codeSamples': 'XCodeSampleList',
+    'x-code-samples': 'XCodeSampleList', // deprecated
     'x-hideTryItPanel': { type: 'boolean' },
   },
   extensionsPrefix: 'x-',
@@ -95,7 +95,6 @@ const Schema: NodeType = {
     $vocabulary: { type: 'string' },
     externalDocs: 'ExternalDocs',
     discriminator: 'Discriminator',
-    myArbitraryKeyword: { type: 'boolean' },
     title: { type: 'string' },
     multipleOf: { type: 'number', minimum: 0 },
     maximum: { type: 'number' },


Test patch:
diff --git a/__tests__/lint/oas3.1/openapi.yaml b/__tests__/lint/oas3.1/openapi.yaml
index 09e8651e..fc719698 100644
--- a/__tests__/lint/oas3.1/openapi.yaml
+++ b/__tests__/lint/oas3.1/openapi.yaml
@@ -241,7 +241,6 @@ components:
       discriminator:
         propertyName: type
         x-extension: true
-      myArbitraryKeyword: true
     Pets:
       type: array
       items:
diff --git a/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts b/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts
index 50a155d2..06184bb0 100644
--- a/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts
+++ b/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts
@@ -414,7 +414,6 @@ describe('OpenAPI Schema', () => {
     `);
   });
 
-  //Check: No error
   it('should report if description in variable is not a string', async () => {
     const source = outdent`
       openapi: 3.0.2
@@ -448,7 +447,14 @@ describe('OpenAPI Schema', () => {
       await validateDoc(source, {
         spec: 'error',
       })
-    ).toMatchInlineSnapshot(`Array []`);
+    ).toMatchInlineSnapshot(`
+      Array [
+        Object {
+          "location": "#/servers/0/variables/username/description",
+          "message": "Expected type \`string\` but got \`null\`.",
+        },
+      ]
+    `);
   });
 
   it('should not report if servers property is not provided', async () => {