@redocly/openapi-core 1.0.2 → 1.2.0

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 (80) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/bundle.d.ts +2 -2
  3. package/lib/bundle.js +24 -22
  4. package/lib/config/builtIn.js +4 -0
  5. package/lib/config/config-resolvers.js +19 -6
  6. package/lib/config/config.d.ts +9 -9
  7. package/lib/config/config.js +32 -17
  8. package/lib/config/rules.d.ts +2 -2
  9. package/lib/config/types.d.ts +9 -3
  10. package/lib/format/codeframes.d.ts +1 -1
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.js +7 -6
  13. package/lib/lint.js +10 -16
  14. package/lib/oas-types.d.ts +16 -10
  15. package/lib/oas-types.js +52 -26
  16. package/lib/rules/async2/channels-kebab-case.d.ts +2 -0
  17. package/lib/rules/async2/channels-kebab-case.js +19 -0
  18. package/lib/rules/async2/index.d.ts +12 -0
  19. package/lib/rules/async2/index.js +22 -0
  20. package/lib/rules/async2/no-channel-trailing-slash.d.ts +2 -0
  21. package/lib/rules/async2/no-channel-trailing-slash.js +16 -0
  22. package/lib/rules/common/no-path-trailing-slash.js +2 -2
  23. package/lib/rules/common/scalar-property-missing-example.js +1 -1
  24. package/lib/rules/common/spec.d.ts +2 -2
  25. package/lib/rules/common/spec.js +3 -3
  26. package/lib/rules/common/tags-alphabetical.js +5 -2
  27. package/lib/rules/oas2/index.js +1 -1
  28. package/lib/rules/oas2/remove-unused-components.js +4 -1
  29. package/lib/rules/oas3/index.js +1 -1
  30. package/lib/rules/oas3/remove-unused-components.js +4 -1
  31. package/lib/rules/utils.d.ts +1 -1
  32. package/lib/types/asyncapi.d.ts +2 -0
  33. package/lib/types/asyncapi.js +1027 -0
  34. package/lib/types/portal-config-schema.d.ts +2533 -0
  35. package/lib/types/portal-config-schema.js +304 -0
  36. package/lib/types/redocly-yaml.js +26 -20
  37. package/lib/types/{config-external-schemas.d.ts → theme-config.d.ts} +140 -575
  38. package/lib/types/{config-external-schemas.js → theme-config.js} +55 -261
  39. package/lib/typings/asyncapi.d.ts +21 -0
  40. package/lib/typings/asyncapi.js +2 -0
  41. package/lib/visitors.d.ts +12 -0
  42. package/lib/walk.d.ts +3 -3
  43. package/package.json +3 -2
  44. package/src/__tests__/lint.test.ts +38 -6
  45. package/src/bundle.ts +27 -28
  46. package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
  47. package/src/config/__tests__/config.test.ts +15 -4
  48. package/src/config/builtIn.ts +4 -0
  49. package/src/config/config-resolvers.ts +25 -6
  50. package/src/config/config.ts +51 -27
  51. package/src/config/rules.ts +2 -2
  52. package/src/config/types.ts +14 -4
  53. package/src/index.ts +7 -1
  54. package/src/lint.ts +13 -22
  55. package/src/oas-types.ts +59 -21
  56. package/src/rules/async2/__tests__/channels-kebab-case.test.ts +141 -0
  57. package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +97 -0
  58. package/src/rules/async2/channels-kebab-case.ts +18 -0
  59. package/src/rules/async2/index.ts +22 -0
  60. package/src/rules/async2/no-channel-trailing-slash.ts +15 -0
  61. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +41 -0
  62. package/src/rules/common/__tests__/tags-alphabetical.test.ts +58 -0
  63. package/src/rules/common/no-path-trailing-slash.ts +2 -2
  64. package/src/rules/common/scalar-property-missing-example.ts +2 -2
  65. package/src/rules/common/spec.ts +2 -2
  66. package/src/rules/common/tags-alphabetical.ts +8 -4
  67. package/src/rules/oas2/__tests__/remove-unused-components.test.ts +155 -0
  68. package/src/rules/oas2/index.ts +2 -2
  69. package/src/rules/oas2/remove-unused-components.ts +6 -1
  70. package/src/rules/oas3/__tests__/remove-unused-components.test.ts +171 -0
  71. package/src/rules/oas3/index.ts +2 -2
  72. package/src/rules/oas3/remove-unused-components.ts +6 -1
  73. package/src/types/asyncapi.ts +1136 -0
  74. package/src/types/portal-config-schema.ts +343 -0
  75. package/src/types/redocly-yaml.ts +23 -34
  76. package/src/types/{config-external-schemas.ts → theme-config.ts} +60 -294
  77. package/src/typings/asyncapi.ts +26 -0
  78. package/src/visitors.ts +22 -0
  79. package/src/walk.ts +3 -3
  80. package/tsconfig.tsbuildinfo +1 -1
