@redocly/openapi-core 1.0.0-beta.105 → 1.0.0-beta.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +4 -4
  2. package/__tests__/utils.ts +5 -5
  3. package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
  4. package/lib/benchmark/utils.d.ts +2 -2
  5. package/lib/benchmark/utils.js +2 -2
  6. package/lib/bundle.d.ts +2 -2
  7. package/lib/bundle.js +2 -2
  8. package/lib/config/all.d.ts +2 -2
  9. package/lib/config/all.js +1 -1
  10. package/lib/config/builtIn.d.ts +2 -2
  11. package/lib/config/builtIn.js +2 -2
  12. package/lib/config/config-resolvers.d.ts +5 -5
  13. package/lib/config/config-resolvers.js +39 -36
  14. package/lib/config/config.d.ts +5 -5
  15. package/lib/config/config.js +4 -4
  16. package/lib/config/load.js +4 -4
  17. package/lib/config/minimal.d.ts +2 -2
  18. package/lib/config/minimal.js +1 -1
  19. package/lib/config/recommended.d.ts +2 -2
  20. package/lib/config/recommended.js +1 -1
  21. package/lib/config/rules.d.ts +2 -2
  22. package/lib/config/rules.js +1 -1
  23. package/lib/config/types.d.ts +23 -19
  24. package/lib/config/utils.d.ts +5 -5
  25. package/lib/config/utils.js +43 -26
  26. package/lib/decorators/common/remove-x-internal.js +2 -2
  27. package/lib/format/format.js +1 -1
  28. package/lib/index.d.ts +1 -1
  29. package/lib/index.js +2 -2
  30. package/lib/js-yaml/index.js +1 -6
  31. package/lib/lint.d.ts +2 -2
  32. package/lib/lint.js +16 -6
  33. package/lib/redocly/registry-api.d.ts +1 -1
  34. package/lib/redocly/registry-api.js +2 -2
  35. package/lib/rules/common/info-license-url.d.ts +1 -1
  36. package/lib/rules/common/info-license-url.js +5 -10
  37. package/lib/rules/common/info-license.d.ts +2 -0
  38. package/lib/rules/common/info-license.js +17 -0
  39. package/lib/rules/common/no-enum-type-mismatch.js +1 -3
  40. package/lib/rules/common/operation-operationId.js +1 -1
  41. package/lib/rules/common/path-not-include-query.js +1 -1
  42. package/lib/rules/common/paths-kebab-case.js +4 -1
  43. package/lib/rules/common/spec.js +1 -1
  44. package/lib/rules/oas2/index.js +4 -4
  45. package/lib/rules/oas2/remove-unused-components.js +3 -3
  46. package/lib/rules/oas3/index.js +4 -4
  47. package/lib/rules/oas3/no-empty-servers.js +1 -1
  48. package/lib/rules/oas3/remove-unused-components.js +2 -2
  49. package/lib/rules/other/stats.js +43 -14
  50. package/lib/rules/utils.d.ts +1 -1
  51. package/lib/rules/utils.js +4 -1
  52. package/lib/types/index.d.ts +2 -2
  53. package/lib/types/redocly-yaml.js +8 -7
  54. package/package.json +1 -1
  55. package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
  56. package/src/__tests__/bundle.test.ts +68 -34
  57. package/src/__tests__/codeframes.test.ts +13 -14
  58. package/src/__tests__/js-yaml.test.ts +6 -4
  59. package/src/__tests__/lint.test.ts +74 -6
  60. package/src/__tests__/login.test.ts +2 -2
  61. package/src/__tests__/normalizeVisitors.test.ts +4 -4
  62. package/src/__tests__/ref-utils.test.ts +13 -13
  63. package/src/__tests__/resolve-http.test.ts +1 -1
  64. package/src/__tests__/resolve.test.ts +14 -11
  65. package/src/__tests__/walk.test.ts +48 -56
  66. package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
  67. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
  68. package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
  69. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -1
  70. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
  71. package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
  72. package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
  73. package/src/benchmark/benchmark.js +9 -5
  74. package/src/benchmark/utils.ts +5 -5
  75. package/src/bundle.ts +18 -17
  76. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +1 -1
  77. package/src/config/__tests__/config-resolvers.test.ts +123 -121
  78. package/src/config/__tests__/config.test.ts +76 -76
  79. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
  80. package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
  81. package/src/config/__tests__/resolve-plugins.test.ts +3 -3
  82. package/src/config/__tests__/utils.test.ts +83 -0
  83. package/src/config/all.ts +3 -4
  84. package/src/config/builtIn.ts +5 -5
  85. package/src/config/config-resolvers.ts +122 -83
  86. package/src/config/config.ts +5 -5
  87. package/src/config/load.ts +6 -6
  88. package/src/config/minimal.ts +3 -3
  89. package/src/config/recommended.ts +3 -3
  90. package/src/config/rules.ts +6 -6
  91. package/src/config/types.ts +28 -19
  92. package/src/config/utils.ts +70 -50
  93. package/src/decorators/__tests__/filter-out.test.ts +8 -4
  94. package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
  95. package/src/decorators/common/filters/filter-helper.ts +1 -1
  96. package/src/decorators/common/info-description-override.ts +1 -1
  97. package/src/decorators/common/operation-description-override.ts +1 -1
  98. package/src/decorators/common/remove-x-internal.ts +4 -4
  99. package/src/decorators/common/tag-description-override.ts +1 -1
  100. package/src/format/codeframes.ts +4 -4
  101. package/src/format/format.ts +10 -10
  102. package/src/index.ts +2 -3
  103. package/src/js-yaml/index.ts +3 -8
  104. package/src/lint.ts +22 -18
  105. package/src/oas-types.ts +1 -6
  106. package/src/redocly/__tests__/redocly-client.test.ts +25 -19
  107. package/src/redocly/index.ts +6 -4
  108. package/src/redocly/registry-api.ts +6 -6
  109. package/src/ref-utils.ts +2 -2
  110. package/src/resolve.ts +7 -4
  111. package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
  112. package/src/rules/__tests__/utils.test.ts +122 -0
  113. package/src/rules/ajv.ts +3 -4
  114. package/src/rules/common/__tests__/info-description.test.ts +3 -3
  115. package/src/rules/common/__tests__/info-license.test.ts +2 -2
  116. package/src/rules/common/__tests__/license-url.test.ts +2 -2
  117. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
  118. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
  119. package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
  120. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
  121. package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
  122. package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
  123. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
  124. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
  125. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
  126. package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
  127. package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
  128. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
  129. package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
  130. package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
  131. package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
  132. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
  133. package/src/rules/common/__tests__/spec.test.ts +2 -2
  134. package/src/rules/common/__tests__/tag-description.test.ts +2 -2
  135. package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
  136. package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
  137. package/src/rules/common/assertions/index.ts +6 -6
  138. package/src/rules/common/info-license-url.ts +4 -9
  139. package/src/rules/common/info-license.ts +15 -0
  140. package/src/rules/common/no-ambiguous-paths.ts +1 -1
  141. package/src/rules/common/no-enum-type-mismatch.ts +12 -9
  142. package/src/rules/common/no-invalid-parameter-examples.ts +2 -2
  143. package/src/rules/common/no-invalid-schema-examples.ts +1 -1
  144. package/src/rules/common/operation-operationId.ts +1 -1
  145. package/src/rules/common/operation-parameters-unique.ts +2 -2
  146. package/src/rules/common/path-not-include-query.ts +1 -1
  147. package/src/rules/common/path-params-defined.ts +1 -1
  148. package/src/rules/common/paths-kebab-case.ts +4 -1
  149. package/src/rules/common/scalar-property-missing-example.ts +1 -1
  150. package/src/rules/common/spec.ts +10 -7
  151. package/src/rules/no-unresolved-refs.ts +1 -1
  152. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  153. package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
  154. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  155. package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
  156. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
  157. package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
  158. package/src/rules/oas2/index.ts +3 -3
  159. package/src/rules/oas2/remove-unused-components.ts +13 -8
  160. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  161. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
  162. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +8 -8
  163. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
  164. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
  165. package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
  166. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  167. package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
  168. package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
  169. package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
  170. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
  171. package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
  172. package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
  173. package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
  174. package/src/rules/oas3/index.ts +3 -3
  175. package/src/rules/oas3/no-empty-servers.ts +1 -1
  176. package/src/rules/oas3/no-invalid-media-type-examples.ts +12 -4
  177. package/src/rules/oas3/no-servers-empty-enum.ts +9 -10
  178. package/src/rules/oas3/remove-unused-components.ts +18 -7
  179. package/src/rules/other/stats.ts +46 -17
  180. package/src/rules/utils.ts +5 -3
  181. package/src/types/index.ts +5 -5
  182. package/src/types/redocly-yaml.ts +8 -7
  183. package/src/typings/common.ts +9 -1
  184. package/src/typings/openapi.ts +1 -1
  185. package/src/visitors.ts +4 -4
  186. package/tsconfig.tsbuildinfo +1 -1
  187. package/lib/rules/common/license-url.d.ts +0 -2
  188. package/lib/rules/common/license-url.js +0 -12
  189. package/src/rules/common/license-url.ts +0 -10
