@xyd-js/openapi 0.1.0-xyd.0 → 0.1.0-xyd.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/dist/index.cjs +394 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +356 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
deferencedOpenAPI: () => deferencedOpenAPI,
|
|
34
|
+
oapSchemaToReferences: () => oapSchemaToReferences
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/const.ts
|
|
39
|
+
var SUPPORTED_HTTP_METHODS = [
|
|
40
|
+
"get",
|
|
41
|
+
"put",
|
|
42
|
+
"patch",
|
|
43
|
+
"post",
|
|
44
|
+
"delete"
|
|
45
|
+
// 'options',
|
|
46
|
+
// 'head',
|
|
47
|
+
// 'trace'
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
// src/parameters.ts
|
|
51
|
+
function oapParametersToDefinitionProperties(parameters) {
|
|
52
|
+
const parameterIn = {};
|
|
53
|
+
parameters.forEach((param) => {
|
|
54
|
+
if (!parameterIn[param.in]) {
|
|
55
|
+
parameterIn[param.in] = [];
|
|
56
|
+
}
|
|
57
|
+
const schema = param.schema;
|
|
58
|
+
const property = {
|
|
59
|
+
name: param.name,
|
|
60
|
+
type: schema.type || "",
|
|
61
|
+
description: param.description || ""
|
|
62
|
+
};
|
|
63
|
+
parameterIn[param.in].push(property);
|
|
64
|
+
});
|
|
65
|
+
return parameterIn;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/properties.ts
|
|
69
|
+
function schemaObjectToDefinitionProperties(v) {
|
|
70
|
+
return Object.entries(v.properties || {}).map(([name, prop]) => {
|
|
71
|
+
let objProp = prop;
|
|
72
|
+
let merged = [];
|
|
73
|
+
if (objProp.allOf) {
|
|
74
|
+
merged = objProp.allOf.reduce((acc, of) => {
|
|
75
|
+
return [
|
|
76
|
+
...acc,
|
|
77
|
+
...schemaObjectToDefinitionProperties(of)
|
|
78
|
+
];
|
|
79
|
+
}, []);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
name,
|
|
83
|
+
type: objProp.type || "",
|
|
84
|
+
description: objProp.description || "",
|
|
85
|
+
properties: (merged == null ? void 0 : merged.length) ? merged : objProp.properties ? schemaObjectToDefinitionProperties(objProp) : []
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/requestBody.ts
|
|
91
|
+
function oapRequestBodyToDefinitionProperties(reqBody) {
|
|
92
|
+
const schema = reqBody.content["application/json"].schema;
|
|
93
|
+
let schemaObject;
|
|
94
|
+
if (schema.allOf) {
|
|
95
|
+
return schema.allOf.reduce((acc, of) => {
|
|
96
|
+
const fakeBody = {
|
|
97
|
+
content: {
|
|
98
|
+
"application/json": {
|
|
99
|
+
schema: of
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return [
|
|
104
|
+
...acc,
|
|
105
|
+
...oapRequestBodyToDefinitionProperties(fakeBody) || []
|
|
106
|
+
];
|
|
107
|
+
}, []);
|
|
108
|
+
}
|
|
109
|
+
switch (schema.type) {
|
|
110
|
+
case "object": {
|
|
111
|
+
schemaObject = schema;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "array": {
|
|
115
|
+
const arrSchema = schema;
|
|
116
|
+
const items = arrSchema.items;
|
|
117
|
+
schemaObject = items;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
default:
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (!schemaObject) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return schemaObjectToDefinitionProperties(schemaObject);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/responses.ts
|
|
130
|
+
function oapResponseToDefinitionProperties(responses) {
|
|
131
|
+
var _a, _b, _c, _d;
|
|
132
|
+
let schemaObject;
|
|
133
|
+
if (responses["default"]) {
|
|
134
|
+
const w = responses["default"];
|
|
135
|
+
schemaObject = (_b = (_a = w == null ? void 0 : w.content) == null ? void 0 : _a["application/json"]) == null ? void 0 : _b.schema;
|
|
136
|
+
} else if (responses["200"]) {
|
|
137
|
+
const w = responses["200"];
|
|
138
|
+
schemaObject = (_d = (_c = w == null ? void 0 : w.content) == null ? void 0 : _c["application/json"]) == null ? void 0 : _d.schema;
|
|
139
|
+
}
|
|
140
|
+
if (!schemaObject) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
switch (schemaObject.type) {
|
|
144
|
+
case "array":
|
|
145
|
+
const arrSchema = schemaObject;
|
|
146
|
+
const items = arrSchema.items;
|
|
147
|
+
schemaObject = items;
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
return schemaObjectToDefinitionProperties(schemaObject);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/schema.ts
|
|
156
|
+
var import_oas = __toESM(require("oas"), 1);
|
|
157
|
+
|
|
158
|
+
// src/paths.ts
|
|
159
|
+
var import_uniform2 = require("@xyd-js/uniform");
|
|
160
|
+
|
|
161
|
+
// src/utils.ts
|
|
162
|
+
var import_path = __toESM(require("path"), 1);
|
|
163
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
164
|
+
var import_js_yaml = __toESM(require("js-yaml"), 1);
|
|
165
|
+
var import_json_schema_ref_parser = __toESM(require("json-schema-ref-parser"), 1);
|
|
166
|
+
var import_uniform = require("@xyd-js/uniform");
|
|
167
|
+
function toPascalCase(str) {
|
|
168
|
+
return str.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
169
|
+
}
|
|
170
|
+
function readOpenApiSpec(filePath) {
|
|
171
|
+
const ext = import_path.default.extname(filePath).toLowerCase();
|
|
172
|
+
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
173
|
+
if (ext === ".yaml" || ext === ".yml") {
|
|
174
|
+
return import_js_yaml.default.load(content);
|
|
175
|
+
} else if (ext === ".json") {
|
|
176
|
+
return JSON.parse(content);
|
|
177
|
+
} else {
|
|
178
|
+
throw new Error("Unsupported file format. Use JSON or YAML.");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function deferencedOpenAPI(openApiPath) {
|
|
182
|
+
const openApiSpec = readOpenApiSpec(openApiPath);
|
|
183
|
+
await import_json_schema_ref_parser.default.dereference(openApiSpec);
|
|
184
|
+
return openApiSpec;
|
|
185
|
+
}
|
|
186
|
+
function httpMethodToUniformMethod(method) {
|
|
187
|
+
switch (method) {
|
|
188
|
+
case "get":
|
|
189
|
+
return import_uniform.ReferenceType.REST_HTTP_GET;
|
|
190
|
+
case "put":
|
|
191
|
+
return import_uniform.ReferenceType.REST_HTTP_PUT;
|
|
192
|
+
case "patch":
|
|
193
|
+
return import_uniform.ReferenceType.REST_HTTP_PATCH;
|
|
194
|
+
case "post":
|
|
195
|
+
return import_uniform.ReferenceType.REST_HTTP_POST;
|
|
196
|
+
case "delete":
|
|
197
|
+
return import_uniform.ReferenceType.REST_HTTP_DELETE;
|
|
198
|
+
// case 'options':
|
|
199
|
+
// return ReferenceType.REST_HTTP_OPTIONS
|
|
200
|
+
// case 'head':
|
|
201
|
+
// return ReferenceType.REST_HTTP_HEAD
|
|
202
|
+
// case 'trace':
|
|
203
|
+
// return ReferenceType.REST_HTTP_TRACE
|
|
204
|
+
default:
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/paths.ts
|
|
210
|
+
function oapPathToReference(httpMethod, path2, oapPath) {
|
|
211
|
+
const mType = httpMethodToUniformMethod(httpMethod);
|
|
212
|
+
if (!mType) {
|
|
213
|
+
console.error(`Unsupported method: ${httpMethod}`);
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const definitions = [];
|
|
217
|
+
const exampleGroups = [];
|
|
218
|
+
const oapMethod = oapPath == null ? void 0 : oapPath[httpMethod];
|
|
219
|
+
if (!oapMethod) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const endpointRef = {
|
|
223
|
+
title: (oapMethod == null ? void 0 : oapMethod.summary) || "",
|
|
224
|
+
canonical: toPascalCase((oapMethod == null ? void 0 : oapMethod.summary) || ""),
|
|
225
|
+
description: (oapMethod == null ? void 0 : oapMethod.description) || "",
|
|
226
|
+
category: import_uniform2.ReferenceCategory.REST,
|
|
227
|
+
type: mType,
|
|
228
|
+
context: {
|
|
229
|
+
method: httpMethod,
|
|
230
|
+
path: path2
|
|
231
|
+
},
|
|
232
|
+
examples: {
|
|
233
|
+
groups: exampleGroups
|
|
234
|
+
},
|
|
235
|
+
definitions
|
|
236
|
+
};
|
|
237
|
+
if (oapMethod.parameters) {
|
|
238
|
+
const parameters = oapMethod.parameters;
|
|
239
|
+
const paramtersMap = oapParametersToDefinitionProperties(parameters);
|
|
240
|
+
Object.entries(paramtersMap).forEach(([key, definitionProperties]) => {
|
|
241
|
+
let title;
|
|
242
|
+
switch (key) {
|
|
243
|
+
case "path":
|
|
244
|
+
title = "Paths";
|
|
245
|
+
break;
|
|
246
|
+
case "query":
|
|
247
|
+
title = "Query";
|
|
248
|
+
break;
|
|
249
|
+
case "header":
|
|
250
|
+
title = "Header";
|
|
251
|
+
break;
|
|
252
|
+
default:
|
|
253
|
+
console.error(`Unsupported parameter type: ${key} for ${httpMethod} ${path2}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
definitions.push({
|
|
257
|
+
title,
|
|
258
|
+
properties: definitionProperties
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (oapMethod.requestBody) {
|
|
263
|
+
const reqBody = oapMethod.requestBody;
|
|
264
|
+
definitions.push({
|
|
265
|
+
title: "Request body",
|
|
266
|
+
properties: oapRequestBodyToDefinitionProperties(reqBody) || []
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (oapMethod.responses) {
|
|
270
|
+
const responses = oapMethod.responses;
|
|
271
|
+
definitions.push({
|
|
272
|
+
title: "Response",
|
|
273
|
+
properties: oapResponseToDefinitionProperties(responses) || []
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return endpointRef;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/examples.ts
|
|
280
|
+
var import_oas_to_snippet = __toESM(require("@readme/oas-to-snippet"), 1);
|
|
281
|
+
var import_openapi_sampler = __toESM(require("openapi-sampler"), 1);
|
|
282
|
+
function oapExamples(oas, operation) {
|
|
283
|
+
const exampleGroups = [];
|
|
284
|
+
if (operation.schema.requestBody) {
|
|
285
|
+
const body = operation.schema.requestBody;
|
|
286
|
+
const schema = fixAllOfBug(
|
|
287
|
+
body.content["application/json"].schema
|
|
288
|
+
);
|
|
289
|
+
if (!schema) {
|
|
290
|
+
return exampleGroups;
|
|
291
|
+
}
|
|
292
|
+
const fakeData = import_openapi_sampler.default.sample(schema);
|
|
293
|
+
const { code } = (0, import_oas_to_snippet.default)(oas, operation, {
|
|
294
|
+
body: fakeData
|
|
295
|
+
}, null, "shell");
|
|
296
|
+
const examples = [];
|
|
297
|
+
examples.push({
|
|
298
|
+
codeblock: {
|
|
299
|
+
tabs: [{
|
|
300
|
+
title: "curl",
|
|
301
|
+
language: "curl",
|
|
302
|
+
code: code || ""
|
|
303
|
+
}]
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
exampleGroups.push({
|
|
307
|
+
description: "Example request",
|
|
308
|
+
examples
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (operation.schema.responses) {
|
|
312
|
+
const responses = operation.schema.responses;
|
|
313
|
+
const examples = [];
|
|
314
|
+
Object.entries(responses).forEach(([status, r]) => {
|
|
315
|
+
var _a;
|
|
316
|
+
const response = r;
|
|
317
|
+
const schema = (_a = response == null ? void 0 : response.content) == null ? void 0 : _a["application/json"].schema;
|
|
318
|
+
if (!schema) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const fakeData = import_openapi_sampler.default.sample(schema);
|
|
322
|
+
examples.push({
|
|
323
|
+
codeblock: {
|
|
324
|
+
title: status,
|
|
325
|
+
tabs: [{
|
|
326
|
+
title: "json",
|
|
327
|
+
language: "json",
|
|
328
|
+
code: JSON.stringify(fakeData, null, 2) || ""
|
|
329
|
+
}]
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
exampleGroups.push({
|
|
334
|
+
description: "Response",
|
|
335
|
+
examples
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return exampleGroups;
|
|
339
|
+
}
|
|
340
|
+
function fixAllOfBug(schema) {
|
|
341
|
+
const modifiedSchema = { ...schema };
|
|
342
|
+
if (schema.allOf) {
|
|
343
|
+
schema.allOf.forEach((prop, i) => {
|
|
344
|
+
var _a;
|
|
345
|
+
const propObj = prop;
|
|
346
|
+
if ("properties" in propObj && !propObj["properties"]) {
|
|
347
|
+
(_a = modifiedSchema.allOf) == null ? true : delete _a[i];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return modifiedSchema;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/schema.ts
|
|
355
|
+
function oapSchemaToReferences(schema) {
|
|
356
|
+
const references = [];
|
|
357
|
+
const oas = new import_oas.default(schema);
|
|
358
|
+
Object.entries(schema.paths).forEach(([path2, oapPath]) => {
|
|
359
|
+
let type;
|
|
360
|
+
SUPPORTED_HTTP_METHODS.forEach((eachMethod) => {
|
|
361
|
+
const httpMethod = eachMethod.toLowerCase();
|
|
362
|
+
switch (httpMethod) {
|
|
363
|
+
case "get":
|
|
364
|
+
break;
|
|
365
|
+
case "put":
|
|
366
|
+
break;
|
|
367
|
+
case "post":
|
|
368
|
+
break;
|
|
369
|
+
case "delete":
|
|
370
|
+
break;
|
|
371
|
+
default:
|
|
372
|
+
console.error(`Unsupported method: ${httpMethod}`);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const reference = oapPathToReference(
|
|
376
|
+
httpMethod,
|
|
377
|
+
path2,
|
|
378
|
+
oapPath
|
|
379
|
+
);
|
|
380
|
+
if (reference) {
|
|
381
|
+
const operation = oas.operation(path2, httpMethod);
|
|
382
|
+
reference.examples.groups = oapExamples(oas, operation);
|
|
383
|
+
references.push(reference);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
return references;
|
|
388
|
+
}
|
|
389
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
390
|
+
0 && (module.exports = {
|
|
391
|
+
deferencedOpenAPI,
|
|
392
|
+
oapSchemaToReferences
|
|
393
|
+
});
|
|
394
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts","../src/const.ts","../src/parameters.ts","../src/properties.ts","../src/requestBody.ts","../src/responses.ts","../src/schema.ts","../src/paths.ts","../src/utils.ts","../src/examples.ts"],"sourcesContent":["export {\n deferencedOpenAPI,\n oapSchemaToReferences\n} from \"./src\";","export const SUPPORTED_HTTP_METHODS: string[] = [\n 'get',\n 'put',\n 'patch',\n 'post',\n 'delete',\n // 'options',\n // 'head',\n // 'trace'\n];","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\n// oapParametersToDefinitionProperties converts OpenAPI parameters to uniform DefinitionProperties\nexport function oapParametersToDefinitionProperties(\n parameters: OpenAPIV3.ParameterObject[]\n): { [key: string]: DefinitionProperty[] } {\n const parameterIn: { [key: string]: DefinitionProperty[] } = {}\n\n parameters.forEach((param) => {\n if (!parameterIn[param.in]) {\n parameterIn[param.in] = []\n }\n\n const schema = param.schema as OpenAPIV3.SchemaObject\n\n const property: DefinitionProperty = {\n name: param.name,\n type: schema.type || \"\",\n description: param.description || \"\"\n }\n\n parameterIn[param.in].push(property)\n })\n\n return parameterIn\n}\n","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\n// schemaObjectToDefinitionProperties converts OpenAPI schema object to uniform DefinitionProperty[]\nexport function schemaObjectToDefinitionProperties(v: OpenAPIV3.SchemaObject): DefinitionProperty[] {\n return Object.entries(v.properties || {}).map(([name, prop]) => {\n let objProp = prop as OpenAPIV3.SchemaObject\n\n let merged: DefinitionProperty[] = []\n\n if (objProp.allOf) {\n merged = objProp.allOf.reduce((acc, of) => {\n return [\n ...acc,\n ...schemaObjectToDefinitionProperties(of as OpenAPIV3.SchemaObject)\n ]\n }, [] as DefinitionProperty[])\n }\n\n return {\n name: name,\n type: objProp.type || \"\",\n description: objProp.description || \"\",\n properties: (\n merged?.length\n ? merged\n : objProp.properties ? schemaObjectToDefinitionProperties(objProp) : []\n )\n }\n })\n}","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\nimport {schemaObjectToDefinitionProperties} from \"./properties\";\n\n// oapRequestBodyToDefinitionProperties converts OpenAPI request body to uniform DefinitionProperties\nexport function oapRequestBodyToDefinitionProperties(\n reqBody: OpenAPIV3.RequestBodyObject\n): DefinitionProperty[] | null {\n // TODO: support other content types ???\n const schema = reqBody.content['application/json'].schema as OpenAPIV3.SchemaObject\n\n let schemaObject: OpenAPIV3.SchemaObject | undefined\n\n if (schema.allOf) {\n return schema.allOf.reduce((acc, of) => {\n const fakeBody: OpenAPIV3.RequestBodyObject = {\n content: {\n 'application/json': {\n schema: of\n }\n }\n }\n\n return [\n ...acc,\n ...oapRequestBodyToDefinitionProperties(fakeBody) || []\n ]\n }, [] as DefinitionProperty[])\n }\n\n switch (schema.type) {\n case 'object': {\n schemaObject = schema\n break\n }\n case 'array': {\n const arrSchema = schema as OpenAPIV3.ArraySchemaObject\n\n const items = arrSchema.items as OpenAPIV3.SchemaObject\n\n schemaObject = items\n break\n }\n default:\n // TODO: primitive types ???\n break\n }\n\n if (!schemaObject) {\n return null\n }\n\n return schemaObjectToDefinitionProperties(schemaObject)\n}","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\nimport {schemaObjectToDefinitionProperties} from \"./properties\";\n\nexport function oapResponseToDefinitionProperties(\n responses: OpenAPIV3.ResponsesObject\n): DefinitionProperty[] | null {\n let schemaObject: OpenAPIV3.SchemaObject | undefined\n // TODO: support another statuses\n if (responses[\"default\"]) {\n const w = responses[\"default\"] as OpenAPIV3.ResponseObject\n\n schemaObject = w?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject\n } else if (responses[\"200\"]) {\n const w = responses[\"200\"] as OpenAPIV3.ResponseObject\n\n schemaObject = w?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject\n }\n\n if (!schemaObject) {\n return null\n }\n\n switch (schemaObject.type) {\n case 'array':\n const arrSchema = schemaObject as OpenAPIV3.ArraySchemaObject\n\n const items = arrSchema.items as OpenAPIV3.SchemaObject\n\n schemaObject = items\n break\n default:\n break\n }\n\n return schemaObjectToDefinitionProperties(schemaObject)\n}","import {OpenAPIV3} from \"openapi-types\";\nimport Oas from \"oas\";\nimport {Reference, ReferenceType} from \"@xyd-js/uniform\";\n\nimport {SUPPORTED_HTTP_METHODS} from \"./const\";\nimport {oapPathToReference} from \"./paths\";\nimport {oapExamples} from \"./examples\";\n\n// TODO: support one-of\n// TODO: support $ref - currently we use $refParser.dereference that converts $ref into objects\n// TODO: better method check system - currently we need to manually check that in few methods\n\n// oapSchemaToReferences converts an OpenAPI schema to a list of uniform References\nexport function oapSchemaToReferences(\n schema: OpenAPIV3.Document\n): Reference[] {\n const references: Reference[] = [];\n const oas = new Oas(schema as any);\n\n Object.entries(schema.paths).forEach(([path, oapPath]) => {\n let type: ReferenceType;\n\n SUPPORTED_HTTP_METHODS.forEach((eachMethod) => {\n const httpMethod = eachMethod.toLowerCase()\n\n switch (httpMethod) {\n case 'get':\n break\n case 'put':\n break\n case 'post':\n break\n case 'delete':\n break\n default:\n console.error(`Unsupported method: ${httpMethod}`)\n return\n }\n\n const reference = oapPathToReference(\n httpMethod,\n path,\n oapPath as OpenAPIV3.PathItemObject\n )\n\n if (reference) {\n const operation = oas.operation(path, httpMethod);\n reference.examples.groups = oapExamples(oas, operation)\n\n references.push(reference)\n }\n })\n })\n\n return references\n}\n","import {OpenAPIV3} from \"openapi-types\";\nimport {Definition, ExampleGroup, Reference, ReferenceCategory} from \"@xyd-js/uniform\";\n\nimport {oapParametersToDefinitionProperties} from \"./parameters\";\nimport {oapRequestBodyToDefinitionProperties} from \"./requestBody\";\nimport {oapResponseToDefinitionProperties} from \"./responses\";\nimport {\n httpMethodToUniformMethod,\n toPascalCase\n} from \"./utils\";\n\n// oapPathToReference converts an OpenAPI path to a uniform Reference\nexport function oapPathToReference(\n httpMethod: \"get\" | \"put\" | \"post\" | \"delete\", // TODO: ts type\n path: string,\n oapPath: OpenAPIV3.PathItemObject,\n): Reference | null {\n const mType = httpMethodToUniformMethod(httpMethod)\n\n if (!mType) {\n console.error(`Unsupported method: ${httpMethod}`)\n return null\n }\n\n const definitions: Definition[] = []\n const exampleGroups: ExampleGroup[] = []\n\n const oapMethod = oapPath?.[httpMethod] as OpenAPIV3.OperationObject\n\n if (!oapMethod) {\n return null\n }\n\n const endpointRef: Reference = {\n title: oapMethod?.summary || \"\",\n canonical: toPascalCase(oapMethod?.summary || \"\"),\n description: oapMethod?.description || \"\",\n\n category: ReferenceCategory.REST,\n type: mType,\n\n context: {\n method: httpMethod,\n\n path\n },\n\n examples: {\n groups: exampleGroups,\n },\n definitions: definitions,\n }\n\n if (oapMethod.parameters) {\n const parameters = oapMethod.parameters as OpenAPIV3.ParameterObject[]\n\n const paramtersMap = oapParametersToDefinitionProperties(parameters) // TODO: finish\n\n Object.entries(paramtersMap).forEach(([key, definitionProperties]) => {\n let title: string\n\n // TODO: add context to definition\n switch (key) {\n case 'path':\n title = \"Paths\"\n break\n case 'query':\n title = \"Query\"\n break\n case 'header':\n title = \"Header\"\n break\n default:\n console.error(`Unsupported parameter type: ${key} for ${httpMethod} ${path}`)\n return\n }\n\n definitions.push({\n title,\n properties: definitionProperties\n })\n })\n }\n\n if (oapMethod.requestBody) {\n const reqBody = oapMethod.requestBody as OpenAPIV3.RequestBodyObject\n\n definitions.push({\n title: 'Request body',\n properties: oapRequestBodyToDefinitionProperties(reqBody) || []\n })\n }\n\n if (oapMethod.responses) {\n const responses = oapMethod.responses as OpenAPIV3.ResponsesObject\n\n definitions.push({\n title: 'Response',\n properties: oapResponseToDefinitionProperties(responses) || []\n })\n }\n\n return endpointRef\n}\n","import path from \"path\";\nimport fs from \"fs\";\nimport yaml from \"js-yaml\";\nimport $refParser from \"json-schema-ref-parser\";\nimport {OpenAPIV3} from \"openapi-types\";\n\nimport {ReferenceType} from \"@xyd-js/uniform\";\n\ntype Parameters = {\n query?: Record<string, string | number | boolean>;\n headers?: Record<string, string>;\n};\n\nexport function toPascalCase(str: string): string {\n return str\n .split(/[\\s_-]+/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('');\n}\n\n// readOpenApiSpec reads an OpenAPI spec file and returns the content\nfunction readOpenApiSpec(filePath: string) {\n const ext = path.extname(filePath).toLowerCase();\n const content = fs.readFileSync(filePath, 'utf-8');\n\n if (ext === '.yaml' || ext === '.yml') {\n return yaml.load(content);\n } else if (ext === '.json') {\n return JSON.parse(content);\n } else {\n throw new Error('Unsupported file format. Use JSON or YAML.');\n }\n}\n\n// deferencedOpenAPI reads an OpenAPI spec file and returns a dereferenced OpenAPIV3.Document\n// dereferenced means that all $ref references are resolved automatically\nexport async function deferencedOpenAPI(openApiPath: string) {\n const openApiSpec = readOpenApiSpec(openApiPath);\n\n //@ts-ignore TODO: fix ts\n await $refParser.dereference(openApiSpec);\n\n return openApiSpec as OpenAPIV3.Document\n}\n\n// httpMethodToUniformMethod converts an HTTP method to a uniform ReferenceType\nexport function httpMethodToUniformMethod(method: string): ReferenceType | null {\n switch (method) {\n case 'get':\n return ReferenceType.REST_HTTP_GET\n case 'put':\n return ReferenceType.REST_HTTP_PUT\n case 'patch':\n return ReferenceType.REST_HTTP_PATCH\n case 'post':\n return ReferenceType.REST_HTTP_POST\n case 'delete':\n return ReferenceType.REST_HTTP_DELETE\n // case 'options':\n // return ReferenceType.REST_HTTP_OPTIONS\n // case 'head':\n // return ReferenceType.REST_HTTP_HEAD\n // case 'trace':\n // return ReferenceType.REST_HTTP_TRACE\n default:\n return null\n }\n}\n\n// schemaToRequestBody generates a request body from an OpenAPI schema\nfunction schemaToRequestBody(schema: OpenAPIV3.SchemaObject): string {\n const requestBody: any = {};\n\n if (schema.type === 'object' && schema.properties) {\n for (const [key, value] of Object.entries(schema.properties)) {\n if ((value as OpenAPIV3.SchemaObject).default !== undefined) {\n requestBody[key] = (value as OpenAPIV3.SchemaObject).default;\n } else {\n requestBody[key] = null; // or some placeholder value\n }\n }\n }\n\n return JSON.stringify(requestBody);\n}\n\n// generateRequestInitFromOpenAPIObject generates a RequestInit object from an OpenAPI object\nexport function generateRequestInitFromOapOperation(\n urlPath: string,\n operation: OpenAPIV3.OperationObject\n): { url: string, reqInit: RequestInit } {\n const reqInit: RequestInit = {}\n let queryParams = '';\n\n if (operation.parameters) {\n const parameters = operation.parameters as OpenAPIV3.ParameterObject[]\n\n const params = new URLSearchParams(\n Object.entries(parameters).map(([key, value]) => [key, String(value)])\n ).toString();\n\n queryParams += `?${params}`;\n }\n\n if (operation.requestBody) {\n const reqBody = operation.requestBody as OpenAPIV3.RequestBodyObject;\n const contentType = Object.keys(reqBody.content || {})[0];\n\n if (contentType === \"application/json\") {\n const schema = reqBody.content['application/json'].schema as OpenAPIV3.SchemaObject\n\n reqInit.body = schemaToRequestBody(schema);\n reqInit.headers = {\n 'Content-Type': 'application/json',\n }\n }\n }\n\n return {\n url: `${urlPath}${queryParams}`,\n reqInit,\n };\n}\n\n","import {OpenAPIV3} from \"openapi-types\";\nimport Oas from \"oas\";\n// @ts-ignore\nimport {Operation} from 'oas/operation'; // TODO: fix ts\nimport oasToSnippet from \"@readme/oas-to-snippet\";\nimport OpenAPISampler from \"openapi-sampler\";\nimport type {JSONSchema7} from \"json-schema\";\n\nimport {ExampleGroup, Example} from \"@xyd-js/uniform\";\n\n// TODO: option with another languages\n// TODO: uniform plugins\n// TODO: fs uniform plugins\nexport function oapExamples(\n oas: Oas,\n operation: Operation\n): ExampleGroup[] {\n const exampleGroups: ExampleGroup[] = []\n\n if (operation.schema.requestBody) {\n const body = operation.schema.requestBody as OpenAPIV3.RequestBodyObject\n const schema = fixAllOfBug(\n body.content[\"application/json\"].schema as JSONSchema7\n )\n\n if (!schema) {\n return exampleGroups\n }\n\n const fakeData = OpenAPISampler.sample(schema)\n\n // TODO: snippet languages options\n const {code} = oasToSnippet(oas, operation, {\n body: fakeData\n }, null, \"shell\");\n\n const examples: Example[] = []\n\n examples.push({\n codeblock: {\n tabs: [{\n title: \"curl\",\n language: \"curl\",\n code: code || \"\",\n }]\n }\n })\n\n exampleGroups.push({\n description: \"Example request\",\n examples\n })\n }\n\n if (operation.schema.responses) {\n const responses = operation.schema.responses as OpenAPIV3.ResponsesObject\n\n const examples: Example[] = []\n\n Object.entries(responses).forEach(([status, r]) => {\n const response = r as OpenAPIV3.ResponseObject\n const schema = response?.content?.[\"application/json\"].schema as JSONSchema7\n\n if (!schema) {\n return\n }\n\n const fakeData = OpenAPISampler.sample(schema)\n\n examples.push({\n codeblock: {\n title: status,\n tabs: [{\n title: \"json\",\n language: \"json\",\n code: JSON.stringify(fakeData, null, 2) || \"\",\n }]\n }\n })\n })\n\n exampleGroups.push({\n description: \"Response\",\n examples\n })\n }\n\n return exampleGroups\n}\n\n/*\nfixAllOfBug fixes below case:\n\n```yaml\n allOf:\n - $ref: '#/components/schemas/SomeSchema'\n - type: object\n required:\n properties:\n```\n*/\nfunction fixAllOfBug(schema: JSONSchema7) {\n const modifiedSchema = {...schema}\n\n if (schema.allOf) {\n schema.allOf.forEach((prop, i) => {\n const propObj = prop as object\n\n if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,IACJ,CAAC;AAAA,EACL;AAEA,SAAO;AACX;AAaA,SAAS,YAAY,QAAqB;AACtC,QAAM,iBAAiB,EAAC,GAAG,OAAM;AAEjC,MAAI,OAAO,OAAO;AACd,WAAO,MAAM,QAAQ,CAAC,MAAM,MAAM;AAzG1C;AA0GY,YAAM,UAAU;AAEhB,UAAI,gBAAgB,WAAW,CAAC,QAAQ,YAAY,GAAG;AACnD,cAAO,eAAe,UAAtB,wBAA8B;AAAA,MAClC;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO;AACX;;;AHtGO,SAAS,sBACZ,QACW;AACX,QAAM,aAA0B,CAAC;AACjC,QAAM,MAAM,IAAI,WAAAE,QAAI,MAAa;AAEjC,SAAO,QAAQ,OAAO,KAAK,EAAE,QAAQ,CAAC,CAACC,OAAM,OAAO,MAAM;AACtD,QAAI;AAEJ,2BAAuB,QAAQ,CAAC,eAAe;AAC3C,YAAM,aAAa,WAAW,YAAY;AAE1C,cAAQ,YAAY;AAAA,QAChB,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ;AACI,kBAAQ,MAAM,uBAAuB,UAAU,EAAE;AACjD;AAAA,MACR;AAEA,YAAM,YAAY;AAAA,QACd;AAAA,QACAA;AAAA,QACA;AAAA,MACJ;AAEA,UAAI,WAAW;AACX,cAAM,YAAY,IAAI,UAAUA,OAAM,UAAU;AAChD,kBAAU,SAAS,SAAS,YAAY,KAAK,SAAS;AAEtD,mBAAW,KAAK,SAAS;AAAA,MAC7B;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;","names":["import_uniform","path","fs","yaml","$refParser","path","OpenAPISampler","oasToSnippet","Oas","path"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import { Reference } from '@xyd-js/uniform';
|
|
3
|
+
|
|
4
|
+
declare function oapSchemaToReferences(schema: OpenAPIV3.Document): Reference[];
|
|
5
|
+
|
|
6
|
+
declare function deferencedOpenAPI(openApiPath: string): Promise<OpenAPIV3.Document<{}>>;
|
|
7
|
+
|
|
8
|
+
export { deferencedOpenAPI, oapSchemaToReferences };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import { Reference } from '@xyd-js/uniform';
|
|
3
|
+
|
|
4
|
+
declare function oapSchemaToReferences(schema: OpenAPIV3.Document): Reference[];
|
|
5
|
+
|
|
6
|
+
declare function deferencedOpenAPI(openApiPath: string): Promise<OpenAPIV3.Document<{}>>;
|
|
7
|
+
|
|
8
|
+
export { deferencedOpenAPI, oapSchemaToReferences };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// src/const.ts
|
|
2
|
+
var SUPPORTED_HTTP_METHODS = [
|
|
3
|
+
"get",
|
|
4
|
+
"put",
|
|
5
|
+
"patch",
|
|
6
|
+
"post",
|
|
7
|
+
"delete"
|
|
8
|
+
// 'options',
|
|
9
|
+
// 'head',
|
|
10
|
+
// 'trace'
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// src/parameters.ts
|
|
14
|
+
function oapParametersToDefinitionProperties(parameters) {
|
|
15
|
+
const parameterIn = {};
|
|
16
|
+
parameters.forEach((param) => {
|
|
17
|
+
if (!parameterIn[param.in]) {
|
|
18
|
+
parameterIn[param.in] = [];
|
|
19
|
+
}
|
|
20
|
+
const schema = param.schema;
|
|
21
|
+
const property = {
|
|
22
|
+
name: param.name,
|
|
23
|
+
type: schema.type || "",
|
|
24
|
+
description: param.description || ""
|
|
25
|
+
};
|
|
26
|
+
parameterIn[param.in].push(property);
|
|
27
|
+
});
|
|
28
|
+
return parameterIn;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/properties.ts
|
|
32
|
+
function schemaObjectToDefinitionProperties(v) {
|
|
33
|
+
return Object.entries(v.properties || {}).map(([name, prop]) => {
|
|
34
|
+
let objProp = prop;
|
|
35
|
+
let merged = [];
|
|
36
|
+
if (objProp.allOf) {
|
|
37
|
+
merged = objProp.allOf.reduce((acc, of) => {
|
|
38
|
+
return [
|
|
39
|
+
...acc,
|
|
40
|
+
...schemaObjectToDefinitionProperties(of)
|
|
41
|
+
];
|
|
42
|
+
}, []);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
name,
|
|
46
|
+
type: objProp.type || "",
|
|
47
|
+
description: objProp.description || "",
|
|
48
|
+
properties: (merged == null ? void 0 : merged.length) ? merged : objProp.properties ? schemaObjectToDefinitionProperties(objProp) : []
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/requestBody.ts
|
|
54
|
+
function oapRequestBodyToDefinitionProperties(reqBody) {
|
|
55
|
+
const schema = reqBody.content["application/json"].schema;
|
|
56
|
+
let schemaObject;
|
|
57
|
+
if (schema.allOf) {
|
|
58
|
+
return schema.allOf.reduce((acc, of) => {
|
|
59
|
+
const fakeBody = {
|
|
60
|
+
content: {
|
|
61
|
+
"application/json": {
|
|
62
|
+
schema: of
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return [
|
|
67
|
+
...acc,
|
|
68
|
+
...oapRequestBodyToDefinitionProperties(fakeBody) || []
|
|
69
|
+
];
|
|
70
|
+
}, []);
|
|
71
|
+
}
|
|
72
|
+
switch (schema.type) {
|
|
73
|
+
case "object": {
|
|
74
|
+
schemaObject = schema;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "array": {
|
|
78
|
+
const arrSchema = schema;
|
|
79
|
+
const items = arrSchema.items;
|
|
80
|
+
schemaObject = items;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
default:
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (!schemaObject) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return schemaObjectToDefinitionProperties(schemaObject);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/responses.ts
|
|
93
|
+
function oapResponseToDefinitionProperties(responses) {
|
|
94
|
+
var _a, _b, _c, _d;
|
|
95
|
+
let schemaObject;
|
|
96
|
+
if (responses["default"]) {
|
|
97
|
+
const w = responses["default"];
|
|
98
|
+
schemaObject = (_b = (_a = w == null ? void 0 : w.content) == null ? void 0 : _a["application/json"]) == null ? void 0 : _b.schema;
|
|
99
|
+
} else if (responses["200"]) {
|
|
100
|
+
const w = responses["200"];
|
|
101
|
+
schemaObject = (_d = (_c = w == null ? void 0 : w.content) == null ? void 0 : _c["application/json"]) == null ? void 0 : _d.schema;
|
|
102
|
+
}
|
|
103
|
+
if (!schemaObject) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
switch (schemaObject.type) {
|
|
107
|
+
case "array":
|
|
108
|
+
const arrSchema = schemaObject;
|
|
109
|
+
const items = arrSchema.items;
|
|
110
|
+
schemaObject = items;
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return schemaObjectToDefinitionProperties(schemaObject);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/schema.ts
|
|
119
|
+
import Oas from "oas";
|
|
120
|
+
|
|
121
|
+
// src/paths.ts
|
|
122
|
+
import { ReferenceCategory } from "@xyd-js/uniform";
|
|
123
|
+
|
|
124
|
+
// src/utils.ts
|
|
125
|
+
import path from "path";
|
|
126
|
+
import fs from "fs";
|
|
127
|
+
import yaml from "js-yaml";
|
|
128
|
+
import $refParser from "json-schema-ref-parser";
|
|
129
|
+
import { ReferenceType } from "@xyd-js/uniform";
|
|
130
|
+
function toPascalCase(str) {
|
|
131
|
+
return str.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
132
|
+
}
|
|
133
|
+
function readOpenApiSpec(filePath) {
|
|
134
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
135
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
136
|
+
if (ext === ".yaml" || ext === ".yml") {
|
|
137
|
+
return yaml.load(content);
|
|
138
|
+
} else if (ext === ".json") {
|
|
139
|
+
return JSON.parse(content);
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error("Unsupported file format. Use JSON or YAML.");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function deferencedOpenAPI(openApiPath) {
|
|
145
|
+
const openApiSpec = readOpenApiSpec(openApiPath);
|
|
146
|
+
await $refParser.dereference(openApiSpec);
|
|
147
|
+
return openApiSpec;
|
|
148
|
+
}
|
|
149
|
+
function httpMethodToUniformMethod(method) {
|
|
150
|
+
switch (method) {
|
|
151
|
+
case "get":
|
|
152
|
+
return ReferenceType.REST_HTTP_GET;
|
|
153
|
+
case "put":
|
|
154
|
+
return ReferenceType.REST_HTTP_PUT;
|
|
155
|
+
case "patch":
|
|
156
|
+
return ReferenceType.REST_HTTP_PATCH;
|
|
157
|
+
case "post":
|
|
158
|
+
return ReferenceType.REST_HTTP_POST;
|
|
159
|
+
case "delete":
|
|
160
|
+
return ReferenceType.REST_HTTP_DELETE;
|
|
161
|
+
// case 'options':
|
|
162
|
+
// return ReferenceType.REST_HTTP_OPTIONS
|
|
163
|
+
// case 'head':
|
|
164
|
+
// return ReferenceType.REST_HTTP_HEAD
|
|
165
|
+
// case 'trace':
|
|
166
|
+
// return ReferenceType.REST_HTTP_TRACE
|
|
167
|
+
default:
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/paths.ts
|
|
173
|
+
function oapPathToReference(httpMethod, path2, oapPath) {
|
|
174
|
+
const mType = httpMethodToUniformMethod(httpMethod);
|
|
175
|
+
if (!mType) {
|
|
176
|
+
console.error(`Unsupported method: ${httpMethod}`);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
const definitions = [];
|
|
180
|
+
const exampleGroups = [];
|
|
181
|
+
const oapMethod = oapPath == null ? void 0 : oapPath[httpMethod];
|
|
182
|
+
if (!oapMethod) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const endpointRef = {
|
|
186
|
+
title: (oapMethod == null ? void 0 : oapMethod.summary) || "",
|
|
187
|
+
canonical: toPascalCase((oapMethod == null ? void 0 : oapMethod.summary) || ""),
|
|
188
|
+
description: (oapMethod == null ? void 0 : oapMethod.description) || "",
|
|
189
|
+
category: ReferenceCategory.REST,
|
|
190
|
+
type: mType,
|
|
191
|
+
context: {
|
|
192
|
+
method: httpMethod,
|
|
193
|
+
path: path2
|
|
194
|
+
},
|
|
195
|
+
examples: {
|
|
196
|
+
groups: exampleGroups
|
|
197
|
+
},
|
|
198
|
+
definitions
|
|
199
|
+
};
|
|
200
|
+
if (oapMethod.parameters) {
|
|
201
|
+
const parameters = oapMethod.parameters;
|
|
202
|
+
const paramtersMap = oapParametersToDefinitionProperties(parameters);
|
|
203
|
+
Object.entries(paramtersMap).forEach(([key, definitionProperties]) => {
|
|
204
|
+
let title;
|
|
205
|
+
switch (key) {
|
|
206
|
+
case "path":
|
|
207
|
+
title = "Paths";
|
|
208
|
+
break;
|
|
209
|
+
case "query":
|
|
210
|
+
title = "Query";
|
|
211
|
+
break;
|
|
212
|
+
case "header":
|
|
213
|
+
title = "Header";
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
console.error(`Unsupported parameter type: ${key} for ${httpMethod} ${path2}`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
definitions.push({
|
|
220
|
+
title,
|
|
221
|
+
properties: definitionProperties
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (oapMethod.requestBody) {
|
|
226
|
+
const reqBody = oapMethod.requestBody;
|
|
227
|
+
definitions.push({
|
|
228
|
+
title: "Request body",
|
|
229
|
+
properties: oapRequestBodyToDefinitionProperties(reqBody) || []
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (oapMethod.responses) {
|
|
233
|
+
const responses = oapMethod.responses;
|
|
234
|
+
definitions.push({
|
|
235
|
+
title: "Response",
|
|
236
|
+
properties: oapResponseToDefinitionProperties(responses) || []
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return endpointRef;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/examples.ts
|
|
243
|
+
import oasToSnippet from "@readme/oas-to-snippet";
|
|
244
|
+
import OpenAPISampler from "openapi-sampler";
|
|
245
|
+
function oapExamples(oas, operation) {
|
|
246
|
+
const exampleGroups = [];
|
|
247
|
+
if (operation.schema.requestBody) {
|
|
248
|
+
const body = operation.schema.requestBody;
|
|
249
|
+
const schema = fixAllOfBug(
|
|
250
|
+
body.content["application/json"].schema
|
|
251
|
+
);
|
|
252
|
+
if (!schema) {
|
|
253
|
+
return exampleGroups;
|
|
254
|
+
}
|
|
255
|
+
const fakeData = OpenAPISampler.sample(schema);
|
|
256
|
+
const { code } = oasToSnippet(oas, operation, {
|
|
257
|
+
body: fakeData
|
|
258
|
+
}, null, "shell");
|
|
259
|
+
const examples = [];
|
|
260
|
+
examples.push({
|
|
261
|
+
codeblock: {
|
|
262
|
+
tabs: [{
|
|
263
|
+
title: "curl",
|
|
264
|
+
language: "curl",
|
|
265
|
+
code: code || ""
|
|
266
|
+
}]
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
exampleGroups.push({
|
|
270
|
+
description: "Example request",
|
|
271
|
+
examples
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (operation.schema.responses) {
|
|
275
|
+
const responses = operation.schema.responses;
|
|
276
|
+
const examples = [];
|
|
277
|
+
Object.entries(responses).forEach(([status, r]) => {
|
|
278
|
+
var _a;
|
|
279
|
+
const response = r;
|
|
280
|
+
const schema = (_a = response == null ? void 0 : response.content) == null ? void 0 : _a["application/json"].schema;
|
|
281
|
+
if (!schema) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const fakeData = OpenAPISampler.sample(schema);
|
|
285
|
+
examples.push({
|
|
286
|
+
codeblock: {
|
|
287
|
+
title: status,
|
|
288
|
+
tabs: [{
|
|
289
|
+
title: "json",
|
|
290
|
+
language: "json",
|
|
291
|
+
code: JSON.stringify(fakeData, null, 2) || ""
|
|
292
|
+
}]
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
exampleGroups.push({
|
|
297
|
+
description: "Response",
|
|
298
|
+
examples
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return exampleGroups;
|
|
302
|
+
}
|
|
303
|
+
function fixAllOfBug(schema) {
|
|
304
|
+
const modifiedSchema = { ...schema };
|
|
305
|
+
if (schema.allOf) {
|
|
306
|
+
schema.allOf.forEach((prop, i) => {
|
|
307
|
+
var _a;
|
|
308
|
+
const propObj = prop;
|
|
309
|
+
if ("properties" in propObj && !propObj["properties"]) {
|
|
310
|
+
(_a = modifiedSchema.allOf) == null ? true : delete _a[i];
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return modifiedSchema;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/schema.ts
|
|
318
|
+
function oapSchemaToReferences(schema) {
|
|
319
|
+
const references = [];
|
|
320
|
+
const oas = new Oas(schema);
|
|
321
|
+
Object.entries(schema.paths).forEach(([path2, oapPath]) => {
|
|
322
|
+
let type;
|
|
323
|
+
SUPPORTED_HTTP_METHODS.forEach((eachMethod) => {
|
|
324
|
+
const httpMethod = eachMethod.toLowerCase();
|
|
325
|
+
switch (httpMethod) {
|
|
326
|
+
case "get":
|
|
327
|
+
break;
|
|
328
|
+
case "put":
|
|
329
|
+
break;
|
|
330
|
+
case "post":
|
|
331
|
+
break;
|
|
332
|
+
case "delete":
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
console.error(`Unsupported method: ${httpMethod}`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const reference = oapPathToReference(
|
|
339
|
+
httpMethod,
|
|
340
|
+
path2,
|
|
341
|
+
oapPath
|
|
342
|
+
);
|
|
343
|
+
if (reference) {
|
|
344
|
+
const operation = oas.operation(path2, httpMethod);
|
|
345
|
+
reference.examples.groups = oapExamples(oas, operation);
|
|
346
|
+
references.push(reference);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
return references;
|
|
351
|
+
}
|
|
352
|
+
export {
|
|
353
|
+
deferencedOpenAPI,
|
|
354
|
+
oapSchemaToReferences
|
|
355
|
+
};
|
|
356
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/const.ts","../src/parameters.ts","../src/properties.ts","../src/requestBody.ts","../src/responses.ts","../src/schema.ts","../src/paths.ts","../src/utils.ts","../src/examples.ts"],"sourcesContent":["export const SUPPORTED_HTTP_METHODS: string[] = [\n 'get',\n 'put',\n 'patch',\n 'post',\n 'delete',\n // 'options',\n // 'head',\n // 'trace'\n];","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\n// oapParametersToDefinitionProperties converts OpenAPI parameters to uniform DefinitionProperties\nexport function oapParametersToDefinitionProperties(\n parameters: OpenAPIV3.ParameterObject[]\n): { [key: string]: DefinitionProperty[] } {\n const parameterIn: { [key: string]: DefinitionProperty[] } = {}\n\n parameters.forEach((param) => {\n if (!parameterIn[param.in]) {\n parameterIn[param.in] = []\n }\n\n const schema = param.schema as OpenAPIV3.SchemaObject\n\n const property: DefinitionProperty = {\n name: param.name,\n type: schema.type || \"\",\n description: param.description || \"\"\n }\n\n parameterIn[param.in].push(property)\n })\n\n return parameterIn\n}\n","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\n// schemaObjectToDefinitionProperties converts OpenAPI schema object to uniform DefinitionProperty[]\nexport function schemaObjectToDefinitionProperties(v: OpenAPIV3.SchemaObject): DefinitionProperty[] {\n return Object.entries(v.properties || {}).map(([name, prop]) => {\n let objProp = prop as OpenAPIV3.SchemaObject\n\n let merged: DefinitionProperty[] = []\n\n if (objProp.allOf) {\n merged = objProp.allOf.reduce((acc, of) => {\n return [\n ...acc,\n ...schemaObjectToDefinitionProperties(of as OpenAPIV3.SchemaObject)\n ]\n }, [] as DefinitionProperty[])\n }\n\n return {\n name: name,\n type: objProp.type || \"\",\n description: objProp.description || \"\",\n properties: (\n merged?.length\n ? merged\n : objProp.properties ? schemaObjectToDefinitionProperties(objProp) : []\n )\n }\n })\n}","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\nimport {schemaObjectToDefinitionProperties} from \"./properties\";\n\n// oapRequestBodyToDefinitionProperties converts OpenAPI request body to uniform DefinitionProperties\nexport function oapRequestBodyToDefinitionProperties(\n reqBody: OpenAPIV3.RequestBodyObject\n): DefinitionProperty[] | null {\n // TODO: support other content types ???\n const schema = reqBody.content['application/json'].schema as OpenAPIV3.SchemaObject\n\n let schemaObject: OpenAPIV3.SchemaObject | undefined\n\n if (schema.allOf) {\n return schema.allOf.reduce((acc, of) => {\n const fakeBody: OpenAPIV3.RequestBodyObject = {\n content: {\n 'application/json': {\n schema: of\n }\n }\n }\n\n return [\n ...acc,\n ...oapRequestBodyToDefinitionProperties(fakeBody) || []\n ]\n }, [] as DefinitionProperty[])\n }\n\n switch (schema.type) {\n case 'object': {\n schemaObject = schema\n break\n }\n case 'array': {\n const arrSchema = schema as OpenAPIV3.ArraySchemaObject\n\n const items = arrSchema.items as OpenAPIV3.SchemaObject\n\n schemaObject = items\n break\n }\n default:\n // TODO: primitive types ???\n break\n }\n\n if (!schemaObject) {\n return null\n }\n\n return schemaObjectToDefinitionProperties(schemaObject)\n}","import {OpenAPIV3} from \"openapi-types\";\nimport {DefinitionProperty} from \"@xyd-js/uniform\";\n\nimport {schemaObjectToDefinitionProperties} from \"./properties\";\n\nexport function oapResponseToDefinitionProperties(\n responses: OpenAPIV3.ResponsesObject\n): DefinitionProperty[] | null {\n let schemaObject: OpenAPIV3.SchemaObject | undefined\n // TODO: support another statuses\n if (responses[\"default\"]) {\n const w = responses[\"default\"] as OpenAPIV3.ResponseObject\n\n schemaObject = w?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject\n } else if (responses[\"200\"]) {\n const w = responses[\"200\"] as OpenAPIV3.ResponseObject\n\n schemaObject = w?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject\n }\n\n if (!schemaObject) {\n return null\n }\n\n switch (schemaObject.type) {\n case 'array':\n const arrSchema = schemaObject as OpenAPIV3.ArraySchemaObject\n\n const items = arrSchema.items as OpenAPIV3.SchemaObject\n\n schemaObject = items\n break\n default:\n break\n }\n\n return schemaObjectToDefinitionProperties(schemaObject)\n}","import {OpenAPIV3} from \"openapi-types\";\nimport Oas from \"oas\";\nimport {Reference, ReferenceType} from \"@xyd-js/uniform\";\n\nimport {SUPPORTED_HTTP_METHODS} from \"./const\";\nimport {oapPathToReference} from \"./paths\";\nimport {oapExamples} from \"./examples\";\n\n// TODO: support one-of\n// TODO: support $ref - currently we use $refParser.dereference that converts $ref into objects\n// TODO: better method check system - currently we need to manually check that in few methods\n\n// oapSchemaToReferences converts an OpenAPI schema to a list of uniform References\nexport function oapSchemaToReferences(\n schema: OpenAPIV3.Document\n): Reference[] {\n const references: Reference[] = [];\n const oas = new Oas(schema as any);\n\n Object.entries(schema.paths).forEach(([path, oapPath]) => {\n let type: ReferenceType;\n\n SUPPORTED_HTTP_METHODS.forEach((eachMethod) => {\n const httpMethod = eachMethod.toLowerCase()\n\n switch (httpMethod) {\n case 'get':\n break\n case 'put':\n break\n case 'post':\n break\n case 'delete':\n break\n default:\n console.error(`Unsupported method: ${httpMethod}`)\n return\n }\n\n const reference = oapPathToReference(\n httpMethod,\n path,\n oapPath as OpenAPIV3.PathItemObject\n )\n\n if (reference) {\n const operation = oas.operation(path, httpMethod);\n reference.examples.groups = oapExamples(oas, operation)\n\n references.push(reference)\n }\n })\n })\n\n return references\n}\n","import {OpenAPIV3} from \"openapi-types\";\nimport {Definition, ExampleGroup, Reference, ReferenceCategory} from \"@xyd-js/uniform\";\n\nimport {oapParametersToDefinitionProperties} from \"./parameters\";\nimport {oapRequestBodyToDefinitionProperties} from \"./requestBody\";\nimport {oapResponseToDefinitionProperties} from \"./responses\";\nimport {\n httpMethodToUniformMethod,\n toPascalCase\n} from \"./utils\";\n\n// oapPathToReference converts an OpenAPI path to a uniform Reference\nexport function oapPathToReference(\n httpMethod: \"get\" | \"put\" | \"post\" | \"delete\", // TODO: ts type\n path: string,\n oapPath: OpenAPIV3.PathItemObject,\n): Reference | null {\n const mType = httpMethodToUniformMethod(httpMethod)\n\n if (!mType) {\n console.error(`Unsupported method: ${httpMethod}`)\n return null\n }\n\n const definitions: Definition[] = []\n const exampleGroups: ExampleGroup[] = []\n\n const oapMethod = oapPath?.[httpMethod] as OpenAPIV3.OperationObject\n\n if (!oapMethod) {\n return null\n }\n\n const endpointRef: Reference = {\n title: oapMethod?.summary || \"\",\n canonical: toPascalCase(oapMethod?.summary || \"\"),\n description: oapMethod?.description || \"\",\n\n category: ReferenceCategory.REST,\n type: mType,\n\n context: {\n method: httpMethod,\n\n path\n },\n\n examples: {\n groups: exampleGroups,\n },\n definitions: definitions,\n }\n\n if (oapMethod.parameters) {\n const parameters = oapMethod.parameters as OpenAPIV3.ParameterObject[]\n\n const paramtersMap = oapParametersToDefinitionProperties(parameters) // TODO: finish\n\n Object.entries(paramtersMap).forEach(([key, definitionProperties]) => {\n let title: string\n\n // TODO: add context to definition\n switch (key) {\n case 'path':\n title = \"Paths\"\n break\n case 'query':\n title = \"Query\"\n break\n case 'header':\n title = \"Header\"\n break\n default:\n console.error(`Unsupported parameter type: ${key} for ${httpMethod} ${path}`)\n return\n }\n\n definitions.push({\n title,\n properties: definitionProperties\n })\n })\n }\n\n if (oapMethod.requestBody) {\n const reqBody = oapMethod.requestBody as OpenAPIV3.RequestBodyObject\n\n definitions.push({\n title: 'Request body',\n properties: oapRequestBodyToDefinitionProperties(reqBody) || []\n })\n }\n\n if (oapMethod.responses) {\n const responses = oapMethod.responses as OpenAPIV3.ResponsesObject\n\n definitions.push({\n title: 'Response',\n properties: oapResponseToDefinitionProperties(responses) || []\n })\n }\n\n return endpointRef\n}\n","import path from \"path\";\nimport fs from \"fs\";\nimport yaml from \"js-yaml\";\nimport $refParser from \"json-schema-ref-parser\";\nimport {OpenAPIV3} from \"openapi-types\";\n\nimport {ReferenceType} from \"@xyd-js/uniform\";\n\ntype Parameters = {\n query?: Record<string, string | number | boolean>;\n headers?: Record<string, string>;\n};\n\nexport function toPascalCase(str: string): string {\n return str\n .split(/[\\s_-]+/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('');\n}\n\n// readOpenApiSpec reads an OpenAPI spec file and returns the content\nfunction readOpenApiSpec(filePath: string) {\n const ext = path.extname(filePath).toLowerCase();\n const content = fs.readFileSync(filePath, 'utf-8');\n\n if (ext === '.yaml' || ext === '.yml') {\n return yaml.load(content);\n } else if (ext === '.json') {\n return JSON.parse(content);\n } else {\n throw new Error('Unsupported file format. Use JSON or YAML.');\n }\n}\n\n// deferencedOpenAPI reads an OpenAPI spec file and returns a dereferenced OpenAPIV3.Document\n// dereferenced means that all $ref references are resolved automatically\nexport async function deferencedOpenAPI(openApiPath: string) {\n const openApiSpec = readOpenApiSpec(openApiPath);\n\n //@ts-ignore TODO: fix ts\n await $refParser.dereference(openApiSpec);\n\n return openApiSpec as OpenAPIV3.Document\n}\n\n// httpMethodToUniformMethod converts an HTTP method to a uniform ReferenceType\nexport function httpMethodToUniformMethod(method: string): ReferenceType | null {\n switch (method) {\n case 'get':\n return ReferenceType.REST_HTTP_GET\n case 'put':\n return ReferenceType.REST_HTTP_PUT\n case 'patch':\n return ReferenceType.REST_HTTP_PATCH\n case 'post':\n return ReferenceType.REST_HTTP_POST\n case 'delete':\n return ReferenceType.REST_HTTP_DELETE\n // case 'options':\n // return ReferenceType.REST_HTTP_OPTIONS\n // case 'head':\n // return ReferenceType.REST_HTTP_HEAD\n // case 'trace':\n // return ReferenceType.REST_HTTP_TRACE\n default:\n return null\n }\n}\n\n// schemaToRequestBody generates a request body from an OpenAPI schema\nfunction schemaToRequestBody(schema: OpenAPIV3.SchemaObject): string {\n const requestBody: any = {};\n\n if (schema.type === 'object' && schema.properties) {\n for (const [key, value] of Object.entries(schema.properties)) {\n if ((value as OpenAPIV3.SchemaObject).default !== undefined) {\n requestBody[key] = (value as OpenAPIV3.SchemaObject).default;\n } else {\n requestBody[key] = null; // or some placeholder value\n }\n }\n }\n\n return JSON.stringify(requestBody);\n}\n\n// generateRequestInitFromOpenAPIObject generates a RequestInit object from an OpenAPI object\nexport function generateRequestInitFromOapOperation(\n urlPath: string,\n operation: OpenAPIV3.OperationObject\n): { url: string, reqInit: RequestInit } {\n const reqInit: RequestInit = {}\n let queryParams = '';\n\n if (operation.parameters) {\n const parameters = operation.parameters as OpenAPIV3.ParameterObject[]\n\n const params = new URLSearchParams(\n Object.entries(parameters).map(([key, value]) => [key, String(value)])\n ).toString();\n\n queryParams += `?${params}`;\n }\n\n if (operation.requestBody) {\n const reqBody = operation.requestBody as OpenAPIV3.RequestBodyObject;\n const contentType = Object.keys(reqBody.content || {})[0];\n\n if (contentType === \"application/json\") {\n const schema = reqBody.content['application/json'].schema as OpenAPIV3.SchemaObject\n\n reqInit.body = schemaToRequestBody(schema);\n reqInit.headers = {\n 'Content-Type': 'application/json',\n }\n }\n }\n\n return {\n url: `${urlPath}${queryParams}`,\n reqInit,\n };\n}\n\n","import {OpenAPIV3} from \"openapi-types\";\nimport Oas from \"oas\";\n// @ts-ignore\nimport {Operation} from 'oas/operation'; // TODO: fix ts\nimport oasToSnippet from \"@readme/oas-to-snippet\";\nimport OpenAPISampler from \"openapi-sampler\";\nimport type {JSONSchema7} from \"json-schema\";\n\nimport {ExampleGroup, Example} from \"@xyd-js/uniform\";\n\n// TODO: option with another languages\n// TODO: uniform plugins\n// TODO: fs uniform plugins\nexport function oapExamples(\n oas: Oas,\n operation: Operation\n): ExampleGroup[] {\n const exampleGroups: ExampleGroup[] = []\n\n if (operation.schema.requestBody) {\n const body = operation.schema.requestBody as OpenAPIV3.RequestBodyObject\n const schema = fixAllOfBug(\n body.content[\"application/json\"].schema as JSONSchema7\n )\n\n if (!schema) {\n return exampleGroups\n }\n\n const fakeData = OpenAPISampler.sample(schema)\n\n // TODO: snippet languages options\n const {code} = oasToSnippet(oas, operation, {\n body: fakeData\n }, null, \"shell\");\n\n const examples: Example[] = []\n\n examples.push({\n codeblock: {\n tabs: [{\n title: \"curl\",\n language: \"curl\",\n code: code || \"\",\n }]\n }\n })\n\n exampleGroups.push({\n description: \"Example request\",\n examples\n })\n }\n\n if (operation.schema.responses) {\n const responses = operation.schema.responses as OpenAPIV3.ResponsesObject\n\n const examples: Example[] = []\n\n Object.entries(responses).forEach(([status, r]) => {\n const response = r as OpenAPIV3.ResponseObject\n const schema = response?.content?.[\"application/json\"].schema as JSONSchema7\n\n if (!schema) {\n return\n }\n\n const fakeData = OpenAPISampler.sample(schema)\n\n examples.push({\n codeblock: {\n title: status,\n tabs: [{\n title: \"json\",\n language: \"json\",\n code: JSON.stringify(fakeData, null, 2) || \"\",\n }]\n }\n })\n })\n\n exampleGroups.push({\n description: \"Response\",\n examples\n })\n }\n\n return exampleGroups\n}\n\n/*\nfixAllOfBug fixes below case:\n\n```yaml\n allOf:\n - $ref: '#/components/schemas/SomeSchema'\n - type: object\n required:\n properties:\n```\n*/\nfunction fixAllOfBug(schema: JSONSchema7) {\n const modifiedSchema = {...schema}\n\n if (schema.allOf) {\n schema.allOf.forEach((prop, i) => {\n const propObj = prop as object\n\n if (\"properties\" in propObj && !propObj[\"properties\"]) {\n delete modifiedSchema.allOf?.[i]\n }\n })\n }\n\n return modifiedSchema\n}"],"mappings":";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,YAAM,UAAU;AAEhB,UAAI,gBAAgB,WAAW,CAAC,QAAQ,YAAY,GAAG;AACnD,cAAO,eAAe,UAAtB,wBAA8B;AAAA,MAClC;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO;AACX;;;AHtGO,SAAS,sBACZ,QACW;AACX,QAAM,aAA0B,CAAC;AACjC,QAAM,MAAM,IAAI,IAAI,MAAa;AAEjC,SAAO,QAAQ,OAAO,KAAK,EAAE,QAAQ,CAAC,CAACC,OAAM,OAAO,MAAM;AACtD,QAAI;AAEJ,2BAAuB,QAAQ,CAAC,eAAe;AAC3C,YAAM,aAAa,WAAW,YAAY;AAE1C,cAAQ,YAAY;AAAA,QAChB,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ,KAAK;AACD;AAAA,QACJ;AACI,kBAAQ,MAAM,uBAAuB,UAAU,EAAE;AACjD;AAAA,MACR;AAEA,YAAM,YAAY;AAAA,QACd;AAAA,QACAA;AAAA,QACA;AAAA,MACJ;AAEA,UAAI,WAAW;AACX,cAAM,YAAY,IAAI,UAAUA,OAAM,UAAU;AAChD,kBAAU,SAAS,SAAS,YAAY,KAAK,SAAS;AAEtD,mBAAW,KAAK,SAAS;AAAA,MAC7B;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;","names":["path","path"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/openapi",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"oas": "^25.0.3",
|
|
12
12
|
"openapi-sampler": "^1.5.1",
|
|
13
13
|
"openapi-types": "^12.1.3",
|
|
14
|
-
"@xyd-js/uniform": "0.1.0-xyd.
|
|
14
|
+
"@xyd-js/uniform": "0.1.0-xyd.3"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/js-yaml": "^4.0.9",
|