@skmtc/core 0.0.961 → 0.0.963
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/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +19 -10
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +12 -7
- package/esm/context/generateTypes.d.ts +3 -3
- package/esm/context/generateTypes.d.ts.map +1 -1
- package/esm/dsl/EntityType.d.ts.map +1 -1
- package/esm/dsl/EntityType.js +10 -5
- package/esm/helpers/collateExamples.d.ts.map +1 -1
- package/esm/helpers/collateExamples.js +55 -47
- package/esm/helpers/naming.d.ts.map +1 -1
- package/esm/helpers/naming.js +8 -5
- package/esm/oas/document/Document.d.ts.map +1 -1
- package/esm/oas/document/Document.js +16 -17
- package/esm/oas/object/Object.d.ts.map +1 -1
- package/esm/oas/object/Object.js +11 -5
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +24 -12
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +55 -28
- package/esm/oas/schema/toSchemasV3.d.ts.map +1 -1
- package/esm/oas/schema/toSchemasV3.js +96 -89
- package/esm/oas/securitySchemes/toSecuritySchemes.d.ts.map +1 -1
- package/esm/oas/securitySchemes/toSecuritySchemes.js +59 -60
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/FunctionParameter.js +85 -51
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +14 -8
- package/package.json +1 -2
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +19 -10
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +12 -7
- package/script/context/generateTypes.d.ts +3 -3
- package/script/context/generateTypes.d.ts.map +1 -1
- package/script/dsl/EntityType.d.ts.map +1 -1
- package/script/dsl/EntityType.js +10 -5
- package/script/helpers/collateExamples.d.ts.map +1 -1
- package/script/helpers/collateExamples.js +55 -47
- package/script/helpers/naming.d.ts.map +1 -1
- package/script/helpers/naming.js +8 -5
- package/script/oas/document/Document.d.ts.map +1 -1
- package/script/oas/document/Document.js +16 -17
- package/script/oas/object/Object.d.ts.map +1 -1
- package/script/oas/object/Object.js +11 -5
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +24 -12
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +55 -28
- package/script/oas/schema/toSchemasV3.d.ts.map +1 -1
- package/script/oas/schema/toSchemasV3.js +96 -89
- package/script/oas/securitySchemes/toSecuritySchemes.d.ts.map +1 -1
- package/script/oas/securitySchemes/toSecuritySchemes.js +59 -60
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/FunctionParameter.js +85 -51
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +14 -8
package/esm/oas/ref/Ref.js
CHANGED
|
@@ -11,8 +11,32 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _OasRef_fields, _OasRef_oasDocument;
|
|
13
13
|
import { toRefName } from '../../helpers/refFns.js';
|
|
14
|
-
import { match } from 'ts-pattern';
|
|
15
14
|
const MAX_LOOKUPS = 10;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a ref type to its plural components path.
|
|
17
|
+
*/
|
|
18
|
+
function refTypeToPluralPath(refType) {
|
|
19
|
+
switch (refType) {
|
|
20
|
+
case 'schema':
|
|
21
|
+
return 'schemas';
|
|
22
|
+
case 'requestBody':
|
|
23
|
+
return 'requestBodies';
|
|
24
|
+
case 'parameter':
|
|
25
|
+
return 'parameters';
|
|
26
|
+
case 'response':
|
|
27
|
+
return 'responses';
|
|
28
|
+
case 'example':
|
|
29
|
+
return 'examples';
|
|
30
|
+
case 'header':
|
|
31
|
+
return 'headers';
|
|
32
|
+
case 'securityScheme':
|
|
33
|
+
return 'securitySchemes';
|
|
34
|
+
default: {
|
|
35
|
+
const _exhaustive = refType;
|
|
36
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
16
40
|
/**
|
|
17
41
|
* Represents an OpenAPI reference ($ref) in the SKMTC OAS processing system.
|
|
18
42
|
*
|
|
@@ -160,15 +184,34 @@ export class OasRef {
|
|
|
160
184
|
const c = this.oasDocument.components;
|
|
161
185
|
const refName = toRefName(this.$ref);
|
|
162
186
|
const refType = this.refType;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
187
|
+
let resolved;
|
|
188
|
+
switch (refType) {
|
|
189
|
+
case 'schema':
|
|
190
|
+
resolved = c?.schemas?.[refName];
|
|
191
|
+
break;
|
|
192
|
+
case 'requestBody':
|
|
193
|
+
resolved = c?.requestBodies?.[refName];
|
|
194
|
+
break;
|
|
195
|
+
case 'parameter':
|
|
196
|
+
resolved = c?.parameters?.[refName];
|
|
197
|
+
break;
|
|
198
|
+
case 'response':
|
|
199
|
+
resolved = c?.responses?.[refName];
|
|
200
|
+
break;
|
|
201
|
+
case 'example':
|
|
202
|
+
resolved = c?.examples?.[refName];
|
|
203
|
+
break;
|
|
204
|
+
case 'header':
|
|
205
|
+
resolved = c?.headers?.[refName];
|
|
206
|
+
break;
|
|
207
|
+
case 'securityScheme':
|
|
208
|
+
resolved = c?.securitySchemes?.[refName];
|
|
209
|
+
break;
|
|
210
|
+
default: {
|
|
211
|
+
const _exhaustive = refType;
|
|
212
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
172
215
|
if (!resolved) {
|
|
173
216
|
throw new Error(`Ref "${__classPrivateFieldGet(this, _OasRef_fields, "f").$ref}" not found`);
|
|
174
217
|
}
|
|
@@ -202,29 +245,13 @@ export class OasRef {
|
|
|
202
245
|
return resolved;
|
|
203
246
|
}
|
|
204
247
|
const ref = {
|
|
205
|
-
$ref: `#/components/${
|
|
206
|
-
.with('schema', () => 'schemas')
|
|
207
|
-
.with('requestBody', () => 'requestBodies')
|
|
208
|
-
.with('parameter', () => 'parameters')
|
|
209
|
-
.with('response', () => 'responses')
|
|
210
|
-
.with('example', () => 'examples')
|
|
211
|
-
.with('header', () => 'headers')
|
|
212
|
-
.with('securityScheme', () => 'securitySchemes')
|
|
213
|
-
.exhaustive()}/${this.toRefName()}`
|
|
248
|
+
$ref: `#/components/${refTypeToPluralPath(this.refType)}/${this.toRefName()}`
|
|
214
249
|
};
|
|
215
250
|
return ref;
|
|
216
251
|
}
|
|
217
252
|
toJSON() {
|
|
218
253
|
return {
|
|
219
|
-
$ref: `#/components/${
|
|
220
|
-
.with('schema', () => 'schemas')
|
|
221
|
-
.with('requestBody', () => 'requestBodies')
|
|
222
|
-
.with('parameter', () => 'parameters')
|
|
223
|
-
.with('response', () => 'responses')
|
|
224
|
-
.with('example', () => 'examples')
|
|
225
|
-
.with('header', () => 'headers')
|
|
226
|
-
.with('securityScheme', () => 'securitySchemes')
|
|
227
|
-
.exhaustive()}/${this.toRefName()}`
|
|
254
|
+
$ref: `#/components/${refTypeToPluralPath(this.refType)}/${this.toRefName()}`
|
|
228
255
|
};
|
|
229
256
|
}
|
|
230
257
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSchemasV3.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/toSchemasV3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"toSchemasV3.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/toSchemasV3.ts"],"names":[],"mappings":"AACA,OAAO,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G;IAC5B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,GAAG,SAAS,CAAA;IACtE,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,iCAIhC,sBAAsB,KAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAM1D,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { toRefV31 } from '../ref/toRefV31.js';
|
|
2
2
|
import { isRef } from '../../helpers/refFns.js';
|
|
3
|
-
import { match, P } from 'ts-pattern';
|
|
4
3
|
import { toArray } from '../array/toArray.js';
|
|
5
4
|
import { toObject } from '../object/toObject.js';
|
|
6
5
|
import { toInteger } from '../integer/toInteger.js';
|
|
@@ -44,8 +43,7 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
44
43
|
if (isRef(schema)) {
|
|
45
44
|
return toRefV31({ ref: schema, refType: 'schema', stackTrail, context });
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
.with({ allOf: P.array() }, schema => {
|
|
46
|
+
if ('allOf' in schema && Array.isArray(schema.allOf)) {
|
|
49
47
|
return stackTrail.trace('allOf', st => {
|
|
50
48
|
const merged = mergeIntersection({
|
|
51
49
|
schema,
|
|
@@ -53,11 +51,11 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
53
51
|
});
|
|
54
52
|
return toSchemaV3({ schema: merged, stackTrail: st, context });
|
|
55
53
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
54
|
+
}
|
|
55
|
+
if ('oneOf' in schema && Array.isArray(schema.oneOf)) {
|
|
58
56
|
return stackTrail.trace('oneOf', st => {
|
|
59
57
|
const merged = mergeUnion({
|
|
60
|
-
schema
|
|
58
|
+
schema,
|
|
61
59
|
getRef: toGetRef(context.documentObject),
|
|
62
60
|
groupType: 'oneOf'
|
|
63
61
|
});
|
|
@@ -73,17 +71,17 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
73
71
|
}
|
|
74
72
|
return toUnion({ value, members, parentType: 'oneOf', stackTrail: st, context });
|
|
75
73
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
74
|
+
}
|
|
75
|
+
if ('anyOf' in schema && Array.isArray(schema.anyOf)) {
|
|
78
76
|
return stackTrail.trace('anyOf', st => {
|
|
79
77
|
// deno-lint-ignore ban-ts-comment
|
|
80
78
|
// @ts-expect-error
|
|
81
|
-
if (
|
|
82
|
-
const { anyOf, ...value } =
|
|
79
|
+
if (schema['x-expansionResources'] && Array.isArray(schema.anyOf)) {
|
|
80
|
+
const { anyOf, ...value } = schema;
|
|
83
81
|
return toUnion({ value, members: anyOf, parentType: 'anyOf', stackTrail: st, context });
|
|
84
82
|
}
|
|
85
83
|
const merged = mergeUnion({
|
|
86
|
-
schema
|
|
84
|
+
schema,
|
|
87
85
|
getRef: toGetRef(context.documentObject),
|
|
88
86
|
groupType: 'anyOf'
|
|
89
87
|
});
|
|
@@ -99,85 +97,94 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
99
97
|
}
|
|
100
98
|
return toUnion({ value, members, parentType: 'anyOf', stackTrail: st, context });
|
|
101
99
|
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
return toObject({
|
|
119
|
-
value: {
|
|
120
|
-
...value,
|
|
121
|
-
type: 'object'
|
|
122
|
-
},
|
|
123
|
-
stackTrail,
|
|
124
|
-
context
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
if (possibleArray(value)) {
|
|
128
|
-
context.logIssueNoKey({
|
|
129
|
-
level: 'warning',
|
|
130
|
-
message: 'Object has "items" property, but is missing type="array" property',
|
|
131
|
-
parent: value,
|
|
132
|
-
stackTrail,
|
|
133
|
-
type: 'MISSING_ARRAY_TYPE'
|
|
134
|
-
});
|
|
135
|
-
return toArray({
|
|
136
|
-
value: {
|
|
137
|
-
...value,
|
|
138
|
-
type: 'array'
|
|
139
|
-
// Adding cast here since {} is a valid value for items
|
|
140
|
-
},
|
|
141
|
-
stackTrail,
|
|
142
|
-
context
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (possibleBoolean(value)) {
|
|
146
|
-
context.logIssueNoKey({
|
|
147
|
-
level: 'warning',
|
|
148
|
-
message: 'Object has a boolean "default" or "example" property, but is missing type="boolean" property',
|
|
149
|
-
parent: value,
|
|
150
|
-
stackTrail,
|
|
151
|
-
type: 'MISSING_BOOLEAN_TYPE'
|
|
152
|
-
});
|
|
153
|
-
return toBoolean({
|
|
154
|
-
value: {
|
|
155
|
-
...value,
|
|
156
|
-
type: 'boolean'
|
|
157
|
-
},
|
|
158
|
-
stackTrail,
|
|
159
|
-
context
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (possibleString(value)) {
|
|
163
|
-
context.logIssueNoKey({
|
|
164
|
-
level: 'warning',
|
|
165
|
-
message: 'Object has a string "default" or "example" property, but is missing type="string" property',
|
|
166
|
-
parent: value,
|
|
167
|
-
stackTrail,
|
|
168
|
-
type: 'MISSING_STRING_TYPE'
|
|
169
|
-
});
|
|
170
|
-
return toString({
|
|
171
|
-
value: {
|
|
172
|
-
...value,
|
|
173
|
-
type: 'string'
|
|
174
|
-
},
|
|
175
|
-
stackTrail,
|
|
176
|
-
context
|
|
177
|
-
});
|
|
100
|
+
}
|
|
101
|
+
if ('type' in schema) {
|
|
102
|
+
switch (schema.type) {
|
|
103
|
+
case 'object':
|
|
104
|
+
return toObject({ value: schema, stackTrail, context });
|
|
105
|
+
case 'array':
|
|
106
|
+
return toArray({ value: schema, stackTrail, context });
|
|
107
|
+
case 'integer':
|
|
108
|
+
return toInteger({ value: schema, stackTrail, context });
|
|
109
|
+
case 'number':
|
|
110
|
+
return toNumber({ value: schema, stackTrail, context });
|
|
111
|
+
case 'boolean':
|
|
112
|
+
return toBoolean({ value: schema, stackTrail, context });
|
|
113
|
+
case 'string':
|
|
114
|
+
return toString({ value: schema, stackTrail, context });
|
|
178
115
|
}
|
|
179
|
-
|
|
180
|
-
|
|
116
|
+
}
|
|
117
|
+
// Otherwise cases
|
|
118
|
+
if (possibleObject(schema)) {
|
|
119
|
+
context.logIssueNoKey({
|
|
120
|
+
level: 'warning',
|
|
121
|
+
message: 'Object has "properties" property, but is missing type="object" property',
|
|
122
|
+
parent: schema,
|
|
123
|
+
stackTrail,
|
|
124
|
+
type: 'MISSING_OBJECT_TYPE'
|
|
125
|
+
});
|
|
126
|
+
return toObject({
|
|
127
|
+
value: {
|
|
128
|
+
...schema,
|
|
129
|
+
type: 'object'
|
|
130
|
+
},
|
|
131
|
+
stackTrail,
|
|
132
|
+
context
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (possibleArray(schema)) {
|
|
136
|
+
context.logIssueNoKey({
|
|
137
|
+
level: 'warning',
|
|
138
|
+
message: 'Object has "items" property, but is missing type="array" property',
|
|
139
|
+
parent: schema,
|
|
140
|
+
stackTrail,
|
|
141
|
+
type: 'MISSING_ARRAY_TYPE'
|
|
142
|
+
});
|
|
143
|
+
return toArray({
|
|
144
|
+
value: {
|
|
145
|
+
...schema,
|
|
146
|
+
type: 'array'
|
|
147
|
+
// Adding cast here since {} is a valid value for items
|
|
148
|
+
},
|
|
149
|
+
stackTrail,
|
|
150
|
+
context
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (possibleBoolean(schema)) {
|
|
154
|
+
context.logIssueNoKey({
|
|
155
|
+
level: 'warning',
|
|
156
|
+
message: 'Object has a boolean "default" or "example" property, but is missing type="boolean" property',
|
|
157
|
+
parent: schema,
|
|
158
|
+
stackTrail,
|
|
159
|
+
type: 'MISSING_BOOLEAN_TYPE'
|
|
160
|
+
});
|
|
161
|
+
return toBoolean({
|
|
162
|
+
value: {
|
|
163
|
+
...schema,
|
|
164
|
+
type: 'boolean'
|
|
165
|
+
},
|
|
166
|
+
stackTrail,
|
|
167
|
+
context
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (possibleString(schema)) {
|
|
171
|
+
context.logIssueNoKey({
|
|
172
|
+
level: 'warning',
|
|
173
|
+
message: 'Object has a string "default" or "example" property, but is missing type="string" property',
|
|
174
|
+
parent: schema,
|
|
175
|
+
stackTrail,
|
|
176
|
+
type: 'MISSING_STRING_TYPE'
|
|
177
|
+
});
|
|
178
|
+
return toString({
|
|
179
|
+
value: {
|
|
180
|
+
...schema,
|
|
181
|
+
type: 'string'
|
|
182
|
+
},
|
|
183
|
+
stackTrail,
|
|
184
|
+
context
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return toUnknown({ value: schema, stackTrail, context });
|
|
181
188
|
};
|
|
182
189
|
const possibleString = (value) => {
|
|
183
190
|
return (value &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSecuritySchemes.d.ts","sourceRoot":"","sources":["../../../src/oas/securitySchemes/toSecuritySchemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"toSecuritySchemes.d.ts","sourceRoot":"","sources":["../../../src/oas/securitySchemes/toSecuritySchemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAenE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,KAAK,qBAAqB,GAAG;IAC3B,eAAe,EACX,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,oBAAoB,CAAC,GAC1E,SAAS,CAAA;IACb,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,0CAIjC,qBAAqB,KACxB,AAD2B,iDAAiD;AAC5E,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAenC,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { match } from 'ts-pattern';
|
|
2
1
|
import { OasHttpSecurityScheme, OasApiKeySecurityScheme, OasOAuth2SecurityScheme, OasOpenIdSecurityScheme } from './SecurityScheme.js';
|
|
3
2
|
import * as v from 'valibot';
|
|
4
3
|
import { oasApiKeySecuritySchemeData, oasHttpSecuritySchemeData, oasOAuth2SecuritySchemeData, oasOpenIdSecuritySchemeData } from './security-scheme-types.js';
|
|
@@ -20,71 +19,71 @@ const toSecuritySchemeV3 = ({ securityScheme, stackTrail, context }) => {
|
|
|
20
19
|
if (isRef(securityScheme)) {
|
|
21
20
|
return toRefV31({ ref: securityScheme, refType: 'securityScheme', stackTrail, context });
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
switch (securityScheme.type) {
|
|
23
|
+
case 'http': {
|
|
24
|
+
const { type: _type, description, scheme, bearerFormat, ...skipped } = v.parse(oasHttpSecuritySchemeData, securityScheme);
|
|
25
|
+
if (!isEmpty(skipped)) {
|
|
26
|
+
context.logSkippedFields({
|
|
27
|
+
skipped,
|
|
28
|
+
parent: securityScheme,
|
|
29
|
+
stackTrail,
|
|
30
|
+
parentType: 'securityScheme:http'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return new OasHttpSecurityScheme({
|
|
34
|
+
description,
|
|
35
|
+
scheme,
|
|
36
|
+
bearerFormat
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
description,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
case 'apiKey': {
|
|
40
|
+
const { type: _type, in: location, description, name, ...skipped } = v.parse(oasApiKeySecuritySchemeData, securityScheme);
|
|
41
|
+
if (!isEmpty(skipped)) {
|
|
42
|
+
context.logSkippedFields({
|
|
43
|
+
skipped,
|
|
44
|
+
parent: securityScheme,
|
|
45
|
+
stackTrail,
|
|
46
|
+
parentType: 'securityScheme:apiKey'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return new OasApiKeySecurityScheme({
|
|
50
|
+
description,
|
|
51
|
+
name,
|
|
52
|
+
in: location
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
description,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
parentType: 'securityScheme:oauth2'
|
|
55
|
+
case 'oauth2': {
|
|
56
|
+
const { type: _type, flows, description, ...skipped } = v.parse(oasOAuth2SecuritySchemeData, securityScheme);
|
|
57
|
+
if (!isEmpty(skipped)) {
|
|
58
|
+
context.logSkippedFields({
|
|
59
|
+
skipped,
|
|
60
|
+
parent: securityScheme,
|
|
61
|
+
stackTrail,
|
|
62
|
+
parentType: 'securityScheme:oauth2'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return new OasOAuth2SecurityScheme({
|
|
66
|
+
description,
|
|
67
|
+
flows
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
description,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
case 'openIdConnect': {
|
|
71
|
+
const { type: _type, description, openIdConnectUrl, ...skipped } = v.parse(oasOpenIdSecuritySchemeData, securityScheme);
|
|
72
|
+
if (!isEmpty(skipped)) {
|
|
73
|
+
context.logSkippedFields({
|
|
74
|
+
skipped,
|
|
75
|
+
parent: securityScheme,
|
|
76
|
+
stackTrail,
|
|
77
|
+
parentType: 'securityScheme:openIdConnect'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return new OasOpenIdSecurityScheme({
|
|
81
|
+
description,
|
|
82
|
+
openIdConnectUrl
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
86
|
-
.otherwise(other => {
|
|
87
|
-
// TODO: skip ref
|
|
88
|
-
throw new Error(`Unknown security scheme type: ${other}`);
|
|
89
|
-
});
|
|
85
|
+
default:
|
|
86
|
+
// TODO: skip ref
|
|
87
|
+
throw new Error(`Unknown security scheme type: ${securityScheme.type}`);
|
|
88
|
+
}
|
|
90
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAwB,MAAM,WAAW,CAAA;AAItD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