api-render-ui 1.1.2 → 1.1.3
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 +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api-render-ui.ts +11 -4
package/dist/index.js
CHANGED
|
@@ -265,7 +265,7 @@ var ApiRenderer = class _ApiRenderer {
|
|
|
265
265
|
}, options);
|
|
266
266
|
this.container = null;
|
|
267
267
|
}
|
|
268
|
-
render(apiSpec, renderUnit = false) {
|
|
268
|
+
render(apiSpec, currentServer, serviceName, renderUnit = false) {
|
|
269
269
|
const appendInlineStyle = (text) => {
|
|
270
270
|
if (!_ApiRenderer.globalStyleInjected) {
|
|
271
271
|
const styleEl = document.createElement("style");
|
|
@@ -282,7 +282,7 @@ var ApiRenderer = class _ApiRenderer {
|
|
|
282
282
|
}
|
|
283
283
|
if (apiSpec["openapi"] && apiSpec["openapi"].startsWith("3.") || apiSpec["swagger"] && apiSpec["swagger"].startsWith("2.")) {
|
|
284
284
|
const countApi = countOpenAPI(apiSpec);
|
|
285
|
-
const apiOperatorList =
|
|
285
|
+
const apiOperatorList = parseOpenApiSpec(apiSpec, currentServer, serviceName);
|
|
286
286
|
if (countApi == 1 && renderUnit) {
|
|
287
287
|
this.container = createApiUnit(apiOperatorList[0]);
|
|
288
288
|
} else {
|
|
@@ -1341,7 +1341,7 @@ var HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch",
|
|
|
1341
1341
|
function isHttpMethod(method) {
|
|
1342
1342
|
return HTTP_METHODS.includes(method);
|
|
1343
1343
|
}
|
|
1344
|
-
function
|
|
1344
|
+
function parseOpenApiSpec(openapiSpec, currentServer, serviceName) {
|
|
1345
1345
|
const apiOperatorList = [];
|
|
1346
1346
|
const pathEntries = [];
|
|
1347
1347
|
for (const path in openapiSpec.paths) {
|
|
@@ -1362,9 +1362,15 @@ function parseOpenAPI(openapiSpec) {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
1364
|
pathItemEntries.forEach(([method, operation]) => {
|
|
1365
|
+
let url = path;
|
|
1366
|
+
if (currentServer) {
|
|
1367
|
+
url = currentServer.value + "/api/" + serviceName + "/v1" + path;
|
|
1368
|
+
} else if (openapiSpec.servers && openapiSpec.servers.length > 0) {
|
|
1369
|
+
url = openapiSpec.servers[0].url + path;
|
|
1370
|
+
}
|
|
1365
1371
|
const apiOperator = {
|
|
1366
1372
|
method: method.toUpperCase(),
|
|
1367
|
-
url
|
|
1373
|
+
url,
|
|
1368
1374
|
rawApiInfo: operation,
|
|
1369
1375
|
requestBody: null,
|
|
1370
1376
|
response: {},
|