@@ -1,242 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.productThemeOverrideSchema = exports.themeConfigSchema = exports.mockServerConfigSchema = exports.i18nConfigSchema = exports.responseHeaderSchema = exports.devOnboardingConfigSchema = exports.seoConfigSchema = exports.redirectConfigSchema = exports.ssoConfigSchema = exports.rbacConfigSchema = void 0;
4
- const config_1 = require("../config");
5
- const oidcIssuerMetadataSchema = {
6
- type: 'object',
7
- properties: {
8
- end_session_endpoint: { type: 'string' },
9
- token_endpoint: { type: 'string' },
10
- authorization_endpoint: { type: 'string' },
11
- },
12
- required: ['token_endpoint', 'authorization_endpoint'],
13
- additionalProperties: true,
14
- };
15
- const oidcProviderConfigSchema = {
16
- type: 'object',
17
- properties: {
18
- type: { type: 'string', const: config_1.AuthProviderType.OIDC },
19
- title: { type: 'string' },
20
- configurationUrl: { type: 'string', minLength: 1 },
21
- configuration: oidcIssuerMetadataSchema,
22
- clientId: { type: 'string', minLength: 1 },
23
- clientSecret: { type: 'string', minLength: 1 },
24
- teamsClaimName: { type: 'string' },
25
- defaultTeams: { type: 'array', items: { type: 'string' } },
26
- scopes: { type: 'array', items: { type: 'string' } },
27
- tokenExpirationTime: { type: 'number' },
28
- authorizationRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
29
- tokenRequestCustomParams: { type: 'object', additionalProperties: { type: 'string' } },
30
- },
31
- required: ['type', 'clientId', 'clientSecret'],
32
- oneOf: [{ required: ['configurationUrl'] }, { required: ['configuration'] }],
33
- additionalProperties: false,
34
- };
35
- const saml2ProviderConfigSchema = {
36
- type: 'object',
37
- properties: {
38
- type: { type: 'string', const: config_1.AuthProviderType.SAML2 },
39
- title: { type: 'string' },
40
- issuerId: { type: 'string' },
41
- entityId: { type: 'string' },
42
- ssoUrl: { type: 'string' },
43
- x509PublicCert: { type: 'string' },
44
- teamsAttributeName: { type: 'string', default: config_1.DEFAULT_TEAM_CLAIM_NAME },
45
- teamsAttributeMap: { type: 'object', additionalProperties: { type: 'string' } },
46
- defaultTeams: { type: 'array', items: { type: 'string' } },
47
- },
48
- additionalProperties: false,
49
- required: ['type', 'issuerId', 'ssoUrl', 'x509PublicCert'],
50
- };
51
- const basicAuthProviderConfigSchema = {
52
- type: 'object',
53
- properties: {
54
- type: { type: 'string', const: config_1.AuthProviderType.BASIC },
55
- title: { type: 'string' },
56
- credentials: {
57
- type: 'array',
58
- items: {
59
- type: 'object',
60
- properties: {
61
- username: { type: 'string' },
62
- password: { type: 'string' },
63
- passwordHash: { type: 'string' },
64
- teams: { type: 'array', items: { type: 'string' } },
65
- },
66
- required: ['username'],
67
- additionalProperties: false,
68
- },
69
- },
70
- },
71
- required: ['type', 'credentials'],
72
- additionalProperties: false,
73
- };
74
- const authProviderConfigSchema = {
75
- oneOf: [oidcProviderConfigSchema, saml2ProviderConfigSchema, basicAuthProviderConfigSchema],
76
- discriminator: { propertyName: 'type' },
77
- };
78
- const rbacScopeItemsSchema = { type: 'object', additionalProperties: { type: 'string' } };
79
- exports.rbacConfigSchema = {
80
- type: 'object',
81
- properties: {
82
- defaults: rbacScopeItemsSchema,
83
- },
84
- additionalProperties: rbacScopeItemsSchema,
85
- };
86
- exports.ssoConfigSchema = {
87
- type: 'object',
88
- additionalProperties: authProviderConfigSchema,
89
- };
90
- exports.redirectConfigSchema = {
91
- type: 'object',
92
- properties: {
93
- to: { type: 'string' },
94
- type: { type: 'number', default: 301 },
95
- },
96
- required: ['to'],
97
- additionalProperties: false,
98
- };
99
- exports.seoConfigSchema = {
100
- type: 'object',
101
- properties: {
102
- title: { type: 'string' },
103
- description: { type: 'string' },
104
- siteUrl: { type: 'string' },
105
- image: { type: 'string' },
106
- keywords: { type: 'array', items: { type: 'string' } },
107
- lang: { type: 'string' },
108
- jsonLd: { type: 'object' },
109
- meta: {
110
- type: 'array',
111
- items: {
112
- type: 'object',
113
- properties: {
114
- name: { type: 'string' },
115
- content: { type: 'string' },
116
- },
117
- required: ['name', 'content'],
118
- additionalProperties: false,
119
- },
120
- },
121
- },
122
- additionalProperties: false,
123
- };
124
- const apigeeAdapterAuthOauth2Schema = {
125
- type: 'object',
126
- properties: {
127
- type: { type: 'string', const: config_1.ApigeeDevOnboardingIntegrationAuthType.OAUTH2 },
128
- tokenEndpoint: { type: 'string' },
129
- clientId: { type: 'string' },
130
- clientSecret: { type: 'string' },
131
- },
132
- additionalProperties: false,
133
- required: ['type', 'tokenEndpoint', 'clientId', 'clientSecret'],
134
- };
135
- const apigeeAdapterAuthServiceAccountSchema = {
136
- type: 'object',
137
- properties: {
138
- type: { type: 'string', const: config_1.ApigeeDevOnboardingIntegrationAuthType.SERVICE_ACCOUNT },
139
- serviceAccountEmail: { type: 'string' },
140
- serviceAccountPrivateKey: { type: 'string' },
141
- },
142
- additionalProperties: false,
143
- required: ['type', 'serviceAccountEmail', 'serviceAccountPrivateKey'],
144
- };
145
- const apigeeXAdapterConfigSchema = {
146
- type: 'object',
147
- properties: {
148
- type: { type: 'string', const: 'APIGEE_X' },
149
- apiUrl: { type: 'string' },
150
- stage: { type: 'string', default: 'non-production' },
151
- organizationName: { type: 'string' },
152
- ignoreApiProducts: { type: 'array', items: { type: 'string' } },
153
- allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
154
- auth: {
155
- type: 'object',
156
- oneOf: [apigeeAdapterAuthOauth2Schema, apigeeAdapterAuthServiceAccountSchema],
157
- discriminator: { propertyName: 'type' },
158
- },
159
- },
160
- additionalProperties: false,
161
- required: ['type', 'organizationName', 'auth'],
162
- };
163
- const apigeeEdgeAdapterConfigSchema = Object.assign(Object.assign({}, apigeeXAdapterConfigSchema), { properties: Object.assign(Object.assign({}, apigeeXAdapterConfigSchema.properties), { type: { type: 'string', const: 'APIGEE_EDGE' } }) });
164
- const graviteeAdapterConfigSchema = {
165
- type: 'object',
166
- properties: {
167
- type: { type: 'string', const: 'GRAVITEE' },
168
- apiBaseUrl: { type: 'string' },
169
- env: { type: 'string' },
170
- allowApiProductsOutsideCatalog: { type: 'boolean', default: false },
171
- stage: { type: 'string', default: 'non-production' },
172
- auth: { type: 'object', properties: { static: { type: 'string' } } },
173
- },
174
- additionalProperties: false,
175
- required: ['type', 'apiBaseUrl'],
176
- };
177
- const devOnboardingAdapterConfigSchema = {
178
- type: 'object',
179
- oneOf: [apigeeXAdapterConfigSchema, apigeeEdgeAdapterConfigSchema, graviteeAdapterConfigSchema],
180
- discriminator: { propertyName: 'type' },
181
- };
182
- exports.devOnboardingConfigSchema = {
183
- type: 'object',
184
- required: ['adapters'],
185
- additionalProperties: false,
186
- properties: {
187
- adapters: {
188
- type: 'array',
189
- items: devOnboardingAdapterConfigSchema,
190
- },
191
- },
192
- };
193
- exports.responseHeaderSchema = {
194
- type: 'object',
195
- properties: {
196
- name: { type: 'string' },
197
- value: { type: 'string' },
198
- },
199
- additionalProperties: false,
200
- required: ['name', 'value'],
201
- };
202
- exports.i18nConfigSchema = {
203
- type: 'object',
204
- properties: {
205
- defaultLocale: {
206
- type: 'string',
207
- },
208
- locales: {
209
- type: 'array',
210
- items: {
211
- type: 'object',
212
- properties: {
213
- code: {
214
- type: 'string',
215
- },
216
- name: {
217
- type: 'string',
218
- },
219
- },
220
- required: ['code'],
221
- },
222
- },
223
- },
224
- required: ['defaultLocale', 'locales'],
225
- };
226
- exports.mockServerConfigSchema = {
227
- type: 'object',
228
- properties: {
229
- off: { type: 'boolean', default: false },
230
- position: { type: 'string', enum: ['first', 'last', 'replace', 'off'], default: 'first' },
231
- strictExamples: { type: 'boolean', default: false },
232
- errorIfForcedExampleNotFound: { type: 'boolean', default: false },
233
- description: { type: 'string' },
234
- },
235
- };
3
+ exports.ScorecardStatus = exports.productThemeOverrideSchema = exports.themeConfigSchema = void 0;
236
4
  const logoConfigSchema = {
237
5
  type: 'object',
238
6
  properties: {
239
7
  image: { type: 'string' },
8
+ srcSet: { type: 'string' },
240
9
  altText: { type: 'string' },
241
10
  link: { type: 'string' },
242
11
  favicon: { type: 'string' },
@@ -316,7 +85,7 @@ const markdownConfigSchema = {
316
85
  },
317
86
  editPage: {
318
87
  type: 'object',
319
- properties: Object.assign({ baseUrl: { type: 'string' }, icon: { type: 'string' }, text: { type: 'string', default: 'Edit this page' } }, hideConfigSchema.properties),
88
+ properties: Object.assign({ baseUrl: { type: 'string' } }, hideConfigSchema.properties),
320
89
  additionalProperties: false,
321
90
  default: {},
322
91
  },
@@ -404,35 +173,14 @@ const googleAnalyticsConfigSchema = {
404
173
  properties: {
405
174
  includeInDevelopment: { type: 'boolean' },
406
175
  trackingId: { type: 'string' },
176
+ conversionId: { type: 'string' },
177
+ floodlightId: { type: 'string' },
407
178
  head: { type: 'boolean' },
408
179
  respectDNT: { type: 'boolean' },
409
- anonymize: { type: 'boolean' },
410
180
  exclude: { type: 'array', items: { type: 'string' } },
411
181
  optimizeId: { type: 'string' },
412
- experimentId: { type: 'string' },
413
- variationId: { type: 'string' },
414
- enableWebVitalsTracking: { type: 'boolean' },
415
- defer: { type: 'boolean' },
416
- sampleRate: { type: 'number' },
417
- name: { type: 'string' },
418
- clientId: { type: 'string' },
419
- siteSpeedSampleRate: { type: 'number' },
420
- alwaysSendReferrer: { type: 'boolean' },
421
- allowAnchor: { type: 'boolean' },
422
- cookieName: { type: 'string' },
423
- cookieFlags: { type: 'string' },
424
- cookieDomain: { type: 'string' },
182
+ anonymizeIp: { type: 'boolean' },
425
183
  cookieExpires: { type: 'number' },
426
- storeGac: { type: 'boolean' },
427
- legacyCookieDomain: { type: 'string' },
428
- legacyHistoryImport: { type: 'boolean' },
429
- allowLinker: { type: 'boolean' },
430
- storage: { type: 'string' },
431
- allowAdFeatures: { type: 'boolean' },
432
- dataSource: { type: 'string' },
433
- queueTime: { type: 'number' },
434
- forceSSL: { type: 'boolean' },
435
- transport: { type: 'string' },
436
184
  },
437
185
  additionalProperties: false,
438
186
  required: ['trackingId'],
@@ -456,6 +204,11 @@ const navItemSchema = {
456
204
  label: { type: 'string' },
457
205
  separator: { type: 'string' },
458
206
  separatorLine: { type: 'boolean' },
207
+ linePosition: {
208
+ type: 'string',
209
+ enum: ['top', 'bottom'],
210
+ default: 'top',
211
+ },
459
212
  version: { type: 'string' },
460
213
  menuStyle: { type: 'string', enum: ['drilldown'] },
461
214
  expanded: { type: 'string', const: 'always' },
@@ -511,6 +264,14 @@ const scorecardConfigSchema = {
511
264
  required: ['levels'],
512
265
  properties: {
513
266
  failBuildIfBelowMinimum: { type: 'boolean', default: false },
267
+ teamMetadataProperty: {
268
+ type: 'object',
269
+ properties: {
270
+ property: { type: 'string' },
271
+ label: { type: 'string' },
272
+ default: { type: 'string' },
273
+ },
274
+ },
514
275
  levels: {
515
276
  type: 'array',
516
277
  items: {
@@ -553,11 +314,15 @@ const scorecardConfigSchema = {
553
314
  const catalogSchema = {
554
315
  type: 'object',
555
316
  additionalProperties: true,
556
- required: ['slug', 'filters', 'groupByFirstFilter', 'items'],
317
+ required: ['slug', 'items'],
557
318
  properties: {
558
319
  slug: { type: 'string' },
559
320
  filters: { type: 'array', items: catalogFilterSchema },
560
321
  groupByFirstFilter: { type: 'boolean' },
322
+ filterValuesCasing: {
323
+ type: 'string',
324
+ enum: ['sentence', 'original', 'lowercase', 'uppercase'],
325
+ },
561
326
  items: navItemsSchema,
562
327
  requiredPermission: { type: 'string' },
563
328
  separateVersions: { type: 'boolean' },
@@ -593,10 +358,24 @@ exports.themeConfigSchema = {
593
358
  },
594
359
  footer: {
595
360
  type: 'object',
596
- properties: Object.assign({ items: navItemsSchema, copyrightText: { type: 'string' } }, hideConfigSchema.properties),
361
+ properties: Object.assign({ items: navItemsSchema, copyrightText: { type: 'string' }, logo: hideConfigSchema }, hideConfigSchema.properties),
597
362
  additionalProperties: false,
598
363
  },
599
- sidebar: hideConfigSchema,
364
+ sidebar: {
365
+ type: 'object',
366
+ properties: Object.assign({ separatorLine: { type: 'boolean' }, linePosition: {
367
+ type: 'string',
368
+ enum: ['top', 'bottom'],
369
+ default: 'bottom',
370
+ } }, hideConfigSchema.properties),
371
+ additionalProperties: false,
372
+ },
373
+ seo: {
374
+ type: 'object',
375
+ properties: {
376
+ title: { type: 'string' },
377
+ },
378
+ },
600
379
  scripts: {
601
380
  type: 'object',
602
381
  properties: {
@@ -762,6 +541,15 @@ exports.themeConfigSchema = {
762
541
  additionalProperties: false,
763
542
  default: {},
764
543
  },
544
+ versionPicker: {
545
+ type: 'object',
546
+ properties: {
547
+ hide: { type: 'boolean' },
548
+ showForUnversioned: {
549
+ type: 'boolean',
550
+ },
551
+ },
552
+ },
765
553
  breadcrumbs: {
766
554
  type: 'object',
767
555
  properties: {
@@ -803,3 +591,9 @@ exports.productThemeOverrideSchema = {
803
591
  additionalProperties: true,
804
592
  default: {},
805
593
  };
594
+ var ScorecardStatus;
595
+ (function (ScorecardStatus) {
596
+ ScorecardStatus["BelowMinimum"] = "Below minimum";
597
+ ScorecardStatus["Highest"] = "Highest";
598
+ ScorecardStatus["Minimum"] = "Minimum";
599
+ })(ScorecardStatus = exports.ScorecardStatus || (exports.ScorecardStatus = {}));
@@ -0,0 +1,21 @@
1
+ export interface Async2Definition {
2
+ asyncapi: string;
3
+ info?: Async2Info;
4
+ }
5
+ export interface Async2Info {
6
+ title: string;
7
+ version: string;
8
+ description?: string;
9
+ termsOfService?: string;
10
+ contact?: Async2Contact;
11
+ license?: Async2License;
12
+ }
13
+ export interface Async2Contact {
14
+ name?: string;
15
+ url?: string;
16
+ email?: string;
17
+ }
18
+ export interface Async2License {
19
+ name: string;
20
+ url?: string;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/visitors.d.ts CHANGED
@@ -4,6 +4,7 @@ import { NormalizedNodeType } from './types';
4
4
  import type { Stack } from './utils';
5
5
  import type { UserContext, ResolveResult, ProblemSeverity } from './walk';
6
6
  import type { Location } from './ref-utils';
7
+ import { Async2Definition } from './typings/asyncapi';
7
8
  export declare type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>;
8
9
  export declare type VisitFunction<T> = (node: T, ctx: UserContext & {
9
10
  ignoreNextVisitorsOnNode: () => void;
@@ -134,16 +135,24 @@ declare type Oas2FlatVisitor = {
134
135
  SecurityScheme?: VisitFunctionOrObject<Oas2SecurityScheme>;
135
136
  SpecExtension?: VisitFunctionOrObject<unknown>;
136
137
  };
138
+ declare type Async2FlatVisitor = {
139
+ Root?: VisitFunctionOrObject<Async2Definition>;
140
+ };
137
141
  declare type Oas3NestedVisitor = {
138
142
  [T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
139
143
  };
140
144
  declare type Oas2NestedVisitor = {
141
145
  [T in keyof Oas2FlatVisitor]: Oas2FlatVisitor[T] extends Function ? Oas2FlatVisitor[T] : Oas2FlatVisitor[T] & NestedVisitor<Oas2NestedVisitor>;
142
146
  };
147
+ declare type Async2NestedVisitor = {
148
+ [T in keyof Async2FlatVisitor]: Async2FlatVisitor[T] extends Function ? Async2FlatVisitor[T] : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
149
+ };
143
150
  export declare type Oas3Visitor = BaseVisitor & Oas3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
144
151
  export declare type Oas2Visitor = BaseVisitor & Oas2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas2NestedVisitor>>;
152
+ export declare type Async2Visitor = BaseVisitor & Async2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
145
153
  export declare type Oas3TransformVisitor = BaseVisitor & Oas3FlatVisitor & Record<string, VisitFunction<any> | VisitObject<any>>;
146
154
  export declare type Oas2TransformVisitor = BaseVisitor & Oas2FlatVisitor & Record<string, VisitFunction<any> | VisitObject<any>>;
155
+ export declare type Async2TransformVisitor = BaseVisitor & Async2FlatVisitor & Record<string, VisitFunction<any> | VisitObject<any>>;
147
156
  export declare type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
148
157
  export declare type NormalizedOasVisitors<T extends BaseVisitor> = {
149
158
  [V in keyof T]-?: {
@@ -162,10 +171,13 @@ export declare type NormalizedOasVisitors<T extends BaseVisitor> = {
162
171
  };
163
172
  export declare type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
164
173
  export declare type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
174
+ export declare type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
165
175
  export declare type Oas3Preprocessor = (options: Record<string, any>) => Oas3TransformVisitor;
166
176
  export declare type Oas2Preprocessor = (options: Record<string, any>) => Oas2TransformVisitor;
177
+ export declare type Async2Preprocessor = (options: Record<string, any>) => Async2TransformVisitor;
167
178
  export declare type Oas3Decorator = (options: Record<string, any>) => Oas3TransformVisitor;
168
179
  export declare type Oas2Decorator = (options: Record<string, any>) => Oas2TransformVisitor;
180
+ export declare type Async2Decorator = (options: Record<string, any>) => Async2TransformVisitor;
169
181
  export declare type OasRule = Oas3Rule;
170
182
  export declare type OasPreprocessor = Oas3Preprocessor;
171
183
  export declare type OasDecorator = Oas3Decorator;
package/lib/walk.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { NormalizedNodeType } from './types';
5
5
  import type { RuleSeverity } from './config';
6
6
  import { Location } from './ref-utils';
7
7
  import { ResolveError, YamlParseError, Source } from './resolve';
8
- import { OasVersion } from './oas-types';
8
+ import { SpecVersion } from './oas-types';
9
9
  declare type NonUndefined = string | number | boolean | symbol | bigint | object | Record<string, any>;
10
10
  export declare type ResolveResult<T extends NonUndefined> = {
11
11
  node: T;
@@ -27,7 +27,7 @@ export declare type UserContext = {
27
27
  type: NormalizedNodeType;
28
28
  key: string | number;
29
29
  parent: any;
30
- oasVersion: OasVersion;
30
+ oasVersion: SpecVersion;
31
31
  getVisitorData: () => Record<string, unknown>;
32
32
  };
33
33
  export declare type Loc = {
@@ -65,7 +65,7 @@ export declare type NormalizedProblem = {
65
65
  };
66
66
  export declare type WalkContext = {
67
67
  problems: NormalizedProblem[];
68
- oasVersion: OasVersion;
68
+ oasVersion: SpecVersion;
69
69
  visitorsData: Record<string, Record<string, unknown>>;
70
70
  refTypes?: Map<string, NormalizedNodeType>;
71
71
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
7
- "node": ">=12.0.0"
7
+ "node": ">=14.0.0"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "license": "MIT",
@@ -26,6 +26,7 @@
26
26
  "Swagger",
27
27
  "OpenAPI linter",
28
28
  "Swagger linter",
29
+ "AsyncAPI linter",
29
30
  "oas"
30
31
  ],
31
32
  "contributors": [
@@ -5,7 +5,7 @@ import { lintFromString, lintConfig, lintDocument } from '../lint';
5
5
  import { BaseResolver } from '../resolve';
6
6
  import { loadConfig } from '../config/load';
7
7
  import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../__tests__/utils';
8
- import { detectOpenAPI } from '../oas-types';
8
+ import { detectSpec } from '../oas-types';
9
9
 
10
10
  describe('lint', () => {
11
11
  it('lintFromString should work', async () => {
@@ -61,12 +61,12 @@ describe('lint', () => {
61
61
  path-http-verbs-order: error
62
62
  boolean-parameter-prefixes: off
63
63
  rule/operation-summary-length:
64
- subject:
64
+ subject:
65
65
  type: Operation
66
66
  property: summary
67
67
  message: Operation summary should start with an active verb
68
68
  assertions:
69
- local/checkWordsCount:
69
+ local/checkWordsCount:
70
70
  min: 3
71
71
  theme:
72
72
  openapi:
@@ -111,6 +111,7 @@ describe('lint', () => {
111
111
  "severity": "error",
112
112
  "suggest": Array [
113
113
  "theme",
114
+ "env",
114
115
  "seo",
115
116
  "sso",
116
117
  ],
@@ -178,6 +179,7 @@ describe('lint', () => {
178
179
  "apis",
179
180
  "seo",
180
181
  "sso",
182
+ "env",
181
183
  ],
182
184
  },
183
185
  ]
@@ -187,8 +189,8 @@ describe('lint', () => {
187
189
  it('lintConfig should work with legacy fields - referenceDocs', async () => {
188
190
  const document = parseYamlToDocument(
189
191
  outdent`
190
- apis:
191
- entry:
192
+ apis:
193
+ entry:
192
194
  root: ./file.yaml
193
195
  rules:
194
196
  operation-2xx-response: warn
@@ -302,11 +304,41 @@ describe('lint', () => {
302
304
  `,
303
305
  ''
304
306
  );
305
- expect(() => detectOpenAPI(testDocument.parsed)).toThrow(
307
+ expect(() => detectSpec(testDocument.parsed)).toThrow(
306
308
  `Invalid OpenAPI version: should be a string but got "number"`
307
309
  );
308
310
  });
309
311
 
312
+ it('detect unsupported OpenAPI version', () => {
313
+ const testDocument = parseYamlToDocument(
314
+ outdent`
315
+ openapi: 1.0.4
316
+ `,
317
+ ''
318
+ );
319
+ expect(() => detectSpec(testDocument.parsed)).toThrow(`Unsupported OpenAPI version: 1.0.4`);
320
+ });
321
+
322
+ it('detect unsupported AsyncAPI version', () => {
323
+ const testDocument = parseYamlToDocument(
324
+ outdent`
325
+ asyncapi: 1.0.4
326
+ `,
327
+ ''
328
+ );
329
+ expect(() => detectSpec(testDocument.parsed)).toThrow(`Unsupported AsyncAPI version: 1.0.4`);
330
+ });
331
+
332
+ it('detect unsupported spec format', () => {
333
+ const testDocument = parseYamlToDocument(
334
+ outdent`
335
+ notapi: 3.1.0
336
+ `,
337
+ ''
338
+ );
339
+ expect(() => detectSpec(testDocument.parsed)).toThrow(`Unsupported specification`);
340
+ });
341
+
310
342
  it("spec rule shouldn't throw an error for named callback", async () => {
311
343
  const document = parseYamlToDocument(
312
344
  outdent`