@redocly/openapi-core 1.0.0-beta.126 → 1.0.0-beta.127

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 (275) hide show
  1. package/lib/bundle.js +5 -2
  2. package/lib/rules/common/spec.js +1 -0
  3. package/lib/rules/oas2/request-mime-type.d.ts +1 -1
  4. package/lib/rules/oas2/response-mime-type.d.ts +1 -1
  5. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +2 -2
  6. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
  7. package/lib/rules/oas3/request-mime-type.d.ts +1 -1
  8. package/lib/rules/oas3/response-mime-type.d.ts +1 -1
  9. package/lib/walk.d.ts +6 -5
  10. package/lib/walk.js +23 -27
  11. package/package.json +1 -1
  12. package/__tests__/utils.ts +0 -88
  13. package/src/__tests__/__snapshots__/bundle.test.ts.snap +0 -437
  14. package/src/__tests__/bundle.test.ts +0 -236
  15. package/src/__tests__/codeframes.test.ts +0 -530
  16. package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +0 -5
  17. package/src/__tests__/fixtures/extension.js +0 -24
  18. package/src/__tests__/fixtures/refs/definitions.yaml +0 -3
  19. package/src/__tests__/fixtures/refs/examples.yaml +0 -8
  20. package/src/__tests__/fixtures/refs/external-request-body.yaml +0 -13
  21. package/src/__tests__/fixtures/refs/externalref.yaml +0 -35
  22. package/src/__tests__/fixtures/refs/hosted.yaml +0 -35
  23. package/src/__tests__/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +0 -21
  24. package/src/__tests__/fixtures/refs/openapi-with-external-refs.yaml +0 -33
  25. package/src/__tests__/fixtures/refs/openapi-with-url-refs.yaml +0 -18
  26. package/src/__tests__/fixtures/refs/param-b.yaml +0 -1
  27. package/src/__tests__/fixtures/refs/param-c.yaml +0 -1
  28. package/src/__tests__/fixtures/refs/rename.yaml +0 -1
  29. package/src/__tests__/fixtures/refs/requestBody.yaml +0 -9
  30. package/src/__tests__/fixtures/refs/schema-a.yaml +0 -1
  31. package/src/__tests__/fixtures/refs/simple.yaml +0 -1
  32. package/src/__tests__/fixtures/refs/vendor.schema.yaml +0 -20
  33. package/src/__tests__/fixtures/resolve/External.yaml +0 -10
  34. package/src/__tests__/fixtures/resolve/External2.yaml +0 -4
  35. package/src/__tests__/fixtures/resolve/description.md +0 -3
  36. package/src/__tests__/fixtures/resolve/externalInfo.yaml +0 -4
  37. package/src/__tests__/fixtures/resolve/externalLicense.yaml +0 -1
  38. package/src/__tests__/fixtures/resolve/openapi-with-back.yaml +0 -13
  39. package/src/__tests__/fixtures/resolve/openapi-with-md-description.yaml +0 -5
  40. package/src/__tests__/fixtures/resolve/openapi.yaml +0 -28
  41. package/src/__tests__/fixtures/resolve/schemas/type-a.yaml +0 -10
  42. package/src/__tests__/fixtures/resolve/schemas/type-b.yaml +0 -6
  43. package/src/__tests__/fixtures/resolve/transitive/a.yaml +0 -1
  44. package/src/__tests__/fixtures/resolve/transitive/components.yaml +0 -5
  45. package/src/__tests__/fixtures/resolve/transitive/schemas.yaml +0 -3
  46. package/src/__tests__/format.test.ts +0 -76
  47. package/src/__tests__/js-yaml.test.ts +0 -73
  48. package/src/__tests__/lint.test.ts +0 -388
  49. package/src/__tests__/logger-browser.test.ts +0 -53
  50. package/src/__tests__/logger.test.ts +0 -47
  51. package/src/__tests__/login.test.ts +0 -17
  52. package/src/__tests__/normalizeVisitors.test.ts +0 -151
  53. package/src/__tests__/output-browser.test.ts +0 -18
  54. package/src/__tests__/output.test.ts +0 -15
  55. package/src/__tests__/ref-utils.test.ts +0 -120
  56. package/src/__tests__/resolve-http.test.ts +0 -77
  57. package/src/__tests__/resolve.test.ts +0 -430
  58. package/src/__tests__/utils-browser.test.ts +0 -11
  59. package/src/__tests__/utils.test.ts +0 -144
  60. package/src/__tests__/walk.test.ts +0 -1545
  61. package/src/benchmark/benches/lint-with-many-rules.bench.ts +0 -35
  62. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +0 -39
  63. package/src/benchmark/benches/lint-with-no-rules.bench.ts +0 -20
  64. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +0 -35
  65. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +0 -32
  66. package/src/benchmark/benches/rebilly.yaml +0 -32275
  67. package/src/benchmark/benches/recommended-oas3.bench.ts +0 -22
  68. package/src/benchmark/benches/resolve-with-no-external.bench.ts +0 -23
  69. package/src/benchmark/benchmark.js +0 -311
  70. package/src/benchmark/colors.js +0 -29
  71. package/src/benchmark/fork.js +0 -83
  72. package/src/benchmark/utils.ts +0 -36
  73. package/src/bundle.ts +0 -399
  74. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +0 -161
  75. package/src/config/__tests__/__snapshots__/config.test.ts.snap +0 -144
  76. package/src/config/__tests__/config-resolvers.test.ts +0 -491
  77. package/src/config/__tests__/config.test.ts +0 -307
  78. package/src/config/__tests__/fixtures/ingore-file.ts +0 -8
  79. package/src/config/__tests__/fixtures/load-redocly.yaml +0 -2
  80. package/src/config/__tests__/fixtures/plugin-config.yaml +0 -2
  81. package/src/config/__tests__/fixtures/plugin.js +0 -56
  82. package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +0 -11
  83. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +0 -69
  84. package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +0 -7
  85. package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +0 -17
  86. package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +0 -18
  87. package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +0 -15
  88. package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +0 -9
  89. package/src/config/__tests__/fixtures/resolve-config/plugin.js +0 -80
  90. package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +0 -3
  91. package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +0 -4
  92. package/src/config/__tests__/load.test.ts +0 -167
  93. package/src/config/__tests__/resolve-plugins.test.ts +0 -27
  94. package/src/config/__tests__/utils.test.ts +0 -204
  95. package/src/config/all.ts +0 -73
  96. package/src/config/builtIn.ts +0 -37
  97. package/src/config/config-resolvers.ts +0 -465
  98. package/src/config/config.ts +0 -330
  99. package/src/config/index.ts +0 -7
  100. package/src/config/load.ts +0 -144
  101. package/src/config/minimal.ts +0 -60
  102. package/src/config/recommended.ts +0 -60
  103. package/src/config/rules.ts +0 -54
  104. package/src/config/types.ts +0 -216
  105. package/src/config/utils.ts +0 -333
  106. package/src/decorators/__tests__/filter-in.test.ts +0 -310
  107. package/src/decorators/__tests__/filter-out.test.ts +0 -335
  108. package/src/decorators/__tests__/media-type-examples-override.test.ts +0 -665
  109. package/src/decorators/__tests__/remove-x-internal.test.ts +0 -316
  110. package/src/decorators/__tests__/resources/request.yaml +0 -3
  111. package/src/decorators/__tests__/resources/response.yaml +0 -3
  112. package/src/decorators/common/filters/filter-helper.ts +0 -72
  113. package/src/decorators/common/filters/filter-in.ts +0 -18
  114. package/src/decorators/common/filters/filter-out.ts +0 -18
  115. package/src/decorators/common/info-description-override.ts +0 -24
  116. package/src/decorators/common/info-override.ts +0 -15
  117. package/src/decorators/common/media-type-examples-override.ts +0 -79
  118. package/src/decorators/common/operation-description-override.ts +0 -30
  119. package/src/decorators/common/registry-dependencies.ts +0 -25
  120. package/src/decorators/common/remove-x-internal.ts +0 -59
  121. package/src/decorators/common/tag-description-override.ts +0 -25
  122. package/src/decorators/oas2/index.ts +0 -20
  123. package/src/decorators/oas3/index.ts +0 -22
  124. package/src/env.ts +0 -5
  125. package/src/format/codeframes.ts +0 -216
  126. package/src/format/format.ts +0 -375
  127. package/src/index.ts +0 -71
  128. package/src/js-yaml/index.ts +0 -14
  129. package/src/lint.ts +0 -130
  130. package/src/logger.ts +0 -34
  131. package/src/oas-types.ts +0 -57
  132. package/src/output.ts +0 -7
  133. package/src/redocly/__tests__/redocly-client.test.ts +0 -146
  134. package/src/redocly/index.ts +0 -187
  135. package/src/redocly/redocly-client-types.ts +0 -10
  136. package/src/redocly/registry-api-types.ts +0 -32
  137. package/src/redocly/registry-api.ts +0 -149
  138. package/src/ref-utils.ts +0 -85
  139. package/src/resolve.ts +0 -417
  140. package/src/rules/__tests__/fixtures/code-sample.php +0 -9
  141. package/src/rules/__tests__/fixtures/invalid-yaml.yaml +0 -1
  142. package/src/rules/__tests__/fixtures/ref.yaml +0 -1
  143. package/src/rules/__tests__/no-unresolved-refs.test.ts +0 -257
  144. package/src/rules/__tests__/utils.test.ts +0 -160
  145. package/src/rules/ajv.ts +0 -102
  146. package/src/rules/common/__tests__/info-license.test.ts +0 -62
  147. package/src/rules/common/__tests__/license-url.test.ts +0 -63
  148. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +0 -96
  149. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +0 -210
  150. package/src/rules/common/__tests__/no-identical-paths.test.ts +0 -58
  151. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +0 -85
  152. package/src/rules/common/__tests__/operation-2xx-response.test.ts +0 -192
  153. package/src/rules/common/__tests__/operation-4xx-response.test.ts +0 -231
  154. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +0 -76
  155. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +0 -45
  156. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +0 -167
  157. package/src/rules/common/__tests__/operation-singular-tag.test.ts +0 -72
  158. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +0 -95
  159. package/src/rules/common/__tests__/path-not-include-query.test.ts +0 -64
  160. package/src/rules/common/__tests__/path-params-defined.test.ts +0 -202
  161. package/src/rules/common/__tests__/paths-kebab-case.test.ts +0 -108
  162. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +0 -264
  163. package/src/rules/common/__tests__/security-defined.test.ts +0 -175
  164. package/src/rules/common/__tests__/spec.test.ts +0 -555
  165. package/src/rules/common/__tests__/tag-description.test.ts +0 -65
  166. package/src/rules/common/__tests__/tags-alphabetical.test.ts +0 -64
  167. package/src/rules/common/assertions/__tests__/asserts.test.ts +0 -869
  168. package/src/rules/common/assertions/__tests__/index.test.ts +0 -100
  169. package/src/rules/common/assertions/__tests__/utils.test.ts +0 -236
  170. package/src/rules/common/assertions/asserts.ts +0 -357
  171. package/src/rules/common/assertions/index.ts +0 -56
  172. package/src/rules/common/assertions/utils.ts +0 -331
  173. package/src/rules/common/info-contact.ts +0 -15
  174. package/src/rules/common/info-license-url.ts +0 -10
  175. package/src/rules/common/info-license.ts +0 -15
  176. package/src/rules/common/no-ambiguous-paths.ts +0 -50
  177. package/src/rules/common/no-enum-type-mismatch.ts +0 -52
  178. package/src/rules/common/no-http-verbs-in-paths.ts +0 -36
  179. package/src/rules/common/no-identical-paths.ts +0 -24
  180. package/src/rules/common/no-invalid-parameter-examples.ts +0 -36
  181. package/src/rules/common/no-invalid-schema-examples.ts +0 -27
  182. package/src/rules/common/no-path-trailing-slash.ts +0 -15
  183. package/src/rules/common/operation-2xx-response.ts +0 -24
  184. package/src/rules/common/operation-4xx-response.ts +0 -24
  185. package/src/rules/common/operation-description.ts +0 -13
  186. package/src/rules/common/operation-operationId-unique.ts +0 -21
  187. package/src/rules/common/operation-operationId-url-safe.ts +0 -19
  188. package/src/rules/common/operation-operationId.ts +0 -17
  189. package/src/rules/common/operation-parameters-unique.ts +0 -48
  190. package/src/rules/common/operation-singular-tag.ts +0 -17
  191. package/src/rules/common/operation-summary.ts +0 -13
  192. package/src/rules/common/operation-tag-defined.ts +0 -26
  193. package/src/rules/common/parameter-description.ts +0 -22
  194. package/src/rules/common/path-declaration-must-exist.ts +0 -15
  195. package/src/rules/common/path-excludes-patterns.ts +0 -23
  196. package/src/rules/common/path-http-verbs-order.ts +0 -30
  197. package/src/rules/common/path-not-include-query.ts +0 -17
  198. package/src/rules/common/path-params-defined.ts +0 -65
  199. package/src/rules/common/path-segment-plural.ts +0 -31
  200. package/src/rules/common/paths-kebab-case.ts +0 -19
  201. package/src/rules/common/required-string-property-missing-min-length.ts +0 -44
  202. package/src/rules/common/response-contains-header.ts +0 -35
  203. package/src/rules/common/scalar-property-missing-example.ts +0 -58
  204. package/src/rules/common/security-defined.ts +0 -65
  205. package/src/rules/common/spec.ts +0 -174
  206. package/src/rules/common/tag-description.ts +0 -10
  207. package/src/rules/common/tags-alphabetical.ts +0 -20
  208. package/src/rules/no-unresolved-refs.ts +0 -51
  209. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +0 -110
  210. package/src/rules/oas2/__tests__/response-contains-header.test.ts +0 -174
  211. package/src/rules/oas2/__tests__/response-contains-property.test.ts +0 -155
  212. package/src/rules/oas2/__tests__/spec/fixtures/description.md +0 -1
  213. package/src/rules/oas2/__tests__/spec/info.test.ts +0 -355
  214. package/src/rules/oas2/__tests__/spec/operation.test.ts +0 -123
  215. package/src/rules/oas2/__tests__/spec/paths.test.ts +0 -245
  216. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +0 -35
  217. package/src/rules/oas2/__tests__/spec/utils.ts +0 -32
  218. package/src/rules/oas2/boolean-parameter-prefixes.ts +0 -26
  219. package/src/rules/oas2/index.ts +0 -89
  220. package/src/rules/oas2/remove-unused-components.ts +0 -81
  221. package/src/rules/oas2/request-mime-type.ts +0 -17
  222. package/src/rules/oas2/response-contains-property.ts +0 -36
  223. package/src/rules/oas2/response-mime-type.ts +0 -17
  224. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +0 -111
  225. package/src/rules/oas3/__tests__/fixtures/common.yaml +0 -11
  226. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +0 -205
  227. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +0 -65
  228. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +0 -473
  229. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +0 -60
  230. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +0 -79
  231. package/src/rules/oas3/__tests__/no-unused-components.test.ts +0 -131
  232. package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +0 -145
  233. package/src/rules/oas3/__tests__/response-contains-header.test.ts +0 -389
  234. package/src/rules/oas3/__tests__/response-contains-property.test.ts +0 -403
  235. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +0 -41
  236. package/src/rules/oas3/__tests__/spec/fixtures/description.md +0 -1
  237. package/src/rules/oas3/__tests__/spec/info.test.ts +0 -391
  238. package/src/rules/oas3/__tests__/spec/operation.test.ts +0 -253
  239. package/src/rules/oas3/__tests__/spec/paths.test.ts +0 -284
  240. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +0 -77
  241. package/src/rules/oas3/__tests__/spec/servers.test.ts +0 -505
  242. package/src/rules/oas3/__tests__/spec/spec.test.ts +0 -298
  243. package/src/rules/oas3/__tests__/spec/utils.ts +0 -32
  244. package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +0 -305
  245. package/src/rules/oas3/boolean-parameter-prefixes.ts +0 -28
  246. package/src/rules/oas3/index.ts +0 -109
  247. package/src/rules/oas3/no-empty-servers.ts +0 -22
  248. package/src/rules/oas3/no-example-value-and-externalValue.ts +0 -14
  249. package/src/rules/oas3/no-invalid-media-type-examples.ts +0 -49
  250. package/src/rules/oas3/no-server-example.com.ts +0 -14
  251. package/src/rules/oas3/no-server-trailing-slash.ts +0 -15
  252. package/src/rules/oas3/no-server-variables-empty-enum.ts +0 -66
  253. package/src/rules/oas3/no-undefined-server-variable.ts +0 -30
  254. package/src/rules/oas3/no-unused-components.ts +0 -75
  255. package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +0 -36
  256. package/src/rules/oas3/remove-unused-components.ts +0 -95
  257. package/src/rules/oas3/request-mime-type.ts +0 -31
  258. package/src/rules/oas3/response-contains-property.ts +0 -38
  259. package/src/rules/oas3/response-mime-type.ts +0 -31
  260. package/src/rules/oas3/spec-components-invalid-map-name.ts +0 -74
  261. package/src/rules/other/stats.ts +0 -73
  262. package/src/rules/utils.ts +0 -191
  263. package/src/types/index.ts +0 -149
  264. package/src/types/oas2.ts +0 -478
  265. package/src/types/oas3.ts +0 -597
  266. package/src/types/oas3_1.ts +0 -258
  267. package/src/types/redocly-yaml.ts +0 -1010
  268. package/src/typings/common.ts +0 -17
  269. package/src/typings/openapi.ts +0 -298
  270. package/src/typings/swagger.ts +0 -236
  271. package/src/utils.ts +0 -276
  272. package/src/visitors.ts +0 -491
  273. package/src/walk.ts +0 -453
  274. package/tsconfig.json +0 -8
  275. package/tsconfig.tsbuildinfo +0 -1