@@ -22,7 +22,7 @@ export declare type NodeType = {
22
22
  items?: string;
23
23
  required?: string[] | ((value: any, key: string | number | undefined) => string[]);
24
24
  requiredOneOf?: string[];
25
- allowed?: ((value: any) => string[] | undefined);
25
+ allowed?: (value: any) => string[] | undefined;
26
26
  extensionsPrefix?: string;
27
27
  };
28
28
  declare type PropType = string | NodeType | ScalarSchema | undefined | null;
@@ -34,7 +34,7 @@ export declare type NormalizedNodeType = {
34
34
  items?: NormalizedNodeType;
35
35
  required?: string[] | ((value: any, key: string | number | undefined) => string[]);
36
36
  requiredOneOf?: string[];
37
- allowed?: ((value: any) => string[] | undefined);
37
+ allowed?: (value: any) => string[] | undefined;
38
38
  extensionsPrefix?: string;
39
39
  };
40
40
  declare type NormalizedPropType = NormalizedNodeType | NormalizedScalarSchema | undefined | null;
@@ -112,7 +112,8 @@ const ConfigRoot = {
112
112
  properties: {},
113
113
  additionalProperties: { properties: { type: 'string' } },
114
114
  },
115
- lint: 'RootConfigLint',
115
+ styleguide: 'RootConfigStyleguide',
116
+ lint: 'RootConfigStyleguide',
116
117
  'features.openapi': 'ConfigReferenceDocs',
