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.cjs
CHANGED
|
@@ -291,7 +291,7 @@ var ApiRenderer = class _ApiRenderer {
|
|
|
291
291
|
}, options);
|
|
292
292
|
this.container = null;
|
|
293
293
|
}
|
|
294
|
-
render(apiSpec, renderUnit = false) {
|
|
294
|
+
render(apiSpec, currentServer, serviceName, renderUnit = false) {
|
|
295
295
|
const appendInlineStyle = (text) => {
|
|
296
296
|
if (!_ApiRenderer.globalStyleInjected) {
|
|
297
297
|
const styleEl = document.createElement("style");
|
|
@@ -308,7 +308,7 @@ var ApiRenderer = class _ApiRenderer {
|
|
|
308
308
|
}
|
|
309
309
|
if (apiSpec["openapi"] && apiSpec["openapi"].startsWith("3.") || apiSpec["swagger"] && apiSpec["swagger"].startsWith("2.")) {
|
|
310
310
|
const countApi = countOpenAPI(apiSpec);
|
|
311
|
-
const apiOperatorList =
|
|
311
|
+
const apiOperatorList = parseOpenApiSpec(apiSpec, currentServer, serviceName);
|
|
312
312
|
if (countApi == 1 && renderUnit) {
|
|
313
313
|
this.container = createApiUnit(apiOperatorList[0]);
|
|
314
314
|
} else {
|
|
@@ -1367,7 +1367,7 @@ var HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch",
|
|
|
1367
1367
|
function isHttpMethod(method) {
|
|
1368
1368
|
return HTTP_METHODS.includes(method);
|
|
1369
1369
|
}
|
|
1370
|
-
function
|
|
1370
|
+
function parseOpenApiSpec(openapiSpec, currentServer, serviceName) {
|
|
1371
1371
|
const apiOperatorList = [];
|
|
1372
1372
|
const pathEntries = [];
|
|
1373
1373
|
for (const path in openapiSpec.paths) {
|
|
@@ -1388,9 +1388,15 @@ function parseOpenAPI(openapiSpec) {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
1390
|
pathItemEntries.forEach(([method, operation]) => {
|
|
1391
|
+
let url = path;
|
|
1392
|
+
if (currentServer) {
|
|
1393
|
+
url = currentServer.value + "/api/" + serviceName + "/v1" + path;
|
|
1394
|
+
} else if (openapiSpec.servers && openapiSpec.servers.length > 0) {
|
|
1395
|
+
url = openapiSpec.servers[0].url + path;
|
|
1396
|
+
}
|
|
1391
1397
|
const apiOperator = {
|
|
1392
1398
|
method: method.toUpperCase(),
|
|
1393
|
-
url
|
|
1399
|
+
url,
|
|
1394
1400
|
rawApiInfo: operation,
|
|
1395
1401
|
requestBody: null,
|
|
1396
1402
|
response: {},
|