@scalar/oas-utils 0.2.106 → 0.2.107
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 +13 -0
- package/dist/entities/cookie/cookie.d.ts +2 -2
- package/dist/entities/cookie/cookie.js +1 -1
- package/dist/entities/environment/environment.d.ts +2 -2
- package/dist/entities/environment/environment.js +1 -1
- package/dist/entities/shared/utility.d.ts +13 -1
- package/dist/entities/shared/utility.d.ts.map +1 -1
- package/dist/entities/shared/utility.js +4 -1
- package/dist/entities/spec/collection.d.ts +46 -46
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +11 -16
- package/dist/entities/spec/operation.d.ts +22 -22
- package/dist/entities/spec/parameters.d.ts +4 -4
- package/dist/entities/spec/request-examples.d.ts +5 -5
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +25 -62
- package/dist/entities/spec/requests.d.ts +30 -30
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +6 -18
- package/dist/entities/spec/security.d.ts +22 -22
- package/dist/entities/spec/security.d.ts.map +1 -1
- package/dist/entities/spec/security.js +7 -22
- package/dist/entities/spec/server.d.ts +2 -2
- package/dist/entities/spec/server.d.ts.map +1 -1
- package/dist/entities/spec/server.js +3 -5
- package/dist/entities/spec/spec-objects.d.ts +5 -5
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.js +6 -3
- package/dist/entities/spec/x-scalar-secrets.d.ts +4 -4
- package/dist/entities/spec/x-scalar-secrets.d.ts.map +1 -1
- package/dist/entities/workspace/workspace.d.ts +7 -7
- package/dist/entities/workspace/workspace.d.ts.map +1 -1
- package/dist/entities/workspace/workspace.js +5 -5
- package/dist/helpers/fetchSpecFromUrl.d.ts.map +1 -1
- package/dist/helpers/fetchSpecFromUrl.js +1 -1
- package/dist/helpers/json2xml.d.ts.map +1 -1
- package/dist/helpers/json2xml.js +3 -7
- package/dist/migrations/migrator.d.ts +1 -1
- package/dist/migrations/migrator.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.d.ts +1 -1
- package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.js +66 -3
- package/dist/migrations/v-2.5.0/types.generated.d.ts +17 -17
- package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
- package/dist/transforms/import-spec.d.ts +1 -1
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +12 -34
- package/package.json +7 -7
|
@@ -53,13 +53,9 @@ const parseSchema = async (spec, { shouldLoad = true } = {}) => {
|
|
|
53
53
|
/** Converts selected security requirements to uids */
|
|
54
54
|
const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNames = [], securitySchemeMap) => {
|
|
55
55
|
// Set the first security requirement if no preferred security schemes are set
|
|
56
|
-
const names = securityRequirements[0] && !preferredSecurityNames.length
|
|
57
|
-
? [securityRequirements[0]]
|
|
58
|
-
: preferredSecurityNames;
|
|
56
|
+
const names = securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames;
|
|
59
57
|
// Map names to uids
|
|
60
|
-
const uids = names.map((name) => Array.isArray(name)
|
|
61
|
-
? name.map((k) => securitySchemeMap[k])
|
|
62
|
-
: securitySchemeMap[name]);
|
|
58
|
+
const uids = names.map((name) => Array.isArray(name) ? name.map((k) => securitySchemeMap[k]) : securitySchemeMap[name]);
|
|
63
59
|
return uids;
|
|
64
60
|
};
|
|
65
61
|
/**
|
|
@@ -179,38 +175,27 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
179
175
|
const methods = Object.keys(path).filter(isHttpMethod);
|
|
180
176
|
methods.forEach((method) => {
|
|
181
177
|
const operation = path[method];
|
|
182
|
-
const operationServers = serverSchema
|
|
183
|
-
.array()
|
|
184
|
-
.parse(operation.servers ?? []);
|
|
178
|
+
const operationServers = serverSchema.array().parse(operation.servers ?? []);
|
|
185
179
|
servers.push(...operationServers);
|
|
186
180
|
// We will save a list of all tags to ensure they exists at the top level
|
|
187
181
|
// TODO: make sure we add any loose requests with no tags to the collection children
|
|
188
182
|
operation.tags?.forEach((t) => tagNames.add(t));
|
|
189
183
|
// Remove security here and add it correctly below
|
|
190
184
|
const { security: operationSecurity, ...operationWithoutSecurity } = operation;
|
|
191
|
-
const securityRequirements = (operationSecurity ??
|
|
192
|
-
schema.security ??
|
|
193
|
-
[])
|
|
185
|
+
const securityRequirements = (operationSecurity ?? schema.security ?? [])
|
|
194
186
|
.map((s) => {
|
|
195
187
|
const keys = Object.keys(s);
|
|
196
188
|
return keys.length > 1 ? keys : keys[0];
|
|
197
189
|
})
|
|
198
190
|
.filter(isDefined);
|
|
199
191
|
// Filter the preferred security schemes to only include the ones that are in the security requirements
|
|
200
|
-
const preferredSecurityNames = [
|
|
201
|
-
authentication?.preferredSecurityScheme ?? [],
|
|
202
|
-
]
|
|
203
|
-
.flat()
|
|
204
|
-
.filter((name) => {
|
|
192
|
+
const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {
|
|
205
193
|
// Match up complex security requirements, array to array
|
|
206
194
|
if (Array.isArray(name)) {
|
|
207
195
|
// We match every element in the array
|
|
208
|
-
return securityRequirements.some((r) => Array.isArray(r) &&
|
|
209
|
-
r.length === name.length &&
|
|
210
|
-
r.every((v, i) => v === name[i]));
|
|
196
|
+
return securityRequirements.some((r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]));
|
|
211
197
|
}
|
|
212
|
-
|
|
213
|
-
return securityRequirements.includes(name);
|
|
198
|
+
return securityRequirements.includes(name);
|
|
214
199
|
});
|
|
215
200
|
// Set the initially selected security scheme
|
|
216
201
|
const selectedSecuritySchemeUids = securityRequirements.length && !setCollectionSecurity
|
|
@@ -223,10 +208,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
223
208
|
security: operationSecurity,
|
|
224
209
|
selectedSecuritySchemeUids,
|
|
225
210
|
// Merge path and operation level parameters
|
|
226
|
-
parameters: [
|
|
227
|
-
...(path?.parameters ?? []),
|
|
228
|
-
...(operation.parameters ?? []),
|
|
229
|
-
],
|
|
211
|
+
parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])],
|
|
230
212
|
servers: [...pathServers, ...operationServers].map((s) => s.uid),
|
|
231
213
|
};
|
|
232
214
|
// Remove any examples from the request payload as they conflict with our examples property and are not valid
|
|
@@ -246,8 +228,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
246
228
|
[key]: s[key],
|
|
247
229
|
};
|
|
248
230
|
}
|
|
249
|
-
|
|
250
|
-
return s;
|
|
231
|
+
return s;
|
|
251
232
|
});
|
|
252
233
|
// Save parse the request
|
|
253
234
|
const request = schemaModel(requestPayload, requestSchema, false);
|
|
@@ -314,12 +295,9 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
314
295
|
})
|
|
315
296
|
.filter(isDefined);
|
|
316
297
|
// Here we do not filter these as we let the preferredSecurityScheme override the requirements
|
|
317
|
-
const preferredSecurityNames = [
|
|
318
|
-
authentication?.preferredSecurityScheme ?? [],
|
|
319
|
-
].flat();
|
|
298
|
+
const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat();
|
|
320
299
|
// Set the initially selected security scheme
|
|
321
|
-
const selectedSecuritySchemeUids = (securityRequirements.length || preferredSecurityNames?.length) &&
|
|
322
|
-
setCollectionSecurity
|
|
300
|
+
const selectedSecuritySchemeUids = (securityRequirements.length || preferredSecurityNames?.length) && setCollectionSecurity
|
|
323
301
|
? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)
|
|
324
302
|
: [];
|
|
325
303
|
const collection = collectionSchema.parse({
|
|
@@ -384,7 +362,7 @@ function getServersFromOpenApiDocument(servers, { baseServerURL } = {}) {
|
|
|
384
362
|
return parsedSchema;
|
|
385
363
|
}
|
|
386
364
|
catch (error) {
|
|
387
|
-
console.warn(
|
|
365
|
+
console.warn('Oops, that’s an invalid server configuration.');
|
|
388
366
|
console.warn('Server:', server);
|
|
389
367
|
console.warn('Error:', error);
|
|
390
368
|
// Return undefined to remove the server
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.107",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -126,19 +126,19 @@
|
|
|
126
126
|
"nanoid": "^5.0.9",
|
|
127
127
|
"yaml": "^2.4.5",
|
|
128
128
|
"zod": "^3.23.8",
|
|
129
|
-
"@scalar/openapi-types": "0.1.7",
|
|
130
129
|
"@scalar/object-utils": "1.1.13",
|
|
131
|
-
"@scalar/types": "0.
|
|
132
|
-
"@scalar/themes": "0.9.
|
|
130
|
+
"@scalar/openapi-types": "0.1.8",
|
|
131
|
+
"@scalar/themes": "0.9.68",
|
|
132
|
+
"@scalar/types": "0.0.34"
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"type-fest": "^4.20.0",
|
|
136
136
|
"vite": "^5.4.10",
|
|
137
137
|
"vitest": "^1.6.0",
|
|
138
138
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
139
|
-
"@scalar/
|
|
140
|
-
"@scalar/openapi-
|
|
141
|
-
"@scalar/
|
|
139
|
+
"@scalar/openapi-parser": "0.10.8",
|
|
140
|
+
"@scalar/openapi-types": "0.1.8",
|
|
141
|
+
"@scalar/build-tooling": "0.1.14"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
144
144
|
"build": "scalar-build-rollup",
|