@scalar/openapi-parser 0.7.1 → 0.8.1
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.
- package/CHANGELOG.md +26 -0
- package/LICENSE +1 -1
- package/README.md +193 -24
- package/dist/{configuration.d.ts → configuration/index.d.ts} +9 -7
- package/dist/configuration/index.d.ts.map +1 -0
- package/dist/configuration/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/Validator/Validator.d.ts +6 -8
- package/dist/lib/Validator/Validator.d.ts.map +1 -0
- package/dist/lib/Validator/Validator.js +1 -0
- package/dist/lib/Validator/index.d.ts +3 -0
- package/dist/lib/Validator/index.d.ts.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/polyfills/index.d.ts +2 -0
- package/dist/polyfills/index.d.ts.map +1 -0
- package/dist/polyfills/path.d.ts +24 -0
- package/dist/polyfills/path.d.ts.map +1 -0
- package/dist/polyfills/path.js +1 -0
- package/dist/schemas/v2.0/schema.json.js +1 -1623
- package/dist/schemas/v3.0/schema.json.js +1 -1673
- package/dist/schemas/v3.1/schema.json.js +1 -1452
- package/dist/types/index.d.ts +24 -18
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/helpers.d.ts +7 -0
- package/dist/utils/betterAjvErrors/helpers.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/helpers.js +1 -0
- package/dist/utils/betterAjvErrors/index.d.ts +17 -0
- package/dist/utils/betterAjvErrors/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/index.js +1 -0
- package/dist/utils/betterAjvErrors/utils.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.js +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +1 -0
- package/dist/utils/dereference.d.ts +3 -5
- package/dist/utils/dereference.d.ts.map +1 -0
- package/dist/utils/dereference.js +1 -0
- package/dist/utils/details.d.ts +3 -5
- package/dist/utils/details.d.ts.map +1 -0
- package/dist/utils/details.js +1 -0
- package/dist/utils/escapeJsonPointer.d.ts +2 -3
- package/dist/utils/escapeJsonPointer.d.ts.map +1 -0
- package/dist/utils/escapeJsonPointer.js +1 -0
- package/dist/utils/filter.d.ts +3 -5
- package/dist/utils/filter.d.ts.map +1 -0
- package/dist/utils/filter.js +1 -0
- package/dist/utils/getEntrypoint.d.ts +3 -5
- package/dist/utils/getEntrypoint.d.ts.map +1 -0
- package/dist/utils/getEntrypoint.js +1 -0
- package/dist/utils/getListOfReferences.d.ts +3 -5
- package/dist/utils/getListOfReferences.d.ts.map +1 -0
- package/dist/utils/getListOfReferences.js +1 -0
- package/dist/utils/getSegmentsFromPath.d.ts +2 -3
- package/dist/utils/getSegmentsFromPath.d.ts.map +1 -0
- package/dist/utils/getSegmentsFromPath.js +1 -0
- package/dist/utils/index.d.ts +26 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/isFilesystem.d.ts +2 -3
- package/dist/utils/isFilesystem.d.ts.map +1 -0
- package/dist/utils/isFilesystem.js +1 -0
- package/dist/utils/isJson.d.ts +2 -3
- package/dist/utils/isJson.d.ts.map +1 -0
- package/dist/utils/isJson.js +1 -0
- package/dist/utils/isObject.d.ts +2 -3
- package/dist/utils/isObject.d.ts.map +1 -0
- package/dist/utils/isObject.js +1 -0
- package/dist/utils/isYaml.d.ts +2 -3
- package/dist/utils/isYaml.d.ts.map +1 -0
- package/dist/utils/isYaml.js +1 -0
- package/dist/utils/load/index.d.ts +2 -0
- package/dist/utils/load/index.d.ts.map +1 -0
- package/dist/utils/load/load.d.ts +5 -7
- package/dist/utils/load/load.d.ts.map +1 -0
- package/dist/utils/load/load.js +1 -0
- package/dist/{src/utils → utils}/load/plugins/fetchUrls.d.ts +4 -6
- package/dist/utils/load/plugins/fetchUrls.d.ts.map +1 -0
- package/dist/utils/load/plugins/fetchUrls.js +1 -0
- package/dist/utils/load/plugins/readFiles.d.ts +3 -0
- package/dist/utils/load/plugins/readFiles.d.ts.map +1 -0
- package/dist/utils/load/plugins/readFiles.js +1 -0
- package/dist/utils/makeFilesystem.d.ts +3 -0
- package/dist/utils/makeFilesystem.d.ts.map +1 -0
- package/dist/utils/makeFilesystem.js +1 -0
- package/dist/utils/normalize.d.ts +3 -5
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js +1 -0
- package/dist/utils/openapi.d.ts +183 -0
- package/dist/utils/openapi.d.ts.map +1 -0
- package/dist/utils/openapi.js +1 -0
- package/dist/utils/resolveReferences.d.ts +5 -7
- package/dist/utils/resolveReferences.d.ts.map +1 -0
- package/dist/utils/resolveReferences.js +1 -0
- package/dist/utils/toJson.d.ts +3 -5
- package/dist/utils/toJson.d.ts.map +1 -0
- package/dist/utils/toJson.js +1 -0
- package/dist/utils/toYaml.d.ts +3 -5
- package/dist/utils/toYaml.d.ts.map +1 -0
- package/dist/utils/toYaml.js +1 -0
- package/dist/utils/transformErrors.d.ts +3 -5
- package/dist/utils/transformErrors.d.ts.map +1 -0
- package/dist/utils/transformErrors.js +1 -0
- package/dist/utils/traverse.d.ts +3 -5
- package/dist/utils/traverse.d.ts.map +1 -0
- package/dist/utils/traverse.js +1 -0
- package/dist/utils/unescapeJsonPointer.d.ts +2 -3
- package/dist/utils/unescapeJsonPointer.d.ts.map +1 -0
- package/dist/utils/unescapeJsonPointer.js +1 -0
- package/dist/utils/upgrade.d.ts +4 -5
- package/dist/utils/upgrade.d.ts.map +1 -0
- package/dist/utils/upgrade.js +1 -0
- package/dist/utils/upgrade.test-d.d.ts +2 -0
- package/dist/utils/upgrade.test-d.d.ts.map +1 -0
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts +3 -5
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +1 -0
- package/dist/utils/upgradeFromThreeToThreeOne.js +1 -0
- package/dist/utils/upgradeFromTwoToThree.d.ts +3 -5
- package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -0
- package/dist/utils/upgradeFromTwoToThree.js +1 -0
- package/dist/utils/validate.d.ts +3 -5
- package/dist/utils/validate.d.ts.map +1 -0
- package/dist/utils/validate.js +1 -0
- package/dist/utils/workThroughQueue.d.ts +11 -0
- package/dist/utils/workThroughQueue.d.ts.map +1 -0
- package/dist/utils/workThroughQueue.js +1 -0
- package/package.json +44 -36
- package/dist/pipeline.d.ts +0 -388
- package/dist/src/configuration.js +0 -22
- package/dist/src/index.d.ts +0 -27
- package/dist/src/index.js +0 -25
- package/dist/src/lib/Validator/Validator.js +0 -94
- package/dist/src/pipeline.js +0 -121
- package/dist/src/polyfills/path.js +0 -80
- package/dist/src/utils/betterAjvErrors/helpers.js +0 -89
- package/dist/src/utils/betterAjvErrors/index.js +0 -15
- package/dist/src/utils/betterAjvErrors/utils.js +0 -17
- package/dist/src/utils/betterAjvErrors/validation-errors/additional-prop.js +0 -18
- package/dist/src/utils/betterAjvErrors/validation-errors/base.js +0 -23
- package/dist/src/utils/betterAjvErrors/validation-errors/default.js +0 -18
- package/dist/src/utils/betterAjvErrors/validation-errors/enum.js +0 -41
- package/dist/src/utils/betterAjvErrors/validation-errors/pattern.js +0 -18
- package/dist/src/utils/betterAjvErrors/validation-errors/required.js +0 -17
- package/dist/src/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +0 -18
- package/dist/src/utils/dereference.js +0 -18
- package/dist/src/utils/details.js +0 -22
- package/dist/src/utils/escapeJsonPointer.js +0 -5
- package/dist/src/utils/filter.js +0 -17
- package/dist/src/utils/getEntrypoint.js +0 -5
- package/dist/src/utils/getListOfReferences.js +0 -17
- package/dist/src/utils/getSegmentsFromPath.js +0 -10
- package/dist/src/utils/isFilesystem.js +0 -5
- package/dist/src/utils/isJson.js +0 -10
- package/dist/src/utils/isObject.js +0 -3
- package/dist/src/utils/isYaml.js +0 -17
- package/dist/src/utils/load/load.js +0 -59
- package/dist/src/utils/load/plugins/fetchUrls.js +0 -38
- package/dist/src/utils/load/plugins/readFiles.d.ts +0 -5
- package/dist/src/utils/load/plugins/readFiles.js +0 -50
- package/dist/src/utils/makeFilesystem.js +0 -22
- package/dist/src/utils/normalize.js +0 -20
- package/dist/src/utils/resolveReferences.js +0 -106
- package/dist/src/utils/toJson.js +0 -3
- package/dist/src/utils/toYaml.js +0 -5
- package/dist/src/utils/transformErrors.js +0 -19
- package/dist/src/utils/traverse.js +0 -20
- package/dist/src/utils/unescapeJsonPointer.js +0 -5
- package/dist/src/utils/upgrade.js +0 -19
- package/dist/src/utils/upgradeFromThreeToThreeOne.js +0 -70
- package/dist/src/utils/upgradeFromTwoToThree.js +0 -5
- package/dist/src/utils/validate.js +0 -15
- package/dist/src/utils/workThroughQueue.js +0 -24
- package/dist/types/openapi-types.d.ts +0 -747
- package/dist/webpack-stats.json +0 -1
package/dist/pipeline.d.ts
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import { AnyObject, LoadResult, DereferenceResult, ValidateResult, UpgradeResult, FilterResult, Filesystem, DetailsResult } from './types/index.js';
|
|
2
|
-
import { dereference } from './utils/dereference.js';
|
|
3
|
-
import { filter } from './utils/filter.js';
|
|
4
|
-
import { load, LoadPlugin } from './utils/load/load.js';
|
|
5
|
-
import { upgrade } from './utils/upgrade.js';
|
|
6
|
-
import { validate } from './utils/validate.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A queuable action for the pipeline
|
|
10
|
-
*/
|
|
11
|
-
type Action = {
|
|
12
|
-
action: typeof load | typeof upgrade | typeof filter | typeof dereference | typeof validate;
|
|
13
|
-
options?: AnyObject;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* A queue of tasks to run on an OpenAPI specification
|
|
17
|
-
*/
|
|
18
|
-
type Queue = {
|
|
19
|
-
specification: AnyApiDefinitionFormat;
|
|
20
|
-
tasks: Action[];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* JSON, YAML or object representation of an OpenAPI API definition
|
|
24
|
-
*/
|
|
25
|
-
type AnyApiDefinitionFormat = string | AnyObject;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new pipeline
|
|
28
|
-
*/
|
|
29
|
-
declare function openapi(): {
|
|
30
|
-
load: typeof loadAction;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Load an OpenAPI specification.
|
|
34
|
-
*
|
|
35
|
-
* Example: await openapi().load({ openapi: '3.0.0' })
|
|
36
|
-
*/
|
|
37
|
-
declare function loadAction(specification: AnyApiDefinitionFormat, options?: {
|
|
38
|
-
plugins: LoadPlugin[];
|
|
39
|
-
}): {
|
|
40
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
41
|
-
filesystem: Filesystem;
|
|
42
|
-
}>>;
|
|
43
|
-
files: () => Promise<Filesystem>;
|
|
44
|
-
details: () => Promise<DetailsResult>;
|
|
45
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
46
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
47
|
-
filesystem: Filesystem;
|
|
48
|
-
}>>;
|
|
49
|
-
files: () => Promise<Filesystem>;
|
|
50
|
-
details: () => Promise<DetailsResult>;
|
|
51
|
-
filter: () => any;
|
|
52
|
-
upgrade: () => {
|
|
53
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
54
|
-
filesystem: Filesystem;
|
|
55
|
-
}>>;
|
|
56
|
-
files: () => Promise<Filesystem>;
|
|
57
|
-
details: () => Promise<DetailsResult>;
|
|
58
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
59
|
-
validate: () => {
|
|
60
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
61
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
62
|
-
filesystem: Filesystem;
|
|
63
|
-
}>>;
|
|
64
|
-
files: () => Promise<Filesystem>;
|
|
65
|
-
details: () => Promise<DetailsResult>;
|
|
66
|
-
dereference: () => {
|
|
67
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
68
|
-
filesystem: Filesystem;
|
|
69
|
-
}>>;
|
|
70
|
-
files: () => Promise<Filesystem>;
|
|
71
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
72
|
-
toJson: () => Promise<string>;
|
|
73
|
-
toYaml: () => Promise<string>;
|
|
74
|
-
};
|
|
75
|
-
toJson: () => Promise<string>;
|
|
76
|
-
toYaml: () => Promise<string>;
|
|
77
|
-
};
|
|
78
|
-
dereference: () => {
|
|
79
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
80
|
-
filesystem: Filesystem;
|
|
81
|
-
}>>;
|
|
82
|
-
files: () => Promise<Filesystem>;
|
|
83
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
84
|
-
toJson: () => Promise<string>;
|
|
85
|
-
toYaml: () => Promise<string>;
|
|
86
|
-
};
|
|
87
|
-
toJson: () => Promise<string>;
|
|
88
|
-
toYaml: () => Promise<string>;
|
|
89
|
-
};
|
|
90
|
-
validate: () => {
|
|
91
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
92
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
93
|
-
filesystem: Filesystem;
|
|
94
|
-
}>>;
|
|
95
|
-
files: () => Promise<Filesystem>;
|
|
96
|
-
details: () => Promise<DetailsResult>;
|
|
97
|
-
dereference: () => {
|
|
98
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
99
|
-
filesystem: Filesystem;
|
|
100
|
-
}>>;
|
|
101
|
-
files: () => Promise<Filesystem>;
|
|
102
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
103
|
-
toJson: () => Promise<string>;
|
|
104
|
-
toYaml: () => Promise<string>;
|
|
105
|
-
};
|
|
106
|
-
toJson: () => Promise<string>;
|
|
107
|
-
toYaml: () => Promise<string>;
|
|
108
|
-
};
|
|
109
|
-
dereference: () => {
|
|
110
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
111
|
-
filesystem: Filesystem;
|
|
112
|
-
}>>;
|
|
113
|
-
files: () => Promise<Filesystem>;
|
|
114
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
115
|
-
toJson: () => Promise<string>;
|
|
116
|
-
toYaml: () => Promise<string>;
|
|
117
|
-
};
|
|
118
|
-
toJson: () => Promise<string>;
|
|
119
|
-
toYaml: () => Promise<string>;
|
|
120
|
-
};
|
|
121
|
-
upgrade: () => {
|
|
122
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
123
|
-
filesystem: Filesystem;
|
|
124
|
-
}>>;
|
|
125
|
-
files: () => Promise<Filesystem>;
|
|
126
|
-
details: () => Promise<DetailsResult>;
|
|
127
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
128
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
129
|
-
filesystem: Filesystem;
|
|
130
|
-
}>>;
|
|
131
|
-
files: () => Promise<Filesystem>;
|
|
132
|
-
details: () => Promise<DetailsResult>;
|
|
133
|
-
filter: () => any;
|
|
134
|
-
upgrade: () => any;
|
|
135
|
-
validate: () => {
|
|
136
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
137
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
138
|
-
filesystem: Filesystem;
|
|
139
|
-
}>>;
|
|
140
|
-
files: () => Promise<Filesystem>;
|
|
141
|
-
details: () => Promise<DetailsResult>;
|
|
142
|
-
dereference: () => {
|
|
143
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
144
|
-
filesystem: Filesystem;
|
|
145
|
-
}>>;
|
|
146
|
-
files: () => Promise<Filesystem>;
|
|
147
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
148
|
-
toJson: () => Promise<string>;
|
|
149
|
-
toYaml: () => Promise<string>;
|
|
150
|
-
};
|
|
151
|
-
toJson: () => Promise<string>;
|
|
152
|
-
toYaml: () => Promise<string>;
|
|
153
|
-
};
|
|
154
|
-
dereference: () => {
|
|
155
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
156
|
-
filesystem: Filesystem;
|
|
157
|
-
}>>;
|
|
158
|
-
files: () => Promise<Filesystem>;
|
|
159
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
160
|
-
toJson: () => Promise<string>;
|
|
161
|
-
toYaml: () => Promise<string>;
|
|
162
|
-
};
|
|
163
|
-
toJson: () => Promise<string>;
|
|
164
|
-
toYaml: () => Promise<string>;
|
|
165
|
-
};
|
|
166
|
-
validate: () => {
|
|
167
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
168
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
169
|
-
filesystem: Filesystem;
|
|
170
|
-
}>>;
|
|
171
|
-
files: () => Promise<Filesystem>;
|
|
172
|
-
details: () => Promise<DetailsResult>;
|
|
173
|
-
filter: () => any;
|
|
174
|
-
upgrade: () => any;
|
|
175
|
-
validate: () => any;
|
|
176
|
-
dereference: () => {
|
|
177
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
178
|
-
filesystem: Filesystem;
|
|
179
|
-
}>>;
|
|
180
|
-
files: () => Promise<Filesystem>;
|
|
181
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
182
|
-
toJson: () => Promise<string>;
|
|
183
|
-
toYaml: () => Promise<string>;
|
|
184
|
-
};
|
|
185
|
-
toJson: () => Promise<string>;
|
|
186
|
-
toYaml: () => Promise<string>;
|
|
187
|
-
};
|
|
188
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
189
|
-
filesystem: Filesystem;
|
|
190
|
-
}>>;
|
|
191
|
-
files: () => Promise<Filesystem>;
|
|
192
|
-
details: () => Promise<DetailsResult>;
|
|
193
|
-
dereference: () => {
|
|
194
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
195
|
-
filesystem: Filesystem;
|
|
196
|
-
}>>;
|
|
197
|
-
files: () => Promise<Filesystem>;
|
|
198
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
199
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
200
|
-
filesystem: Filesystem;
|
|
201
|
-
}>>;
|
|
202
|
-
files: () => Promise<Filesystem>;
|
|
203
|
-
details: () => Promise<DetailsResult>;
|
|
204
|
-
filter: () => any;
|
|
205
|
-
upgrade: () => any;
|
|
206
|
-
validate: () => any;
|
|
207
|
-
dereference: () => any;
|
|
208
|
-
toJson: () => Promise<string>;
|
|
209
|
-
toYaml: () => Promise<string>;
|
|
210
|
-
};
|
|
211
|
-
toJson: () => Promise<string>;
|
|
212
|
-
toYaml: () => Promise<string>;
|
|
213
|
-
};
|
|
214
|
-
toJson: () => Promise<string>;
|
|
215
|
-
toYaml: () => Promise<string>;
|
|
216
|
-
};
|
|
217
|
-
dereference: () => {
|
|
218
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
219
|
-
filesystem: Filesystem;
|
|
220
|
-
}>>;
|
|
221
|
-
files: () => Promise<Filesystem>;
|
|
222
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
223
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
224
|
-
filesystem: Filesystem;
|
|
225
|
-
}>>;
|
|
226
|
-
files: () => Promise<Filesystem>;
|
|
227
|
-
details: () => Promise<DetailsResult>;
|
|
228
|
-
filter: () => any;
|
|
229
|
-
upgrade: () => any;
|
|
230
|
-
validate: () => {
|
|
231
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
232
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
233
|
-
filesystem: Filesystem;
|
|
234
|
-
}>>;
|
|
235
|
-
files: () => Promise<Filesystem>;
|
|
236
|
-
details: () => Promise<DetailsResult>;
|
|
237
|
-
dereference: () => any;
|
|
238
|
-
toJson: () => Promise<string>;
|
|
239
|
-
toYaml: () => Promise<string>;
|
|
240
|
-
};
|
|
241
|
-
dereference: () => any;
|
|
242
|
-
toJson: () => Promise<string>;
|
|
243
|
-
toYaml: () => Promise<string>;
|
|
244
|
-
};
|
|
245
|
-
toJson: () => Promise<string>;
|
|
246
|
-
toYaml: () => Promise<string>;
|
|
247
|
-
};
|
|
248
|
-
toJson: () => Promise<string>;
|
|
249
|
-
toYaml: () => Promise<string>;
|
|
250
|
-
};
|
|
251
|
-
validate: () => {
|
|
252
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
253
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
254
|
-
filesystem: Filesystem;
|
|
255
|
-
}>>;
|
|
256
|
-
files: () => Promise<Filesystem>;
|
|
257
|
-
details: () => Promise<DetailsResult>;
|
|
258
|
-
filter: () => any;
|
|
259
|
-
upgrade: () => {
|
|
260
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
261
|
-
filesystem: Filesystem;
|
|
262
|
-
}>>;
|
|
263
|
-
files: () => Promise<Filesystem>;
|
|
264
|
-
details: () => Promise<DetailsResult>;
|
|
265
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
266
|
-
validate: () => any;
|
|
267
|
-
dereference: () => {
|
|
268
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
269
|
-
filesystem: Filesystem;
|
|
270
|
-
}>>;
|
|
271
|
-
files: () => Promise<Filesystem>;
|
|
272
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
273
|
-
toJson: () => Promise<string>;
|
|
274
|
-
toYaml: () => Promise<string>;
|
|
275
|
-
};
|
|
276
|
-
toJson: () => Promise<string>;
|
|
277
|
-
toYaml: () => Promise<string>;
|
|
278
|
-
};
|
|
279
|
-
validate: () => any;
|
|
280
|
-
dereference: () => {
|
|
281
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
282
|
-
filesystem: Filesystem;
|
|
283
|
-
}>>;
|
|
284
|
-
files: () => Promise<Filesystem>;
|
|
285
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
286
|
-
toJson: () => Promise<string>;
|
|
287
|
-
toYaml: () => Promise<string>;
|
|
288
|
-
};
|
|
289
|
-
toJson: () => Promise<string>;
|
|
290
|
-
toYaml: () => Promise<string>;
|
|
291
|
-
};
|
|
292
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
293
|
-
filesystem: Filesystem;
|
|
294
|
-
}>>;
|
|
295
|
-
files: () => Promise<Filesystem>;
|
|
296
|
-
details: () => Promise<DetailsResult>;
|
|
297
|
-
dereference: () => {
|
|
298
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
299
|
-
filesystem: Filesystem;
|
|
300
|
-
}>>;
|
|
301
|
-
files: () => Promise<Filesystem>;
|
|
302
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
303
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
304
|
-
filesystem: Filesystem;
|
|
305
|
-
}>>;
|
|
306
|
-
files: () => Promise<Filesystem>;
|
|
307
|
-
details: () => Promise<DetailsResult>;
|
|
308
|
-
filter: () => any;
|
|
309
|
-
upgrade: () => {
|
|
310
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
311
|
-
filesystem: Filesystem;
|
|
312
|
-
}>>;
|
|
313
|
-
files: () => Promise<Filesystem>;
|
|
314
|
-
details: () => Promise<DetailsResult>;
|
|
315
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
316
|
-
validate: () => any;
|
|
317
|
-
dereference: () => any;
|
|
318
|
-
toJson: () => Promise<string>;
|
|
319
|
-
toYaml: () => Promise<string>;
|
|
320
|
-
};
|
|
321
|
-
validate: () => any;
|
|
322
|
-
dereference: () => any;
|
|
323
|
-
toJson: () => Promise<string>;
|
|
324
|
-
toYaml: () => Promise<string>;
|
|
325
|
-
};
|
|
326
|
-
toJson: () => Promise<string>;
|
|
327
|
-
toYaml: () => Promise<string>;
|
|
328
|
-
};
|
|
329
|
-
toJson: () => Promise<string>;
|
|
330
|
-
toYaml: () => Promise<string>;
|
|
331
|
-
};
|
|
332
|
-
dereference: () => {
|
|
333
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
334
|
-
filesystem: Filesystem;
|
|
335
|
-
}>>;
|
|
336
|
-
files: () => Promise<Filesystem>;
|
|
337
|
-
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
338
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
339
|
-
filesystem: Filesystem;
|
|
340
|
-
}>>;
|
|
341
|
-
files: () => Promise<Filesystem>;
|
|
342
|
-
details: () => Promise<DetailsResult>;
|
|
343
|
-
filter: () => any;
|
|
344
|
-
upgrade: () => {
|
|
345
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
346
|
-
filesystem: Filesystem;
|
|
347
|
-
}>>;
|
|
348
|
-
files: () => Promise<Filesystem>;
|
|
349
|
-
details: () => Promise<DetailsResult>;
|
|
350
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
351
|
-
validate: () => {
|
|
352
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
353
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
354
|
-
filesystem: Filesystem;
|
|
355
|
-
}>>;
|
|
356
|
-
files: () => Promise<Filesystem>;
|
|
357
|
-
details: () => Promise<DetailsResult>;
|
|
358
|
-
dereference: () => any;
|
|
359
|
-
toJson: () => Promise<string>;
|
|
360
|
-
toYaml: () => Promise<string>;
|
|
361
|
-
};
|
|
362
|
-
dereference: () => any;
|
|
363
|
-
toJson: () => Promise<string>;
|
|
364
|
-
toYaml: () => Promise<string>;
|
|
365
|
-
};
|
|
366
|
-
validate: () => {
|
|
367
|
-
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
368
|
-
get: () => Promise<Partial<LoadResult & DereferenceResult & ValidateResult & UpgradeResult & FilterResult & {
|
|
369
|
-
filesystem: Filesystem;
|
|
370
|
-
}>>;
|
|
371
|
-
files: () => Promise<Filesystem>;
|
|
372
|
-
details: () => Promise<DetailsResult>;
|
|
373
|
-
dereference: () => any;
|
|
374
|
-
toJson: () => Promise<string>;
|
|
375
|
-
toYaml: () => Promise<string>;
|
|
376
|
-
};
|
|
377
|
-
dereference: () => any;
|
|
378
|
-
toJson: () => Promise<string>;
|
|
379
|
-
toYaml: () => Promise<string>;
|
|
380
|
-
};
|
|
381
|
-
toJson: () => Promise<string>;
|
|
382
|
-
toYaml: () => Promise<string>;
|
|
383
|
-
};
|
|
384
|
-
toJson: () => Promise<string>;
|
|
385
|
-
toYaml: () => Promise<string>;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export { type Action, type AnyApiDefinitionFormat, type Queue, openapi };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Swagger20 from '../schemas/v2.0/schema.json.js';
|
|
2
|
-
import OpenApi30 from '../schemas/v3.0/schema.json.js';
|
|
3
|
-
import OpenApi31 from '../schemas/v3.1/schema.json.js';
|
|
4
|
-
|
|
5
|
-
const OpenApiSpecifications = {
|
|
6
|
-
"2.0": Swagger20,
|
|
7
|
-
"3.0": OpenApi30,
|
|
8
|
-
"3.1": OpenApi31
|
|
9
|
-
};
|
|
10
|
-
const OpenApiVersions = Object.keys(
|
|
11
|
-
OpenApiSpecifications
|
|
12
|
-
);
|
|
13
|
-
const ERRORS = {
|
|
14
|
-
EMPTY_OR_INVALID: "Cannot find JSON, YAML or filename in data",
|
|
15
|
-
// URI_MUST_BE_STRING: 'uri parameter or $id attribute must be a string',
|
|
16
|
-
OPENAPI_VERSION_NOT_SUPPORTED: "Cannot find supported Swagger/OpenAPI version in specification, version must be a string.",
|
|
17
|
-
INVALID_REFERENCE: "Can\u2019t resolve reference: %s",
|
|
18
|
-
EXTERNAL_REFERENCE_NOT_FOUND: "Can\u2019t resolve external reference: %s",
|
|
19
|
-
FILE_DOES_NOT_EXIST: "File does not exist: %s"
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { ERRORS, OpenApiSpecifications, OpenApiVersions };
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { Validator, jsonSchemaVersions } from '../lib/Validator/Validator.js';
|
|
2
|
-
export { ResolveReferencesResult, resolveReferences } from '../utils/resolveReferences.js';
|
|
3
|
-
export { AjvOptions, AnyObject, DereferenceResult, DetailsResult, ErrorObject, Filesystem, FilesystemEntry, FilterResult, LoadResult, UpgradeResult, ValidateResult } from '../types/index.js';
|
|
4
|
-
export { dereference } from '../utils/dereference.js';
|
|
5
|
-
export { details } from '../utils/details.js';
|
|
6
|
-
export { escapeJsonPointer } from '../utils/escapeJsonPointer.js';
|
|
7
|
-
export { filter } from '../utils/filter.js';
|
|
8
|
-
export { getEntrypoint } from '../utils/getEntrypoint.js';
|
|
9
|
-
export { getListOfReferences } from '../utils/getListOfReferences.js';
|
|
10
|
-
export { getSegmentsFromPath } from '../utils/getSegmentsFromPath.js';
|
|
11
|
-
export { isFilesystem } from '../utils/isFilesystem.js';
|
|
12
|
-
export { isJson } from '../utils/isJson.js';
|
|
13
|
-
export { isObject } from '../utils/isObject.js';
|
|
14
|
-
export { isYaml } from '../utils/isYaml.js';
|
|
15
|
-
export { LoadPlugin, load } from '../utils/load/load.js';
|
|
16
|
-
export { normalize } from '../utils/normalize.js';
|
|
17
|
-
export { toJson } from '../utils/toJson.js';
|
|
18
|
-
export { toYaml } from '../utils/toYaml.js';
|
|
19
|
-
export { transformErrors } from '../utils/transformErrors.js';
|
|
20
|
-
export { traverse } from '../utils/traverse.js';
|
|
21
|
-
export { unescapeJsonPointer } from '../utils/unescapeJsonPointer.js';
|
|
22
|
-
export { upgrade } from '../utils/upgrade.js';
|
|
23
|
-
export { upgradeFromThreeToThreeOne } from '../utils/upgradeFromThreeToThreeOne.js';
|
|
24
|
-
export { upgradeFromTwoToThree } from '../utils/upgradeFromTwoToThree.js';
|
|
25
|
-
export { validate } from '../utils/validate.js';
|
|
26
|
-
export { Action, AnyApiDefinitionFormat, Queue, openapi } from '../pipeline.js';
|
|
27
|
-
export { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from '../types/openapi-types.js';
|
package/dist/src/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export { openapi } from './pipeline.js';
|
|
2
|
-
export { Validator, jsonSchemaVersions } from './lib/Validator/Validator.js';
|
|
3
|
-
export { resolveReferences } from './utils/resolveReferences.js';
|
|
4
|
-
export { dereference } from './utils/dereference.js';
|
|
5
|
-
export { details } from './utils/details.js';
|
|
6
|
-
export { escapeJsonPointer } from './utils/escapeJsonPointer.js';
|
|
7
|
-
export { filter } from './utils/filter.js';
|
|
8
|
-
export { getEntrypoint } from './utils/getEntrypoint.js';
|
|
9
|
-
export { getListOfReferences } from './utils/getListOfReferences.js';
|
|
10
|
-
export { getSegmentsFromPath } from './utils/getSegmentsFromPath.js';
|
|
11
|
-
export { isFilesystem } from './utils/isFilesystem.js';
|
|
12
|
-
export { isJson } from './utils/isJson.js';
|
|
13
|
-
export { isObject } from './utils/isObject.js';
|
|
14
|
-
export { isYaml } from './utils/isYaml.js';
|
|
15
|
-
export { load } from './utils/load/load.js';
|
|
16
|
-
export { normalize } from './utils/normalize.js';
|
|
17
|
-
export { toJson } from './utils/toJson.js';
|
|
18
|
-
export { toYaml } from './utils/toYaml.js';
|
|
19
|
-
export { transformErrors } from './utils/transformErrors.js';
|
|
20
|
-
export { traverse } from './utils/traverse.js';
|
|
21
|
-
export { unescapeJsonPointer } from './utils/unescapeJsonPointer.js';
|
|
22
|
-
export { upgrade } from './utils/upgrade.js';
|
|
23
|
-
export { upgradeFromThreeToThreeOne } from './utils/upgradeFromThreeToThreeOne.js';
|
|
24
|
-
export { upgradeFromTwoToThree } from './utils/upgradeFromTwoToThree.js';
|
|
25
|
-
export { validate } from './utils/validate.js';
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import Ajv04 from 'ajv-draft-04';
|
|
2
|
-
import addFormats from 'ajv-formats';
|
|
3
|
-
import Ajv2020 from 'ajv/dist/2020.js';
|
|
4
|
-
import { ERRORS, OpenApiVersions, OpenApiSpecifications } from '../../configuration.js';
|
|
5
|
-
import { details } from '../../utils/details.js';
|
|
6
|
-
import { resolveReferences } from '../../utils/resolveReferences.js';
|
|
7
|
-
import { transformErrors } from '../../utils/transformErrors.js';
|
|
8
|
-
|
|
9
|
-
const jsonSchemaVersions = {
|
|
10
|
-
"http://json-schema.org/draft-04/schema#": Ajv04,
|
|
11
|
-
"https://json-schema.org/draft/2020-12/schema": Ajv2020
|
|
12
|
-
};
|
|
13
|
-
class Validator {
|
|
14
|
-
constructor() {
|
|
15
|
-
// Object with function *or* object { errors: string }
|
|
16
|
-
this.ajvValidators = {};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Checks whether a specification is valid and all references can be resolved.
|
|
20
|
-
*/
|
|
21
|
-
async validate(filesystem) {
|
|
22
|
-
const entrypoint = filesystem.find((file) => file.isEntrypoint);
|
|
23
|
-
const specification = entrypoint?.specification;
|
|
24
|
-
this.specification = specification;
|
|
25
|
-
if (this.specification?.info && !this.specification.info.version) {
|
|
26
|
-
this.specification.info.version = "0.0.1";
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
if (specification === void 0 || specification === null) {
|
|
30
|
-
return {
|
|
31
|
-
valid: false,
|
|
32
|
-
errors: transformErrors(entrypoint, ERRORS.EMPTY_OR_INVALID)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const { version, specificationType, specificationVersion } = details(specification);
|
|
36
|
-
this.version = version;
|
|
37
|
-
this.specificationVersion = specificationVersion;
|
|
38
|
-
this.specificationType = specificationType;
|
|
39
|
-
if (!version) {
|
|
40
|
-
return {
|
|
41
|
-
valid: false,
|
|
42
|
-
errors: transformErrors(
|
|
43
|
-
entrypoint,
|
|
44
|
-
ERRORS.OPENAPI_VERSION_NOT_SUPPORTED
|
|
45
|
-
)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const validateSchema = await this.getAjvValidator(version);
|
|
49
|
-
const schemaResult = validateSchema(specification);
|
|
50
|
-
if (validateSchema.errors) {
|
|
51
|
-
if (validateSchema.errors.length > 0) {
|
|
52
|
-
return {
|
|
53
|
-
valid: false,
|
|
54
|
-
errors: transformErrors(entrypoint, validateSchema.errors)
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const resolvedReferences = resolveReferences(filesystem);
|
|
59
|
-
return {
|
|
60
|
-
valid: schemaResult && resolvedReferences.valid,
|
|
61
|
-
errors: [...schemaResult.errors ?? [], ...resolvedReferences.errors],
|
|
62
|
-
schema: resolvedReferences.schema
|
|
63
|
-
};
|
|
64
|
-
} catch (error) {
|
|
65
|
-
return {
|
|
66
|
-
valid: false,
|
|
67
|
-
errors: transformErrors(entrypoint, error.message ?? error)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Ajv JSON schema validator
|
|
73
|
-
*/
|
|
74
|
-
async getAjvValidator(version) {
|
|
75
|
-
if (this.ajvValidators[version]) {
|
|
76
|
-
return this.ajvValidators[version];
|
|
77
|
-
}
|
|
78
|
-
const schema = OpenApiSpecifications[version];
|
|
79
|
-
const AjvClass = jsonSchemaVersions[schema.$schema];
|
|
80
|
-
const ajv = new AjvClass({
|
|
81
|
-
// Ajv is a bit too strict in its strict validation of OpenAPI schemas.
|
|
82
|
-
// Switch strict mode off.
|
|
83
|
-
strict: false
|
|
84
|
-
});
|
|
85
|
-
addFormats(ajv);
|
|
86
|
-
if (version === "3.1") {
|
|
87
|
-
ajv.addFormat("media-range", true);
|
|
88
|
-
}
|
|
89
|
-
return this.ajvValidators[version] = ajv.compile(schema);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
Validator.supportedVersions = OpenApiVersions;
|
|
93
|
-
|
|
94
|
-
export { Validator, jsonSchemaVersions };
|
package/dist/src/pipeline.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { workThroughQueue } from './utils/workThroughQueue.js';
|
|
2
|
-
import { upgrade } from './utils/upgrade.js';
|
|
3
|
-
import { validate } from './utils/validate.js';
|
|
4
|
-
import { dereference } from './utils/dereference.js';
|
|
5
|
-
import { filter } from './utils/filter.js';
|
|
6
|
-
import { getEntrypoint } from './utils/getEntrypoint.js';
|
|
7
|
-
import { details } from './utils/details.js';
|
|
8
|
-
import { toJson } from './utils/toJson.js';
|
|
9
|
-
import { toYaml } from './utils/toYaml.js';
|
|
10
|
-
import { load } from './utils/load/load.js';
|
|
11
|
-
|
|
12
|
-
function openapi() {
|
|
13
|
-
return {
|
|
14
|
-
load: loadAction
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function loadAction(specification, options) {
|
|
18
|
-
const queue = {
|
|
19
|
-
specification,
|
|
20
|
-
tasks: [
|
|
21
|
-
{
|
|
22
|
-
action: load,
|
|
23
|
-
options
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
get: () => getAction(queue),
|
|
29
|
-
files: () => filesAction(queue),
|
|
30
|
-
details: () => detailsAction(queue),
|
|
31
|
-
filter: (callback) => filterAction(queue, callback),
|
|
32
|
-
upgrade: () => upgradeAction(queue),
|
|
33
|
-
validate: () => validateAction(queue),
|
|
34
|
-
dereference: () => dereferenceAction(queue),
|
|
35
|
-
toJson: () => toJsonAction(queue),
|
|
36
|
-
toYaml: () => toYamlAction(queue)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function upgradeAction(queue) {
|
|
40
|
-
queue.tasks.push({
|
|
41
|
-
action: upgrade
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
get: () => getAction(queue),
|
|
45
|
-
files: () => filesAction(queue),
|
|
46
|
-
details: () => detailsAction(queue),
|
|
47
|
-
filter: (callback) => filterAction(queue, callback),
|
|
48
|
-
validate: () => validateAction(queue),
|
|
49
|
-
dereference: () => dereferenceAction(queue),
|
|
50
|
-
toJson: () => toJsonAction(queue),
|
|
51
|
-
toYaml: () => toYamlAction(queue)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function validateAction(queue) {
|
|
55
|
-
queue.tasks.push({
|
|
56
|
-
action: validate
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
filter: (callback) => filterAction(queue, callback),
|
|
60
|
-
get: () => getAction(queue),
|
|
61
|
-
files: () => filesAction(queue),
|
|
62
|
-
details: () => detailsAction(queue),
|
|
63
|
-
dereference: () => dereferenceAction(queue),
|
|
64
|
-
toJson: () => toJsonAction(queue),
|
|
65
|
-
toYaml: () => toYamlAction(queue)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function dereferenceAction(queue) {
|
|
69
|
-
queue.tasks.push({
|
|
70
|
-
action: dereference
|
|
71
|
-
});
|
|
72
|
-
return {
|
|
73
|
-
get: () => getAction(queue),
|
|
74
|
-
files: () => filesAction(queue),
|
|
75
|
-
filter: (callback) => filterAction(queue, callback),
|
|
76
|
-
toJson: () => toJsonAction(queue),
|
|
77
|
-
toYaml: () => toYamlAction(queue)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function filterAction(queue, callback) {
|
|
81
|
-
queue.tasks.push({
|
|
82
|
-
action: filter,
|
|
83
|
-
options: callback
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
get: () => getAction(queue),
|
|
87
|
-
files: () => filesAction(queue),
|
|
88
|
-
details: () => detailsAction(queue),
|
|
89
|
-
filter: () => filterAction(queue, callback),
|
|
90
|
-
upgrade: () => upgradeAction(queue),
|
|
91
|
-
validate: () => validateAction(queue),
|
|
92
|
-
dereference: () => dereferenceAction(queue),
|
|
93
|
-
toJson: () => toJsonAction(queue),
|
|
94
|
-
toYaml: () => toYamlAction(queue)
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
async function getAction(queue) {
|
|
98
|
-
const result = await workThroughQueue(queue);
|
|
99
|
-
if (result.specification === void 0) {
|
|
100
|
-
result.specification = getEntrypoint(result.filesystem).specification;
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
async function filesAction(queue) {
|
|
105
|
-
const { filesystem } = await workThroughQueue(queue);
|
|
106
|
-
return filesystem;
|
|
107
|
-
}
|
|
108
|
-
async function detailsAction(queue) {
|
|
109
|
-
const { filesystem } = await workThroughQueue(queue);
|
|
110
|
-
return details(getEntrypoint(filesystem).specification);
|
|
111
|
-
}
|
|
112
|
-
async function toJsonAction(queue) {
|
|
113
|
-
const { filesystem } = await workThroughQueue(queue);
|
|
114
|
-
return toJson(getEntrypoint(filesystem).specification);
|
|
115
|
-
}
|
|
116
|
-
async function toYamlAction(queue) {
|
|
117
|
-
const { filesystem } = await workThroughQueue(queue);
|
|
118
|
-
return toYaml(getEntrypoint(filesystem).specification);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { openapi };
|