@superdurable/connector-apifox 0.1.0 → 0.1.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/dex-connector.json +1 -1
- package/dist/index.js +7 -4
- package/package.json +1 -1
package/dex-connector.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -150,12 +150,15 @@ function classifyHTTPStatus(status) {
|
|
|
150
150
|
return branch("providerRejected", kind, `Apifox rejected project export with HTTP ${status}`);
|
|
151
151
|
}
|
|
152
152
|
function decodeProjectSummary(value, token) {
|
|
153
|
-
if (!isRecord(value)
|
|
154
|
-
const
|
|
155
|
-
|
|
153
|
+
if (!isRecord(value)) return void 0;
|
|
154
|
+
const document = Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
|
|
155
|
+
if (typeof document.openapi !== "string" || !document.openapi.startsWith("3.1") || !isRecord(document.info) || !isRecord(document.paths)) return void 0;
|
|
156
|
+
const info = Object.fromEntries(Object.entries(document.info).map(([key, field]) => [key.toLowerCase(), field]));
|
|
157
|
+
const title = info.title;
|
|
158
|
+
const version = info.version;
|
|
156
159
|
if (typeof title !== "string" || typeof version !== "string" || !title || !version || Buffer.byteLength(title, "utf8") > 256 || Buffer.byteLength(version, "utf8") > 64 || /[\r\n\0]/.test(title + version) || (title + version).includes(token)) return void 0;
|
|
157
160
|
let endpointCount = 0;
|
|
158
|
-
for (const methods of Object.values(
|
|
161
|
+
for (const methods of Object.values(document.paths)) {
|
|
159
162
|
if (methods !== null && !isRecord(methods)) return void 0;
|
|
160
163
|
if (methods === null) continue;
|
|
161
164
|
for (const method of Object.keys(methods)) if (httpMethods.has(method.toLowerCase())) endpointCount++;
|