117
118
  referenceDocs: 'ConfigReferenceDocs',
118
119
  'features.mockServer': 'ConfigMockServer',
@@ -137,7 +138,7 @@ const ConfigApisProperties = {
137
138
  type: 'string',
138
139
  },
139
140
  },
140
- lint: 'ConfigLint',
141
+ styleguide: 'ConfigStyleguide',
141
142
  'features.openapi': 'ConfigReferenceDocs',
142
143
  'features.mockServer': 'ConfigMockServer',
143
144
  },
@@ -153,7 +154,7 @@ const ConfigHTTP = {
153
154
  },
154
155
  },
155
156
  };
156
- const ConfigLint = {
157
+ const ConfigStyleguide = {
157
158
  properties: {
158
159
  extends: {
159
160
  type: 'array',
@@ -176,11 +177,11 @@ const ConfigLint = {
176
177
  oas3_1Decorators: { type: 'object' },
177
178
  },
178
179
  };
179
- const RootConfigLint = {
180
+ const RootConfigStyleguide = {
180
181
  properties: Object.assign({ plugins: {
181
182
  type: 'array',
182
183
  items: { type: 'string' },
183
- } }, ConfigLint.properties),
184
+ } }, ConfigStyleguide.properties),
184
185
  };
185
186
  const Rules = {
186
187
  properties: {},
@@ -765,8 +766,8 @@ exports.ConfigTypes = {
765
766
  ConfigRoot,
766
767
  ConfigApis,
767
768
  ConfigApisProperties,
768
- RootConfigLint,
769
- ConfigLint,
769
+ RootConfigStyleguide,
770
+ ConfigStyleguide,
770
771
  ConfigReferenceDocs,
771
772
  ConfigMockServer,
772
773
  ConfigHTTP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.0.0-beta.105",
3
+ "version": "1.0.0-beta.106",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -1,5 +1,146 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`bundle should add to meta ref from redocly registry 1`] = `
4
+ fileDependencies: {}
5
+ rootType:
6
+ properties:
7
+ openapi: null
8
+ info:
9
+ properties:
10
+ title:
11
+ type: string
12
+ version:
13
+ type: string
14
+ description:
15
+ type: string
16
+ termsOfService:
17
+ type: string
18
+ contact:
19
+ properties:
20
+ name:
21
+ type: string
22
+ url:
23
+ type: string
24
+ email:
25
+ type: string
26
+ name: Contact
27
+ license:
28
+ properties:
29
+ name:
30
+ type: string
31
+ url:
32
+ type: string
33
+ required:
34
+ - name
35
+ name: License
36
+ required:
37
+ - title
38
+ - version
39
+ name: Info
40
+ servers:
41
+ name: ServerList
42
+ properties: {}
43
+ items:
44
+ properties:
45
+ url:
46
+ type: string
47
+ description:
48
+ type: string
49
+ variables:
50
+ name: ServerVariableMap
51
+ properties: {}
52
+ required:
53
+ - url
54
+ name: Server
55
+ security:
56
+ name: SecurityRequirementList
57
+ properties: {}
58
+ items:
59
+ properties: {}
60
+ additionalProperties:
61
+ type: array
62
+ items:
63
+ type: string
64
+ name: SecurityRequirement
65
+ tags:
66
+ name: TagList
67
+ properties: {}
68
+ items:
69
+ properties:
70
+ name:
71
+ type: string
72
+ description:
73
+ type: string
74
+ externalDocs:
75
+ properties:
76
+ description:
77
+ type: string
78
+ url:
79
+ type: string
80
+ required:
81
+ - url
82
+ name: ExternalDocs
83
+ required:
84
+ - name
85
+ name: Tag
86
+ externalDocs:
87
+ properties:
88
+ description:
89
+ type: string
90
+ url:
91
+ type: string
92
+ required:
93
+ - url
94
+ name: ExternalDocs
95
+ paths:
96
+ properties: {}
97
+ name: PathMap
98
+ components:
99
+ properties:
100
+ parameters:
101
+ name: NamedParameters
102
+ properties: {}
103
+ schemas:
104
+ name: NamedSchemas
105
+ properties: {}
106
+ responses:
107
+ name: NamedResponses
108
+ properties: {}
109
+ examples:
110
+ name: NamedExamples
111
+ properties: {}
112
+ requestBodies:
113
+ name: NamedRequestBodies
114
+ properties: {}
115
+ headers:
116
+ name: NamedHeaders
117
+ properties: {}
118
+ securitySchemes:
119
+ name: NamedSecuritySchemes
120
+ properties: {}
121
+ links:
122
+ name: NamedLinks
123
+ properties: {}
124
+ callbacks:
125
+ name: NamedCallbacks
126
+ properties: {}
127
+ name: Components
128
+ x-webhooks:
129
+ properties: {}
130
+ name: WebhooksMap
131
+ required:
132
+ - openapi
133
+ - paths
134
+ - info
135
+ name: DefinitionRoot
136
+ refTypes: {}
137
+ visitorsData:
138
+ registry-dependencies:
139
+ links:
140
+ - https://api.redocly.com/registry/params
141
+
142
+ `;
143
+
3
144
  exports[`bundle should bundle external refs 1`] = `
4
145
  openapi: 3.0.0
5
146
  paths:
@@ -2,11 +2,21 @@ import outdent from 'outdent';
2
2
  import * as path from 'path';
3
3
 
4
4
  import { bundleDocument, bundle } from '../bundle';
5
- import { parseYamlToDocument, yamlSerializer } from '../../__tests__/utils';
6
- import { LintConfig, Config, ResolvedConfig } from '../config';
5
+ import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../__tests__/utils';
6
+ import { StyleguideConfig, Config, ResolvedConfig } from '../config';
7
7
  import { BaseResolver } from '../resolve';
8
8
 
9
9
  describe('bundle', () => {
10
+ const fetchMock = jest.fn(() =>
11
+ Promise.resolve({
12
+ ok: true,
13
+ text: () => 'External schema content',
14
+ headers: {
15
+ get: () => '',
16
+ },
17
+ })
18
+ );
19
+
10
20
  expect.addSnapshotSerializer(yamlSerializer);
11
21
 
12
22
  const testDocument = parseYamlToDocument(
@@ -28,14 +38,14 @@ describe('bundle', () => {
28
38
  shared_a:
29
39
  name: shared-a
30
40
  `,
31
- '',
41
+ ''
32
42
  );
33
43
 
34
44
  it('change nothing with only internal refs', async () => {
35
45
  const { bundle, problems } = await bundleDocument({
36
46
  document: testDocument,
37
47
  externalRefResolver: new BaseResolver(),
38
- config: new LintConfig({}),
48
+ config: new StyleguideConfig({}),
39
49
  });
40
50
 
41
51
  const origCopy = JSON.parse(JSON.stringify(testDocument.parsed));
@@ -60,7 +70,7 @@ describe('bundle', () => {
60
70
  });
61
71
  expect(problems).toHaveLength(1);
62
72
  expect(problems[0].message).toEqual(
63
- `Two schemas are referenced with the same name but different content. Renamed param-b to param-b-2.`,
73
+ `Two schemas are referenced with the same name but different content. Renamed param-b to param-b-2.`
64
74
  );
65
75
  expect(res.parsed).toMatchSnapshot();
66
76
  });
@@ -68,7 +78,7 @@ describe('bundle', () => {
68
78
  it('should dereferenced correctly when used with dereference', async () => {
69
79
  const { bundle: res, problems } = await bundleDocument({
70
80
  externalRefResolver: new BaseResolver(),
71
- config: new LintConfig({}),
81
+ config: new StyleguideConfig({}),
72
82
  document: testDocument,
73
83
  dereference: true,
74
84
  });
@@ -98,47 +108,25 @@ describe('bundle', () => {
98
108
  });
99
109
 
100
110
  it('should pull hosted schema', async () => {
101
- const fetchMock = jest.fn(
102
- () => Promise.resolve({
103
- ok: true,
104
- text: () => 'External schema content',
105
- headers: {
106
- get: () => ''
107
- }
108
- })
109
- );
110
-
111
111
  const { bundle: res, problems } = await bundle({
112
112
  config: new Config({} as ResolvedConfig),
113
113
  externalRefResolver: new BaseResolver({
114
114
  http: {
115
115
  customFetch: fetchMock,
116
- headers: []
117
- }
116
+ headers: [],
117
+ },
118
118
  }),
119
- ref: path.join(__dirname, 'fixtures/refs/hosted.yaml')
119
+ ref: path.join(__dirname, 'fixtures/refs/hosted.yaml'),
120
120
  });
121
121
 
122
122
  expect(problems).toHaveLength(0);
123
- expect(fetchMock).toHaveBeenCalledWith(
124
- "https://someexternal.schema",
125
- {
126
- headers: {}
127
- }
128
- );
123
+ expect(fetchMock).toHaveBeenCalledWith('https://someexternal.schema', {
124
+ headers: {},
125
+ });
129
126
  expect(res.parsed).toMatchSnapshot();
130
127
  });
131
128
 
132
129
  it('should not bundle url refs if used with keepUrlRefs', async () => {
133
- const fetchMock = jest.fn(() =>
134
- Promise.resolve({
135
- ok: true,
136
- text: () => 'External schema content',
137
- headers: {
138
- get: () => '',
139
- },
140
- }),
141
- );
142
130
  const { bundle: res, problems } = await bundle({
143
131
  config: new Config({} as ResolvedConfig),
144
132
  externalRefResolver: new BaseResolver({
@@ -153,4 +141,50 @@ describe('bundle', () => {
153
141
  expect(problems).toHaveLength(0);
154
142
  expect(res.parsed).toMatchSnapshot();
155
143
  });
144
+
145
+ it('should add to meta ref from redocly registry', async () => {
146
+ const testDocument = parseYamlToDocument(
147
+ outdent`
148
+ openapi: 3.0.0
149
+ paths:
150
+ /pet:
151
+ get:
152
+ operationId: get
153
+ parameters:
154
+ - $ref: '#/components/parameters/shared_a'
155
+ - name: get_b
156
+ post:
157
+ operationId: post
158
+ parameters:
159
+ - $ref: 'https://api.redocly.com/registry/params'
160
+ components:
161
+ parameters:
162
+ shared_a:
163
+ name: shared-a
164
+ `,
165
+ ''
166
+ );
167
+
168
+ const config = await makeConfig({}, { 'registry-dependencies': 'on' });
169
+
170
+ const {
171
+ bundle: result,
172
+ problems,
173
+ ...meta
174
+ } = await bundleDocument({
175
+ document: testDocument,
176
+ config: config,
177
+ externalRefResolver: new BaseResolver({
178
+ http: {
179
+ customFetch: fetchMock,
180
+ headers: [],
181
+ },
182
+ }),
183
+ });
184
+
185
+ const parsedMeta = JSON.parse(JSON.stringify(meta));
186
+
187
+ expect(problems).toHaveLength(0);
188
+ expect(parsedMeta).toMatchSnapshot();
189
+ });
156
190
  });
@@ -17,7 +17,7 @@ describe('Location', () => {
17
17
  license:
18
18
  name: MIT
19
19
  url: https://google.com
20
- `,
20
+ `
21
21
  ),
22
22
  };
23
23
  const preciseLocation = getLineColLocation(loc);
@@ -37,7 +37,7 @@ describe('Location', () => {
37
37
  license:
38
38
  name: MIT
39
39
  url: https://google.com
40
- `,
40
+ `
41
41
  ),
42
42
  };
43
43
  const preciseLocation = getLineColLocation(loc);
@@ -57,7 +57,7 @@ describe('Location', () => {
57
57
  license:
58
58
  name: MIT
59
59
  url: https://google.com
60
- `,
60
+ `
61
61
  ),
62
62
  };
63
63
  const preciseLocation = getLineColLocation(loc);
@@ -77,7 +77,7 @@ describe('Location', () => {
77
77
  license:
78
78
  name: MIT
79
79
  url: https://google.com
80
- `,
80
+ `
81
81
  ),
82
82
  };
83
83
  const preciseLocation = getLineColLocation(loc);
@@ -98,7 +98,7 @@ describe('Location', () => {
98
98
  license:
99
99
  name: MIT
100
100
  url: https://google.com
101
- `,
101
+ `
102
102
  ),
103
103
  };
104
104
  const preciseLocation = getLineColLocation(loc);
@@ -106,7 +106,6 @@ describe('Location', () => {
106
106
  expect(preciseLocation.end).toEqual({ line: 2, col: 9 });
107
107
  });
108
108
 
109
-
110
109
  it('should return first line for empty doc', () => {
111
110
  const loc = {
112
111
  reportOnKey: false,
@@ -158,7 +157,7 @@ describe('codeframes', () => {
158
157
  license:
159
158
  name: MIT
160
159
  url: https://google.com
161
- `,
160
+ `
162
161
  ),
163
162
  };
164
163
 
@@ -222,7 +221,7 @@ describe('codeframes', () => {
222
221
  license:
223
222
  name: MIT
224
223
  url: https://google.com
225
- `,
224
+ `
226
225
  ),
227
226
  };
228
227
 
@@ -256,7 +255,7 @@ describe('codeframes', () => {
256
255
  name: MIT,
257
256
  url: https://google.com
258
257
  }
259
- `,
258
+ `
260
259
  ),
261
260
  };
262
261
 
@@ -299,7 +298,7 @@ describe('codeframes', () => {
299
298
  field5: MIT
300
299
  url: https://google.com
301
300
  openapi: 3.0.2
302
- `,
301
+ `
303
302
  ),
304
303
  };
305
304
 
@@ -343,7 +342,7 @@ describe('codeframes', () => {
343
342
  field3: MIT
344
343
  field4: MIT
345
344
  field5: MIT
346
- `,
345
+ `
347
346
  ),
348
347
  };
349
348
 
@@ -390,7 +389,7 @@ describe('codeframes', () => {
390
389
  in: wrong
391
390
  post:
392
391
  operationId: test2
393
- `,
392
+ `
394
393
  ),
395
394
  };
396
395
 
@@ -425,7 +424,7 @@ describe('codeframes', () => {
425
424
  license:
426
425
  name: MIT
427
426
  url: https://google.com
428
- `,
427
+ `
429
428
  ),
430
429
  };
431
430
 
@@ -483,7 +482,7 @@ describe('codeframes', () => {
483
482
  license:
484
483
  name: MIT
485
484
  url: https://google.com
486
- `,
485
+ `
487
486
  ),
488
487
  };
489
488
 
@@ -48,7 +48,7 @@ describe('js-yaml', () => {
48
48
 
49
49
  test('should correctly dump date and string', () => {
50
50
  expect(stringifyYaml(parseYaml(yamlToDump))).toMatchInlineSnapshot(
51
- `
51
+ `
52
52
  "date: '2022-01-21T11:29:56.694Z'
53
53
  dateWithoutQuotes: '2020-01-01'
54
54
  dateWithQuotes: '2020-01-01'
@@ -57,7 +57,8 @@ describe('js-yaml', () => {
57
57
  stringWithQuotes: test
58
58
  stringWithDoubleQuotes: test
59
59
  "
60
- `);
60
+ `
61
+ );
61
62
  });
62
63
 
63
64
  test('parse and stringify', () => {
@@ -65,7 +66,8 @@ describe('js-yaml', () => {
65
66
  });
66
67
 
67
68
  test('should throw an error for unsupported types', () => {
68
- expect(() => stringifyYaml({ foo: () => {} }))
69
- .toThrow('unacceptable kind of an object to dump [object Function]');
69
+ expect(() => stringifyYaml({ foo: () => {} })).toThrow(
70
+ 'unacceptable kind of an object to dump [object Function]'
71
+ );
70
72
  });
71
73
  });
@@ -49,7 +49,7 @@ describe('lint', () => {
49
49
  const document = parseYamlToDocument(
50
50
  outdent`
51
51
  apis: error string
52
- lint:
52
+ styleguide:
53
53
  plugins:
54
54
  - './local-plugin.js'
55
55
  extends:
@@ -107,14 +107,82 @@ describe('lint', () => {
107
107
  `);
108
108
  });
109
109
 
110
- it("'plugins' shouldn't be allowed in 'apis' -> 'lint' field", async () => {
110
+ it('lintConfig should detect wrong fields and suggest correct ones', async () => {
111
+ const document = parseYamlToDocument(
112
+ outdent`
113
+ api:
114
+ name@version:
115
+ root: ./file.yaml
116
+ syleguide:
117
+ rules:
118
+ operation-2xx-response: warn
119
+ `,
120
+ ''
121
+ );
122
+ const results = await lintConfig({ document });
123
+
124
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
125
+ Array [
126
+ Object {
127
+ "location": Array [
128
+ Object {
129
+ "pointer": "#/api",
130
+ "reportOnKey": true,
131
+ "source": "",
132
+ },
133
+ ],
134
+ "message": "Property \`api\` is not expected here.",
135
+ "ruleId": "configuration spec",
136
+ "severity": "error",
137
+ "suggest": Array [
138
+ "apis",
139
+ ],
140
+ },
141
+ Object {
142
+ "location": Array [
143
+ Object {
144
+ "pointer": "#/syleguide",
145
+ "reportOnKey": true,
146
+ "source": "",
147
+ },
148
+ ],
149
+ "message": "Property \`syleguide\` is not expected here.",
150
+ "ruleId": "configuration spec",
151
+ "severity": "error",
152
+ "suggest": Array [
153
+ "styleguide",
154
+ ],
155
+ },
156
+ ]
157
+ `);
158
+ });
159
+
160
+ it('lintConfig should work with legacy fields', async () => {
161
+ const document = parseYamlToDocument(
162
+ outdent`
163
+ apiDefinitions:
164
+ entry: ./file.yaml
165
+ lint:
166
+ rules:
167
+ operation-2xx-response: warn
168
+ referenceDocs:
169
+ showConsole: true
170
+ `,
171
+ ''
172
+ );
173
+ const results = await lintConfig({ document });
174
+
175
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
176
+ });
177
+
178
+ it("'plugins' shouldn't be allowed in 'apis' -> 'styleguide' field", async () => {
111
179
  const document = parseYamlToDocument(
112
180
  outdent`
113
181
  apis:
114
- lint:
182
+ styleguide:
115
183
  plugins:
116
184
  - './local-plugin.js'
117
- lint:
185
+ styleguide:
118
186
  plugins:
119
187
  - './local-plugin.js'
120
188
  `,
@@ -127,7 +195,7 @@ describe('lint', () => {
127
195
  Object {
128
196
  "location": Array [
129
197
  Object {
130
- "pointer": "#/apis/lint",
198
+ "pointer": "#/apis/styleguide",
131
199
  "reportOnKey": true,
132
200
  "source": "",
133
201
  },
@@ -140,7 +208,7 @@ describe('lint', () => {
140
208
  Object {
141
209
  "location": Array [
142
210
  Object {
143
- "pointer": "#/apis/lint/plugins",
211
+ "pointer": "#/apis/styleguide/plugins",
144
212
  "reportOnKey": true,
145
213
  "source": "",
146
214
  },
@@ -6,10 +6,10 @@ describe.skip('login', () => {
6
6
  Object.defineProperty(client, 'registryApi', {
7
7
  value: {
8
8
  setAccessTokens: jest.fn(),
9
- authStatus: jest.fn(() => true)
9
+ authStatus: jest.fn(() => true),
10
10
  },
11
11
  writable: true,
12
- configurable: true
12
+ configurable: true,
13
13
  });
14
14
  await client.login('token'); // TODO: bug with rewrite local config file
15
15
  expect(client.registryApi.setAccessTokens).toHaveBeenCalled();
@@ -22,7 +22,7 @@ describe('Normalize visitors', () => {
22
22
  ruleId,
23
23
  severity: 'error' as 'error',
24
24
  visitor: ruleset[ruleId]({}),
25
- })),
25
+ }))
26
26
  );
27
27
 
28
28
  const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
@@ -66,7 +66,7 @@ describe('Normalize visitors', () => {
66
66
  ruleId,
67
67
  severity: 'error' as 'error',
68
68
  visitor: ruleset[ruleId]({}),
69
- })),
69
+ }))
70
70
  );
71
71
 
72
72
  const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
@@ -104,7 +104,7 @@ describe('Normalize visitors', () => {
104
104
  ruleId,
105
105
  severity: 'error' as 'error',
106
106
  visitor: ruleset[ruleId]({}),
107
- })),
107
+ }))
108
108
  );
109
109
 
110
110
  const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
@@ -139,7 +139,7 @@ describe('Normalize visitors', () => {
139
139
  ruleId,
140
140
  severity: 'error' as 'error',
141
141
  visitor: ruleset[ruleId]({}),
142
- })),
142
+ }))
143
143
  );
144
144
 
145
145
  const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));