package/src/types/oas3.ts DELETED
@@ -1,597 +0,0 @@
1
- import { NodeType, listOf, mapOf } from '.';
2
- import { isMappingRef } from '../ref-utils';
3
- const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
4
-
5
- const Root: NodeType = {
6
- properties: {
7
- openapi: null,
8
- info: 'Info',
9
- servers: 'ServerList',
10
- security: 'SecurityRequirementList',
11
- tags: 'TagList',
12
- externalDocs: 'ExternalDocs',
13
- paths: 'Paths',
14
- components: 'Components',
15
- 'x-webhooks': 'WebhooksMap',
16
- 'x-tagGroups': 'TagGroups',
17
- 'x-ignoredHeaderParameters': { type: 'array', items: { type: 'string' } },
18
- },
19
- required: ['openapi', 'paths', 'info'],
20
- extensionsPrefix: 'x-',
21
- };
22
-
23
- const Tag: NodeType = {
24
- properties: {
25
- name: { type: 'string' },
26
- description: { type: 'string' },
27
- externalDocs: 'ExternalDocs',
28
- 'x-traitTag': { type: 'boolean' },
29
- 'x-displayName': { type: 'string' },
30
- },
31
- required: ['name'],
32
- extensionsPrefix: 'x-',
33
- };
34
-
35
- const TagGroup: NodeType = {
36
- properties: {
37
- name: { type: 'string' },
38
- tags: { type: 'array', items: { type: 'string' } },
39
- },
40
- extensionsPrefix: 'x-',
41
- };
42
-
43
- const ExternalDocs: NodeType = {
44
- properties: {
45
- description: { type: 'string' },
46
- url: { type: 'string' },
47
- },
48
- required: ['url'],
49
- extensionsPrefix: 'x-',
50
- };
51
-
52
- const Server: NodeType = {
53
- properties: {
54
- url: { type: 'string' },
55
- description: { type: 'string' },
56
- variables: 'ServerVariablesMap',
57
- },
58
- required: ['url'],
59
- extensionsPrefix: 'x-',
60
- };
61
-
62
- const ServerVariable: NodeType = {
63
- properties: {
64
- enum: {
65
- type: 'array',
66
- items: { type: 'string' },
67
- },
68
- default: { type: 'string' },
69
- description: { type: 'string' },
70
- },
71
- required: ['default'],
72
- extensionsPrefix: 'x-',
73
- };
74
-
75
- const SecurityRequirement: NodeType = {
76
- properties: {},
77
- additionalProperties: { type: 'array', items: { type: 'string' } },
78
- };
79
-
80
- const Info: NodeType = {
81
- properties: {
82
- title: { type: 'string' },
83
- version: { type: 'string' },
84
- description: { type: 'string' },
85
- termsOfService: { type: 'string' },
86
- contact: 'Contact',
87
- license: 'License',
88
- 'x-logo': 'Logo',
89
- },
90
- required: ['title', 'version'],
91
- extensionsPrefix: 'x-',
92
- };
93
-
94
- const Logo: NodeType = {
95
- properties: {
96
- url: { type: 'string' },
97
- altText: { type: 'string' },
98
- backgroundColor: { type: 'string' },
99
- href: { type: 'string' },
100
- },
101
- };
102
-
103
- const Contact: NodeType = {
104
- properties: {
105
- name: { type: 'string' },
106
- url: { type: 'string' },
107
- email: { type: 'string' },
108
- },
109
- extensionsPrefix: 'x-',
110
- };
111
-
112
- const License: NodeType = {
113
- properties: {
114
- name: { type: 'string' },
115
- url: { type: 'string' },
116
- },
117
- required: ['name'],
118
- extensionsPrefix: 'x-',
119
- };
120
-
121
- const Paths: NodeType = {
122
- properties: {},
123
- additionalProperties: (_value: any, key: string) =>
124
- key.startsWith('/') ? 'PathItem' : undefined,
125
- };
126
-
127
- const WebhooksMap: NodeType = {
128
- properties: {},
129
- additionalProperties: () => 'PathItem',
130
- };
131
-
132
- const PathItem: NodeType = {
133
- properties: {
134
- $ref: { type: 'string' }, // TODO: verify special $ref handling for Path Item
135
- servers: 'ServerList',
136
- parameters: 'ParameterList',
137
- summary: { type: 'string' },
138
- description: { type: 'string' },
139
- get: 'Operation',
140
- put: 'Operation',
141
- post: 'Operation',
142
- delete: 'Operation',
143
- options: 'Operation',
144
- head: 'Operation',
145
- patch: 'Operation',
146
- trace: 'Operation',
147
- },
148
- extensionsPrefix: 'x-',
149
- };
150
-
151
- const Parameter: NodeType = {
152
- properties: {
153
- name: { type: 'string' },
154
- in: { enum: ['query', 'header', 'path', 'cookie'] },
155
- description: { type: 'string' },
156
- required: { type: 'boolean' },
157
- deprecated: { type: 'boolean' },
158
- allowEmptyValue: { type: 'boolean' },
159
- style: {
160
- enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
161
- },
162
- explode: { type: 'boolean' },
163
- allowReserved: { type: 'boolean' },
164
- schema: 'Schema',
165
- example: { isExample: true },
166
- examples: 'ExamplesMap',
167
- content: 'MediaTypesMap',
168
- },
169
- required: ['name', 'in'],
170
- requiredOneOf: ['schema', 'content'],
171
- extensionsPrefix: 'x-',
172
- };
173
-
174
- const Operation: NodeType = {
175
- properties: {
176
- tags: {
177
- type: 'array',
178
- items: { type: 'string' },
179
- },
180
- summary: { type: 'string' },
181
- description: { type: 'string' },
182
- externalDocs: 'ExternalDocs',
183
- operationId: { type: 'string' },
184
- parameters: 'ParameterList',
185
- security: 'SecurityRequirementList',
186
- servers: 'ServerList',
187
- requestBody: 'RequestBody',
188
- responses: 'Responses',
189
- deprecated: { type: 'boolean' },
190
- callbacks: 'CallbacksMap',
191
- 'x-codeSamples': 'XCodeSampleList',
192
- 'x-code-samples': 'XCodeSampleList', // deprecated
193
- 'x-hideTryItPanel': { type: 'boolean' },
194
- },
195
- required: ['responses'],
196
- extensionsPrefix: 'x-',
197
- };
198
-
199
- const XCodeSample: NodeType = {
200
- properties: {
201
- lang: { type: 'string' },
202
- label: { type: 'string' },
203
- source: { type: 'string' },
204
- },
205
- };
206
-
207
- const RequestBody: NodeType = {
208
- properties: {
209
- description: { type: 'string' },
210
- required: { type: 'boolean' },
211
- content: 'MediaTypesMap',
212
- },
213
- required: ['content'],
214
- extensionsPrefix: 'x-',
215
- };
216
-
217
- const MediaTypesMap: NodeType = {
218
- properties: {},
219
- additionalProperties: 'MediaType',
220
- };
221
-
222
- const MediaType: NodeType = {
223
- properties: {
224
- schema: 'Schema',
225
- example: { isExample: true },
226
- examples: 'ExamplesMap',
227
- encoding: 'EncodingMap',
228
- },
229
- extensionsPrefix: 'x-',
230
- };
231
-
232
- const Example: NodeType = {
233
- properties: {
234
- value: { isExample: true },
235
- summary: { type: 'string' },
236
- description: { type: 'string' },
237
- externalValue: { type: 'string' },
238
- },
239
- extensionsPrefix: 'x-',
240
- };
241
-
242
- const Encoding: NodeType = {
243
- properties: {
244
- contentType: { type: 'string' },
245
- headers: 'HeadersMap',
246
- style: {
247
- enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
248
- },
249
- explode: { type: 'boolean' },
250
- allowReserved: { type: 'boolean' },
251
- },
252
- extensionsPrefix: 'x-',
253
- };
254
-
255
- const EnumDescriptions: NodeType = {
256
- properties: {},
257
- additionalProperties: { type: 'string' },
258
- };
259
-
260
- const Header: NodeType = {
261
- properties: {
262
- description: { type: 'string' },
263
- required: { type: 'boolean' },
264
- deprecated: { type: 'boolean' },
265
- allowEmptyValue: { type: 'boolean' },
266
- style: {
267
- enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
268
- },
269
- explode: { type: 'boolean' },
270
- allowReserved: { type: 'boolean' },
271
- schema: 'Schema',
272
- example: { isExample: true },
273
- examples: 'ExamplesMap',
274
- content: 'MediaTypesMap',
275
- },
276
- requiredOneOf: ['schema', 'content'],
277
- extensionsPrefix: 'x-',
278
- };
279
-
280
- const Responses: NodeType = {
281
- properties: { default: 'Response' },
282
- additionalProperties: (_v: any, key: string) =>
283
- responseCodeRegexp.test(key) ? 'Response' : undefined,
284
- };
285
-
286
- const Response: NodeType = {
287
- properties: {
288
- description: { type: 'string' },
289
- headers: 'HeadersMap',
290
- content: 'MediaTypesMap',
291
- links: 'LinksMap',
292
- 'x-summary': { type: 'string' },
293
- },
294
- required: ['description'],
295
- extensionsPrefix: 'x-',
296
- };
297
-
298
- const Link: NodeType = {
299
- properties: {
300
- operationRef: { type: 'string' },
301
- operationId: { type: 'string' },
302
- parameters: null, // TODO: figure out how to describe/validate this
303
- requestBody: null, // TODO: figure out how to describe/validate this
304
- description: { type: 'string' },
305
- server: 'Server',
306
- },
307
- extensionsPrefix: 'x-',
308
- };
309
-
310
- const Schema: NodeType = {
311
- properties: {
312
- externalDocs: 'ExternalDocs',
313
- discriminator: 'Discriminator',
314
- title: { type: 'string' },
315
- multipleOf: { type: 'number', minimum: 0 },
316
- maximum: { type: 'number' },
317
- minimum: { type: 'number' },
318
- exclusiveMaximum: { type: 'boolean' },
319
- exclusiveMinimum: { type: 'boolean' },
320
- maxLength: { type: 'integer', minimum: 0 },
321
- minLength: { type: 'integer', minimum: 0 },
322
- pattern: { type: 'string' },
323
- maxItems: { type: 'integer', minimum: 0 },
324
- minItems: { type: 'integer', minimum: 0 },
325
- uniqueItems: { type: 'boolean' },
326
- maxProperties: { type: 'integer', minimum: 0 },
327
- minProperties: { type: 'integer', minimum: 0 },
328
- required: { type: 'array', items: { type: 'string' } },
329
- enum: { type: 'array' },
330
- type: {
331
- enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
332
- },
333
- allOf: listOf('Schema'),
334
- anyOf: listOf('Schema'),
335
- oneOf: listOf('Schema'),
336
- not: 'Schema',
337
- properties: 'SchemaProperties',
338
- items: (value: any) => {
339
- if (Array.isArray(value)) {
340
- return listOf('Schema');
341
- } else {
342
- return 'Schema';
343
- }
344
- },
345
- additionalItems: (value: any) => {
346
- if (typeof value === 'boolean') {
347
- return { type: 'boolean' };
348
- } else {
349
- return 'Schema';
350
- }
351
- },
352
- additionalProperties: (value: any) => {
353
- if (typeof value === 'boolean') {
354
- return { type: 'boolean' };
355
- } else {
356
- return 'Schema';
357
- }
358
- },
359
- description: { type: 'string' },
360
- format: { type: 'string' },
361
- default: null,
362
- nullable: { type: 'boolean' },
363
- readOnly: { type: 'boolean' },
364
- writeOnly: { type: 'boolean' },
365
- xml: 'Xml',
366
- example: { isExample: true },
367
- deprecated: { type: 'boolean' },
368
- 'x-tags': { type: 'array', items: { type: 'string' } },
369
- 'x-additionalPropertiesName': { type: 'string' },
370
- 'x-explicitMappingOnly': { type: 'boolean' },
371
- },
372
- extensionsPrefix: 'x-',
373
- };
374
-
375
- const Xml: NodeType = {
376
- properties: {
377
- name: { type: 'string' },
378
- namespace: { type: 'string' },
379
- prefix: { type: 'string' },
380
- attribute: { type: 'boolean' },
381
- wrapped: { type: 'boolean' },
382
- },
383
- extensionsPrefix: 'x-',
384
- };
385
-
386
- const SchemaProperties: NodeType = {
387
- properties: {},
388
- additionalProperties: 'Schema',
389
- };
390
-
391
- const DiscriminatorMapping: NodeType = {
392
- properties: {},
393
- additionalProperties: (value: any) => {
394
- if (isMappingRef(value)) {
395
- return { type: 'string', directResolveAs: 'Schema' };
396
- } else {
397
- return { type: 'string' };
398
- }
399
- },
400
- };
401
-
402
- const Discriminator: NodeType = {
403
- properties: {
404
- propertyName: { type: 'string' },
405
- mapping: 'DiscriminatorMapping',
406
- },
407
- required: ['propertyName'],
408
- extensionsPrefix: 'x-',
409
- };
410
-
411
- const Components: NodeType = {
412
- properties: {
413
- parameters: 'NamedParameters',
414
- schemas: 'NamedSchemas',
415
- responses: 'NamedResponses',
416
- examples: 'NamedExamples',
417
- requestBodies: 'NamedRequestBodies',
418
- headers: 'NamedHeaders',
419
- securitySchemes: 'NamedSecuritySchemes',
420
- links: 'NamedLinks',
421
- callbacks: 'NamedCallbacks',
422
- },
423
- extensionsPrefix: 'x-',
424
- };
425
-
426
- const ImplicitFlow: NodeType = {
427
- properties: {
428
- refreshUrl: { type: 'string' },
429
- scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
430
- authorizationUrl: { type: 'string' },
431
- },
432
- required: ['authorizationUrl', 'scopes'],
433
- extensionsPrefix: 'x-',
434
- };
435
-
436
- const PasswordFlow: NodeType = {
437
- properties: {
438
- refreshUrl: { type: 'string' },
439
- scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
440
- tokenUrl: { type: 'string' },
441
- },
442
- required: ['tokenUrl', 'scopes'],
443
- extensionsPrefix: 'x-',
444
- };
445
-
446
- const ClientCredentials: NodeType = {
447
- properties: {
448
- refreshUrl: { type: 'string' },
449
- scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
450
- tokenUrl: { type: 'string' },
451
- },
452
- required: ['tokenUrl', 'scopes'],
453
- extensionsPrefix: 'x-',
454
- };
455
-
456
- const AuthorizationCode: NodeType = {
457
- properties: {
458
- refreshUrl: { type: 'string' },
459
- authorizationUrl: { type: 'string' },
460
- scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
461
- tokenUrl: { type: 'string' },
462
- 'x-usePkce': (value: any) => {
463
- if (typeof value === 'boolean') {
464
- return { type: 'boolean' };
465
- } else {
466
- return 'XUsePkce';
467
- }
468
- },
469
- },
470
- required: ['authorizationUrl', 'tokenUrl', 'scopes'],
471
- extensionsPrefix: 'x-',
472
- };
473
-
474
- const OAuth2Flows: NodeType = {
475
- properties: {
476
- implicit: 'ImplicitFlow',
477
- password: 'PasswordFlow',
478
- clientCredentials: 'ClientCredentials',
479
- authorizationCode: 'AuthorizationCode',
480
- },
481
- extensionsPrefix: 'x-',
482
- };
483
-
484
- const SecurityScheme: NodeType = {
485
- properties: {
486
- type: { enum: ['apiKey', 'http', 'oauth2', 'openIdConnect'] },
487
- description: { type: 'string' },
488
- name: { type: 'string' },
489
- in: { type: 'string', enum: ['query', 'header', 'cookie'] },
490
- scheme: { type: 'string' },
491
- bearerFormat: { type: 'string' },
492
- flows: 'OAuth2Flows',
493
- openIdConnectUrl: { type: 'string' },
494
- 'x-defaultClientId': { type: 'string' },
495
- },
496
- required(value) {
497
- switch (value?.type) {
498
- case 'apiKey':
499
- return ['type', 'name', 'in'];
500
- case 'http':
501
- return ['type', 'scheme'];
502
- case 'oauth2':
503
- return ['type', 'flows'];
504
- case 'openIdConnect':
505
- return ['type', 'openIdConnectUrl'];
506
- default:
507
- return ['type'];
508
- }
509
- },
510
- allowed(value) {
511
- switch (value?.type) {
512
- case 'apiKey':
513
- return ['type', 'name', 'in', 'description'];
514
- case 'http':
515
- return ['type', 'scheme', 'bearerFormat', 'description'];
516
- case 'oauth2':
517
- return ['type', 'flows', 'description'];
518
- case 'openIdConnect':
519
- return ['type', 'openIdConnectUrl', 'description'];
520
- default:
521
- return ['type', 'description'];
522
- }
523
- },
524
- extensionsPrefix: 'x-',
525
- };
526
-
527
- const XUsePkce: NodeType = {
528
- properties: {
529
- disableManualConfiguration: { type: 'boolean' },
530
- hideClientSecretInput: { type: 'boolean' },
531
- },
532
- };
533
-
534
- export const Oas3Types: Record<string, NodeType> = {
535
- Root,
536
- Tag,
537
- TagList: listOf('Tag'),
538
- TagGroups: listOf('TagGroup'),
539
- TagGroup,
540
- ExternalDocs,
541
- Server,
542
- ServerList: listOf('Server'),
543
- ServerVariable,
544
- ServerVariablesMap: mapOf('ServerVariable'),
545
- SecurityRequirement,
546
- SecurityRequirementList: listOf('SecurityRequirement'),
547
- Info,
548
- Contact,
549
- License,
550
- Paths,
551
- PathItem,
552
- Parameter,
553
- ParameterList: listOf('Parameter'),
554
- Operation,
555
- Callback: mapOf('PathItem'),
556
- CallbacksMap: mapOf('Callback'),
557
- RequestBody,
558
- MediaTypesMap,
559
- MediaType,
560
- Example,
561
- ExamplesMap: mapOf('Example'),
562
- Encoding,
563
- EncodingMap: mapOf('Encoding'),
564
- EnumDescriptions,
565
- Header,
566
- HeadersMap: mapOf('Header'),
567
- Responses,
568
- Response,
569
- Link,
570
- Logo,
571
- Schema,
572
- Xml,
573
- SchemaProperties,
574
- DiscriminatorMapping,
575
- Discriminator,
576
- Components,
577
- LinksMap: mapOf('Link'),
578
- NamedSchemas: mapOf('Schema'),
579
- NamedResponses: mapOf('Response'),
580
- NamedParameters: mapOf('Parameter'),
581
- NamedExamples: mapOf('Example'),
582
- NamedRequestBodies: mapOf('RequestBody'),
583
- NamedHeaders: mapOf('Header'),
584
- NamedSecuritySchemes: mapOf('SecurityScheme'),
585
- NamedLinks: mapOf('Link'),
586
- NamedCallbacks: mapOf('Callback'),
587
- ImplicitFlow,
588
- PasswordFlow,
589
- ClientCredentials,
590
- AuthorizationCode,
591
- OAuth2Flows,
592
- SecurityScheme,
593
- XCodeSample,
594
- XCodeSampleList: listOf('XCodeSample'),
595
- XUsePkce,
596
- WebhooksMap,
597
- };