vls-openapi-generator 1.6.1 → 1.7.0
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.d.ts +1 -1
- package/dist/index.js +0 -15
- package/dist/lambda-type.d.ts +0 -6
- package/dist/upload-openapi.js +28 -11
- package/package.json +2 -1
- package/src/index.ts +1 -1
- package/src/lambda-type.ts +0 -6
- package/src/upload-openapi.ts +35 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export { OpenAPIConfig } from './lambda-type';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
4
|
const generate_openapi_1 = require("./generate-openapi");
|
|
19
5
|
const upload_openapi_js_1 = require("./upload-openapi.js");
|
|
20
|
-
__exportStar(require("./lambda-type"), exports);
|
|
21
6
|
(async () => {
|
|
22
7
|
try {
|
|
23
8
|
await (0, generate_openapi_1.generateOpenAPI)();
|
package/dist/lambda-type.d.ts
CHANGED
package/dist/upload-openapi.js
CHANGED
|
@@ -40,6 +40,7 @@ const openapi_to_postmanv2_1 = require("openapi-to-postmanv2");
|
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
41
|
const util_1 = require("util");
|
|
42
42
|
const postman_service_1 = require("./postman-service");
|
|
43
|
+
const client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
|
|
43
44
|
const OPENAPI_FILE = path.join(process.cwd(), 'openapi.json');
|
|
44
45
|
const uploadOpenAPI = async () => {
|
|
45
46
|
console.info('Uploading Open API documentation to Postman...');
|
|
@@ -110,20 +111,36 @@ const uploadOpenAPI = async () => {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
await postmanService.updateCollection(collectionID, collection);
|
|
113
|
-
const baseUrl = existingOpenAPIFile.servers.find((x) => x.url.includes(environment))?.url;
|
|
114
|
-
if (!baseUrl) {
|
|
115
|
-
console.warn(`Base URL was not found with the given environment. Environment will not be updated. Given environment: ${environment}`);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
114
|
const environments = (await postmanService.getAllEnvironments()).environments;
|
|
119
115
|
const stackEnvironment = environments.find((x) => x.name === stackName);
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
const cloudFormationClient = new client_cloudformation_1.CloudFormationClient();
|
|
117
|
+
const describeStacksCommand = new client_cloudformation_1.DescribeStacksCommand({
|
|
118
|
+
StackName: stackName
|
|
119
|
+
});
|
|
120
|
+
const result = await cloudFormationClient.send(describeStacksCommand);
|
|
121
|
+
if (!result.Stacks) {
|
|
122
|
+
console.warn(`Base URL was not found with the given environment. Environment will not be updated. Given environment: ${environment}`);
|
|
123
|
+
return;
|
|
122
124
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
for (const cloudFormationStack of result.Stacks) {
|
|
126
|
+
if (!cloudFormationStack.Outputs) {
|
|
127
|
+
console.warn(`Output was not found within the given stack. Environment will not be updated. Given environment: ${environment}`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
for (const output of cloudFormationStack.Outputs) {
|
|
131
|
+
if (output.OutputKey !== 'WebEndpoint' || !output.OutputValue) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!stackEnvironment) {
|
|
135
|
+
await postmanService.createEnvironment(stackName, [{ key: 'baseUrl', value: output.OutputValue }]);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
await postmanService.updateEnvironment(stackEnvironment.id, stackEnvironment.name, [
|
|
139
|
+
{ key: 'baseUrl', value: output.OutputValue }
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
127
144
|
}
|
|
128
145
|
console.info('Open API documentation uploaded successfully');
|
|
129
146
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vls-openapi-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"description": "VLS Open API Generator",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anatine/zod-openapi": "^2.2.7",
|
|
19
|
+
"@aws-sdk/client-cloudformation": "^3.817.0",
|
|
19
20
|
"axios": "^1.7.9",
|
|
20
21
|
"module-alias": "^2.2.3",
|
|
21
22
|
"openapi-to-postmanv2": "^4.25.0"
|
package/src/index.ts
CHANGED
package/src/lambda-type.ts
CHANGED
package/src/upload-openapi.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as path from 'path';
|
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
import { OpenAPI } from './openapi-type';
|
|
7
7
|
import { PostmanService } from './postman-service';
|
|
8
|
+
import { CloudFormationClient, DescribeStacksCommand } from '@aws-sdk/client-cloudformation';
|
|
8
9
|
|
|
9
10
|
const OPENAPI_FILE = path.join(process.cwd(), 'openapi.json');
|
|
10
11
|
|
|
@@ -107,9 +108,19 @@ export const uploadOpenAPI = async (): Promise<void> => {
|
|
|
107
108
|
|
|
108
109
|
await postmanService.updateCollection(collectionID, collection);
|
|
109
110
|
|
|
110
|
-
const
|
|
111
|
+
const environments = (await postmanService.getAllEnvironments()).environments;
|
|
112
|
+
|
|
113
|
+
const stackEnvironment = environments.find((x) => x.name === stackName);
|
|
114
|
+
|
|
115
|
+
const cloudFormationClient = new CloudFormationClient();
|
|
111
116
|
|
|
112
|
-
|
|
117
|
+
const describeStacksCommand = new DescribeStacksCommand({
|
|
118
|
+
StackName: stackName
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const result = await cloudFormationClient.send(describeStacksCommand);
|
|
122
|
+
|
|
123
|
+
if (!result.Stacks) {
|
|
113
124
|
console.warn(
|
|
114
125
|
`Base URL was not found with the given environment. Environment will not be updated. Given environment: ${environment}`
|
|
115
126
|
);
|
|
@@ -117,16 +128,30 @@ export const uploadOpenAPI = async (): Promise<void> => {
|
|
|
117
128
|
return;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
const
|
|
131
|
+
for (const cloudFormationStack of result.Stacks) {
|
|
132
|
+
if (!cloudFormationStack.Outputs) {
|
|
133
|
+
console.warn(
|
|
134
|
+
`Output was not found within the given stack. Environment will not be updated. Given environment: ${environment}`
|
|
135
|
+
);
|
|
121
136
|
|
|
122
|
-
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
123
139
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
for (const output of cloudFormationStack.Outputs) {
|
|
141
|
+
if (output.OutputKey !== 'WebEndpoint' || !output.OutputValue) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!stackEnvironment) {
|
|
146
|
+
await postmanService.createEnvironment(stackName, [{ key: 'baseUrl', value: output.OutputValue }]);
|
|
147
|
+
} else {
|
|
148
|
+
await postmanService.updateEnvironment(stackEnvironment.id, stackEnvironment.name, [
|
|
149
|
+
{ key: 'baseUrl', value: output.OutputValue }
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
130
155
|
}
|
|
131
156
|
|
|
132
157
|
console.info('Open API documentation uploaded successfully');
|