@scalar/oas-utils 0.2.119 → 0.2.120
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
CHANGED
|
@@ -17,7 +17,9 @@ export declare const parseSchema: (spec: string | UnknownObject, { shouldLoad }?
|
|
|
17
17
|
}>;
|
|
18
18
|
/** Converts selected security requirements to uids */
|
|
19
19
|
export declare const getSelectedSecuritySchemeUids: (securityRequirements: (string | string[])[], preferredSecurityNames: (string | string[])[] | undefined, securitySchemeMap: Record<string, SecurityScheme["uid"]>) => SelectedSecuritySchemeUids;
|
|
20
|
-
|
|
20
|
+
/** Create a "uid" from a slug */
|
|
21
|
+
export declare const getSlugUid: (slug: string) => Collection["uid"];
|
|
22
|
+
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {
|
|
21
23
|
/** Sets the preferred security scheme on the collection instead of the requests */
|
|
22
24
|
setCollectionSecurity?: boolean;
|
|
23
25
|
/** Call the load step from the parser */
|
|
@@ -36,7 +38,7 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' |
|
|
|
36
38
|
* - Proper linking between related components
|
|
37
39
|
* - Easy lookup and reference of dependent entities
|
|
38
40
|
*/
|
|
39
|
-
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
41
|
+
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity, slug, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
40
42
|
error: false;
|
|
41
43
|
collection: Collection;
|
|
42
44
|
requests: Request[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,0BAA0B,CAAA;AAMjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAAgB,MAAM,GAAG,aAAa;;;IAkC1D;;;OAGG;YAC8C,WAAW,CAAC,QAAQ;;EAGxE,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,6BAA6B,yBAClB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,0BACnB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,iCAC1B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,KACvD,0BAWF,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,WAAW,CAAC,GAC1F,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,GAAG,eAAe,GAAG,SAAS,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,c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AE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CAkUA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAM,GACvE,MAAM,EAAE,CAwCV"}
|
|
@@ -60,6 +60,8 @@ const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNa
|
|
|
60
60
|
.filter(isDefined);
|
|
61
61
|
return uids;
|
|
62
62
|
};
|
|
63
|
+
/** Create a "uid" from a slug */
|
|
64
|
+
const getSlugUid = (slug) => `slug-uid-${slug}`;
|
|
63
65
|
/**
|
|
64
66
|
* Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
|
|
65
67
|
*
|
|
@@ -73,7 +75,7 @@ const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNa
|
|
|
73
75
|
* - Proper linking between related components
|
|
74
76
|
* - Easy lookup and reference of dependent entities
|
|
75
77
|
*/
|
|
76
|
-
async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity = false, shouldLoad, watchMode = false, } = {}) {
|
|
78
|
+
async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: configuredServers, setCollectionSecurity = false, slug, shouldLoad, watchMode = false, } = {}) {
|
|
77
79
|
const { schema, errors } = await parseSchema(spec, { shouldLoad });
|
|
78
80
|
const importWarnings = [...errors.map((e) => e.message)];
|
|
79
81
|
if (!schema)
|
|
@@ -310,7 +312,10 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
310
312
|
const selectedSecuritySchemeUids = (securityRequirements.length || preferredSecurityNames?.length) && setCollectionSecurity
|
|
311
313
|
? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)
|
|
312
314
|
: [];
|
|
315
|
+
// Set the uid as a prefixed slug if we have one
|
|
316
|
+
const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {};
|
|
313
317
|
const collection = collectionSchema.parse({
|
|
318
|
+
...slugObj,
|
|
314
319
|
...schema,
|
|
315
320
|
watchMode,
|
|
316
321
|
documentUrl,
|
|
@@ -394,4 +399,4 @@ function getFallbackUrl() {
|
|
|
394
399
|
return window.location.origin;
|
|
395
400
|
}
|
|
396
401
|
|
|
397
|
-
export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema };
|
|
402
|
+
export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, getSlugUid, importSpecToWorkspace, parseSchema };
|
package/dist/transforms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema } from './import-spec.js';
|
|
1
|
+
export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, getSlugUid, importSpecToWorkspace, parseSchema } from './import-spec.js';
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.120",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
"zod": "^3.23.8",
|
|
129
129
|
"@scalar/object-utils": "1.1.13",
|
|
130
130
|
"@scalar/openapi-types": "0.1.9",
|
|
131
|
-
"@scalar/themes": "0.9.
|
|
132
|
-
"@scalar/types": "0.1.
|
|
131
|
+
"@scalar/themes": "0.9.79",
|
|
132
|
+
"@scalar/types": "0.1.1"
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"type-fest": "^4.20.0",
|