@scalar/oas-utils 0.2.3 → 0.2.4
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 +6 -0
- package/dist/entities/workspace/collection/collection.d.ts +51 -17
- package/dist/entities/workspace/collection/collection.d.ts.map +1 -1
- package/dist/entities/workspace/collection/collection.js +27 -0
- package/dist/entities/workspace/cookie/cookie.d.ts +2 -2
- package/dist/entities/workspace/environment/environment.d.ts +3 -3
- package/dist/entities/workspace/folder/folder.d.ts +4 -4
- package/dist/entities/workspace/security/index.d.ts +3 -0
- package/dist/entities/workspace/security/index.d.ts.map +1 -0
- package/dist/entities/workspace/security/index.js +2 -0
- package/dist/entities/workspace/security/security-requirement.d.ts +13 -0
- package/dist/entities/workspace/security/security-requirement.d.ts.map +1 -0
- package/dist/entities/workspace/security/security-requirement.js +15 -0
- package/dist/entities/workspace/security/security-schemes.d.ts +664 -0
- package/dist/entities/workspace/security/security-schemes.d.ts.map +1 -0
- package/dist/entities/workspace/security/security-schemes.js +146 -0
- package/dist/entities/workspace/server/server.d.ts +6 -6
- package/dist/entities/workspace/spec/request-examples.d.ts +18 -18
- package/dist/entities/workspace/spec/requests.d.ts +23 -11
- package/dist/entities/workspace/spec/requests.d.ts.map +1 -1
- package/dist/entities/workspace/spec/requests.js +9 -0
- package/dist/entities/workspace/workspace.d.ts +6 -6
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +2 -1
- package/dist/helpers/object.d.ts +10 -0
- package/dist/helpers/object.d.ts.map +1 -0
- package/dist/helpers/{objectMerge.js → object.js} +6 -1
- package/dist/helpers/string.d.ts +10 -0
- package/dist/helpers/string.d.ts.map +1 -0
- package/dist/helpers/string.js +14 -0
- package/dist/transforms/import-spec.d.ts +8 -3
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +13 -0
- package/package.json +4 -4
- package/dist/entities/workspace/security-schemes/index.d.ts +0 -2
- package/dist/entities/workspace/security-schemes/index.d.ts.map +0 -1
- package/dist/entities/workspace/security-schemes/index.js +0 -1
- package/dist/entities/workspace/security-schemes/security-schemes.d.ts +0 -19
- package/dist/entities/workspace/security-schemes/security-schemes.d.ts.map +0 -1
- package/dist/entities/workspace/security-schemes/security-schemes.js +0 -15
- package/dist/helpers/objectMerge.d.ts +0 -5
- package/dist/helpers/objectMerge.d.ts.map +0 -1
|
@@ -70,6 +70,7 @@ const importSpecToWorkspace = async (spec) => {
|
|
|
70
70
|
tags: operation.tags || ['default'],
|
|
71
71
|
description: operation.description,
|
|
72
72
|
operationId: operation.operationId,
|
|
73
|
+
security: operation.security,
|
|
73
74
|
summary: operation.summary,
|
|
74
75
|
externalDocs: operation.externalDocs,
|
|
75
76
|
requestBody: operation.requestBody,
|
|
@@ -110,14 +111,26 @@ const importSpecToWorkspace = async (spec) => {
|
|
|
110
111
|
},
|
|
111
112
|
];
|
|
112
113
|
const servers = unparsedServers.map((server) => createServer(server));
|
|
114
|
+
// Select initial security
|
|
115
|
+
const firstSecurityKey = Object.keys(parsedSpec.components?.securitySchemes ?? {})?.[0];
|
|
116
|
+
const firstScheme = parsedSpec.components?.securitySchemes?.[firstSecurityKey ?? ''];
|
|
117
|
+
// In the case of oauth2 we need to select the flow as well
|
|
118
|
+
const flowKey = firstScheme?.type === 'oauth2'
|
|
119
|
+
? Object.keys(firstScheme.flows ?? {})[0]
|
|
120
|
+
: undefined;
|
|
121
|
+
const selectedSecuritySchemes = firstSecurityKey
|
|
122
|
+
? [{ uid: firstSecurityKey, ...(flowKey ? { flowKey } : {}) }]
|
|
123
|
+
: [];
|
|
113
124
|
const collection = createCollection({
|
|
114
125
|
spec: {
|
|
115
126
|
openapi: parsedSpec.openapi,
|
|
116
127
|
info: schema?.info,
|
|
128
|
+
security: parsedSpec.security,
|
|
117
129
|
externalDocs: schema?.externalDocs,
|
|
118
130
|
serverUids: servers.map(({ uid }) => uid),
|
|
119
131
|
tags,
|
|
120
132
|
},
|
|
133
|
+
selectedSecuritySchemes,
|
|
121
134
|
selectedServerUid: servers[0].uid,
|
|
122
135
|
// We default to having all the requests in the root folder
|
|
123
136
|
childUids: folders.map(({ uid }) => uid),
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.4",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"import": "./dist/entities/workspace/server/index.js",
|
|
60
60
|
"types": "./dist/entities/workspace/server/index.d.ts"
|
|
61
61
|
},
|
|
62
|
-
"./entities/workspace/security
|
|
63
|
-
"import": "./dist/entities/workspace/security
|
|
64
|
-
"types": "./dist/entities/workspace/security
|
|
62
|
+
"./entities/workspace/security": {
|
|
63
|
+
"import": "./dist/entities/workspace/security/index.js",
|
|
64
|
+
"types": "./dist/entities/workspace/security/index.d.ts"
|
|
65
65
|
},
|
|
66
66
|
"./entities/workspace/folder": {
|
|
67
67
|
"import": "./dist/entities/workspace/folder/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/entities/workspace/security-schemes/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createSecurityScheme } from './security-schemes.js';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
declare const securityScheme: z.ZodObject<{
|
|
3
|
-
/** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2",
|
|
4
|
-
* "openIdConnect". */
|
|
5
|
-
type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["apiKey", "http", "mutualTLS", "oauth2"]>>>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
type: "apiKey" | "http" | "mutualTLS" | "oauth2";
|
|
8
|
-
}, {
|
|
9
|
-
type?: "apiKey" | "http" | "mutualTLS" | "oauth2" | undefined;
|
|
10
|
-
}>;
|
|
11
|
-
/** Folders will correspond to the x- */
|
|
12
|
-
export type SecurityScheme = z.infer<typeof securityScheme>;
|
|
13
|
-
export type SecuritySchemePayload = z.input<typeof securityScheme>;
|
|
14
|
-
/** Create Security Scheme with defaults */
|
|
15
|
-
export declare const createSecurityScheme: (payload: SecuritySchemePayload) => {
|
|
16
|
-
type: "apiKey" | "http" | "mutualTLS" | "oauth2";
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=security-schemes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/entities/workspace/security-schemes/security-schemes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,QAAA,MAAM,cAAc;IAClB;0BACsB;;;;;;EAKtB,CAAA;AAEF,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAC3D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAElE,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,YAAa,qBAAqB;;CACrB,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { deepMerge } from '../../../helpers/deepMerge.js';
|
|
3
|
-
|
|
4
|
-
const securityScheme = z.object({
|
|
5
|
-
/** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2",
|
|
6
|
-
* "openIdConnect". */
|
|
7
|
-
type: z
|
|
8
|
-
.enum(['apiKey', 'http', 'mutualTLS', 'oauth2'])
|
|
9
|
-
.optional()
|
|
10
|
-
.default('apiKey'),
|
|
11
|
-
});
|
|
12
|
-
/** Create Security Scheme with defaults */
|
|
13
|
-
const createSecurityScheme = (payload) => deepMerge(securityScheme.parse({}), payload);
|
|
14
|
-
|
|
15
|
-
export { createSecurityScheme };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectMerge.d.ts","sourceRoot":"","sources":["../../src/helpers/objectMerge.ts"],"names":[],"mappings":"AACA;;IAEI;AACJ,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC5D,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,CAAC,KAYf"}
|