@bagelink/sdk 1.6.57 → 1.6.61
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 +8 -1
- package/dist/index.mjs +8 -1
- package/package.json +1 -1
- package/src/openAPITools/index.ts +11 -1
package/dist/index.cjs
CHANGED
|
@@ -700,6 +700,7 @@ function generateTypes(schemas) {
|
|
|
700
700
|
const basicAuthHeader = { Authorization: "Basic YmFnZWxfdXNlcm5hbWU6Tm90U2VjdXJlQGJhZ2Vs" };
|
|
701
701
|
const index = async (openApiUrl, baseUrl) => {
|
|
702
702
|
try {
|
|
703
|
+
console.log(`Fetching OpenAPI spec from: ${openApiUrl}`);
|
|
703
704
|
const { data: openApi } = await axios__default.get(openApiUrl, { headers: basicAuthHeader });
|
|
704
705
|
const schemas = openApi.components?.schemas;
|
|
705
706
|
if (!schemas) {
|
|
@@ -713,7 +714,13 @@ const index = async (openApiUrl, baseUrl) => {
|
|
|
713
714
|
const code = generateFunctions(paths, baseUrl);
|
|
714
715
|
return { types, code };
|
|
715
716
|
} catch (error) {
|
|
716
|
-
|
|
717
|
+
if (error.response) {
|
|
718
|
+
throw new Error(`HTTP ${error.response.status}: ${error.response.statusText} - Failed to fetch OpenAPI spec from ${openApiUrl}`);
|
|
719
|
+
} else if (error.request) {
|
|
720
|
+
throw new Error(`Unable to connect to ${openApiUrl}. Is the server running and accessible?`);
|
|
721
|
+
} else {
|
|
722
|
+
throw new Error(`Error fetching OpenAPI spec: ${error.message}`);
|
|
723
|
+
}
|
|
717
724
|
}
|
|
718
725
|
};
|
|
719
726
|
|
package/dist/index.mjs
CHANGED
|
@@ -694,6 +694,7 @@ function generateTypes(schemas) {
|
|
|
694
694
|
const basicAuthHeader = { Authorization: "Basic YmFnZWxfdXNlcm5hbWU6Tm90U2VjdXJlQGJhZ2Vs" };
|
|
695
695
|
const index = async (openApiUrl, baseUrl) => {
|
|
696
696
|
try {
|
|
697
|
+
console.log(`Fetching OpenAPI spec from: ${openApiUrl}`);
|
|
697
698
|
const { data: openApi } = await axios$1.get(openApiUrl, { headers: basicAuthHeader });
|
|
698
699
|
const schemas = openApi.components?.schemas;
|
|
699
700
|
if (!schemas) {
|
|
@@ -707,7 +708,13 @@ const index = async (openApiUrl, baseUrl) => {
|
|
|
707
708
|
const code = generateFunctions(paths, baseUrl);
|
|
708
709
|
return { types, code };
|
|
709
710
|
} catch (error) {
|
|
710
|
-
|
|
711
|
+
if (error.response) {
|
|
712
|
+
throw new Error(`HTTP ${error.response.status}: ${error.response.statusText} - Failed to fetch OpenAPI spec from ${openApiUrl}`);
|
|
713
|
+
} else if (error.request) {
|
|
714
|
+
throw new Error(`Unable to connect to ${openApiUrl}. Is the server running and accessible?`);
|
|
715
|
+
} else {
|
|
716
|
+
throw new Error(`Error fetching OpenAPI spec: ${error.message}`);
|
|
717
|
+
}
|
|
711
718
|
}
|
|
712
719
|
};
|
|
713
720
|
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ const basicAuthHeader = { Authorization: 'Basic YmFnZWxfdXNlcm5hbWU6Tm90U2VjdXJl
|
|
|
11
11
|
|
|
12
12
|
export default async (openApiUrl: string, baseUrl: string): Promise<OpenAPIResponse> => {
|
|
13
13
|
try {
|
|
14
|
+
console.log(`Fetching OpenAPI spec from: ${openApiUrl}`)
|
|
14
15
|
const { data: openApi } = await axios.get<OpenAPIObject>(openApiUrl, { headers: basicAuthHeader })
|
|
15
16
|
const schemas = openApi.components?.schemas
|
|
16
17
|
if (!schemas) { throw new Error('No schemas found in OpenAPI document') }
|
|
@@ -21,7 +22,16 @@ export default async (openApiUrl: string, baseUrl: string): Promise<OpenAPIRespo
|
|
|
21
22
|
const code = generateFunctions(paths, baseUrl) // TODO baseURL should not be set here, but should be instatiated in runtime somehow
|
|
22
23
|
return { types, code }
|
|
23
24
|
} catch (error: any) {
|
|
24
|
-
|
|
25
|
+
if (error.response) {
|
|
26
|
+
// Server responded with error status
|
|
27
|
+
throw new Error(`HTTP ${error.response.status}: ${error.response.statusText} - Failed to fetch OpenAPI spec from ${openApiUrl}`)
|
|
28
|
+
} else if (error.request) {
|
|
29
|
+
// Request was made but no response received
|
|
30
|
+
throw new Error(`Unable to connect to ${openApiUrl}. Is the server running and accessible?`)
|
|
31
|
+
} else {
|
|
32
|
+
// Something else went wrong
|
|
33
|
+
throw new Error(`Error fetching OpenAPI spec: ${error.message}`)
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
|