openapi-resource-converter 0.0.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.
Files changed (124) hide show
  1. package/README.md +170 -0
  2. package/dist/converter/constant/convert-type.js +19 -0
  3. package/dist/converter/constant/convert-type.js.map +1 -0
  4. package/dist/converter/constant/i-convert-output.js +3 -0
  5. package/dist/converter/constant/i-convert-output.js.map +1 -0
  6. package/dist/converter/i-openapi-converter.js +3 -0
  7. package/dist/converter/i-openapi-converter.js.map +1 -0
  8. package/dist/converter/postman/postman-collection-converter.js +210 -0
  9. package/dist/converter/postman/postman-collection-converter.js.map +1 -0
  10. package/dist/converter/postman/postman-command-builder.js +73 -0
  11. package/dist/converter/postman/postman-command-builder.js.map +1 -0
  12. package/dist/converter/postman/postman-convert-configures.js +81 -0
  13. package/dist/converter/postman/postman-convert-configures.js.map +1 -0
  14. package/dist/index.js +36 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/parser/component-parser.js +96 -0
  17. package/dist/parser/component-parser.js.map +1 -0
  18. package/dist/parser/field-parser.js +6 -0
  19. package/dist/parser/field-parser.js.map +1 -0
  20. package/dist/parser/open-api-parser.js +136 -0
  21. package/dist/parser/open-api-parser.js.map +1 -0
  22. package/dist/parser/parameters-parser.js +42 -0
  23. package/dist/parser/parameters-parser.js.map +1 -0
  24. package/dist/parser/postman-config-parser.js +195 -0
  25. package/dist/parser/postman-config-parser.js.map +1 -0
  26. package/dist/parser/request-body-parser.js +73 -0
  27. package/dist/parser/request-body-parser.js.map +1 -0
  28. package/dist/type/open-api/api-specification.js +79 -0
  29. package/dist/type/open-api/api-specification.js.map +1 -0
  30. package/dist/type/open-api/constant/content-type.js +9 -0
  31. package/dist/type/open-api/constant/content-type.js.map +1 -0
  32. package/dist/type/open-api/constant/data-format.js +36 -0
  33. package/dist/type/open-api/constant/data-format.js.map +1 -0
  34. package/dist/type/open-api/constant/data-type.js +44 -0
  35. package/dist/type/open-api/constant/data-type.js.map +1 -0
  36. package/dist/type/open-api/constant/http-method.js +45 -0
  37. package/dist/type/open-api/constant/http-method.js.map +1 -0
  38. package/dist/type/open-api/constant/in-type.js +30 -0
  39. package/dist/type/open-api/constant/in-type.js.map +1 -0
  40. package/dist/type/open-api/constant/named-literal.js +17 -0
  41. package/dist/type/open-api/constant/named-literal.js.map +1 -0
  42. package/dist/type/open-api/constant/protocol-type.js +40 -0
  43. package/dist/type/open-api/constant/protocol-type.js.map +1 -0
  44. package/dist/type/open-api/open-api-specification.js +43 -0
  45. package/dist/type/open-api/open-api-specification.js.map +1 -0
  46. package/dist/type/open-api/project/contact.js +37 -0
  47. package/dist/type/open-api/project/contact.js.map +1 -0
  48. package/dist/type/open-api/project/project-information.js +49 -0
  49. package/dist/type/open-api/project/project-information.js.map +1 -0
  50. package/dist/type/open-api/protocol/empty-body.js +12 -0
  51. package/dist/type/open-api/protocol/empty-body.js.map +1 -0
  52. package/dist/type/open-api/protocol/open-api-request.js +44 -0
  53. package/dist/type/open-api/protocol/open-api-request.js.map +1 -0
  54. package/dist/type/open-api/protocol/parameters.js +28 -0
  55. package/dist/type/open-api/protocol/parameters.js.map +1 -0
  56. package/dist/type/open-api/protocol/request-body.js +39 -0
  57. package/dist/type/open-api/protocol/request-body.js.map +1 -0
  58. package/dist/type/open-api/sub/i-field.js +3 -0
  59. package/dist/type/open-api/sub/i-field.js.map +1 -0
  60. package/dist/type/open-api/sub/object-field.js +49 -0
  61. package/dist/type/open-api/sub/object-field.js.map +1 -0
  62. package/dist/type/open-api/sub/parameter.js +70 -0
  63. package/dist/type/open-api/sub/parameter.js.map +1 -0
  64. package/dist/type/open-api/sub/tag.js +32 -0
  65. package/dist/type/open-api/sub/tag.js.map +1 -0
  66. package/dist/type/open-api/sub/value-field.js +80 -0
  67. package/dist/type/open-api/sub/value-field.js.map +1 -0
  68. package/dist/type/open-api/sub/version.js +53 -0
  69. package/dist/type/open-api/sub/version.js.map +1 -0
  70. package/dist/type/path.js +62 -0
  71. package/dist/type/path.js.map +1 -0
  72. package/dist/type/postman/constant/case-mode.js +58 -0
  73. package/dist/type/postman/constant/case-mode.js.map +1 -0
  74. package/dist/type/postman/constant/default-value.js +69 -0
  75. package/dist/type/postman/constant/default-value.js.map +1 -0
  76. package/dist/type/postman/constant/request-mode.js +44 -0
  77. package/dist/type/postman/constant/request-mode.js.map +1 -0
  78. package/dist/type/postman/i-postman-node.js +3 -0
  79. package/dist/type/postman/i-postman-node.js.map +1 -0
  80. package/dist/type/postman/i-postman-object.js +3 -0
  81. package/dist/type/postman/i-postman-object.js.map +1 -0
  82. package/dist/type/postman/i-postman-request-body.js +3 -0
  83. package/dist/type/postman/i-postman-request-body.js.map +1 -0
  84. package/dist/type/postman/parsed-postman-option.js +72 -0
  85. package/dist/type/postman/parsed-postman-option.js.map +1 -0
  86. package/dist/type/postman/postman-body-wrapper.js +46 -0
  87. package/dist/type/postman/postman-body-wrapper.js.map +1 -0
  88. package/dist/type/postman/postman-directory.js +61 -0
  89. package/dist/type/postman/postman-directory.js.map +1 -0
  90. package/dist/type/postman/postman-formdata.js +21 -0
  91. package/dist/type/postman/postman-formdata.js.map +1 -0
  92. package/dist/type/postman/postman-header.js +32 -0
  93. package/dist/type/postman/postman-header.js.map +1 -0
  94. package/dist/type/postman/postman-import-file.js +17 -0
  95. package/dist/type/postman/postman-import-file.js.map +1 -0
  96. package/dist/type/postman/postman-info.js +52 -0
  97. package/dist/type/postman/postman-info.js.map +1 -0
  98. package/dist/type/postman/postman-options.js +29 -0
  99. package/dist/type/postman/postman-options.js.map +1 -0
  100. package/dist/type/postman/postman-path-variable.js +72 -0
  101. package/dist/type/postman/postman-path-variable.js.map +1 -0
  102. package/dist/type/postman/postman-query.js +49 -0
  103. package/dist/type/postman/postman-query.js.map +1 -0
  104. package/dist/type/postman/postman-request-body.js +3 -0
  105. package/dist/type/postman/postman-request-body.js.map +1 -0
  106. package/dist/type/postman/postman-request-wrapper-template.js +41 -0
  107. package/dist/type/postman/postman-request-wrapper-template.js.map +1 -0
  108. package/dist/type/postman/postman-request-wrapper.js +29 -0
  109. package/dist/type/postman/postman-request-wrapper.js.map +1 -0
  110. package/dist/type/postman/postman-request.js +52 -0
  111. package/dist/type/postman/postman-request.js.map +1 -0
  112. package/dist/type/postman/postman-url.js +71 -0
  113. package/dist/type/postman/postman-url.js.map +1 -0
  114. package/dist/type/postman/type-value.js +29 -0
  115. package/dist/type/postman/type-value.js.map +1 -0
  116. package/dist/util/collection-util.js +59 -0
  117. package/dist/util/collection-util.js.map +1 -0
  118. package/dist/util/file-util.js +34 -0
  119. package/dist/util/file-util.js.map +1 -0
  120. package/dist/util/object-util.js +160 -0
  121. package/dist/util/object-util.js.map +1 -0
  122. package/dist/util/string-util.js +20 -0
  123. package/dist/util/string-util.js.map +1 -0
  124. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ ## Summary
2
+
3
+ 이 프로젝트는 Open API 3.0 스펙을 여러 데이터 형태로 변환할 수 있는 라이브러리 입니다.
4
+
5
+ ---
6
+
7
+ ## 설치
8
+
9
+ ```shell
10
+ # install package
11
+ npm install -g openapi-resource-converter
12
+ # usage
13
+ orc postman -f <openapi json file path> -o <output file path>
14
+ ```
15
+
16
+ ## 옵션 (Option)
17
+
18
+ ### postman
19
+
20
+ postman 명령어는 OpenAPI 3.0 스펙을 Postman Collection v2.1 스펙으로 변환합니다.
21
+ > The command that named postman will convert to postman collection v2.1 from Open API 3.0.
22
+
23
+ * -f, --file : OpenAPI 3.0 스펙 JSON 파일 경로 (필수)
24
+ * THe file path of Open API 3.0 Specification JSON (Required)
25
+ * -o, --output : 변환된 JSON 파일 경로 (필수)
26
+ * The file path for output (Required)
27
+ * -c, --config : 변환 설정(yaml) 파일 경로 (선택)
28
+ * path of yaml config file (Required)
29
+
30
+ 포스트맨 컬렉션 변환 설정 파일은 다음과 같은 형식으로 작성합니다. (The file that configuring specification that will be converted should be start with:)
31
+
32
+ ```yaml
33
+ postman:
34
+ ...
35
+ ```
36
+
37
+ #### 호스트 지정 (Specify Host)
38
+
39
+ 포스트맨 요청생성시 사용할 호스트를 지정합니다. (Specify host that used when create request for postman)
40
+ ```yaml
41
+ postman:
42
+ host: "http://{{url}}" # 기본값: "{{url}}"
43
+ ```
44
+
45
+ #### 파라미터 키 케이스 설정 (Set naming convention for field key)
46
+
47
+ 파라미터 키의 케이스를 설정합니다. (Set the case for naming convention)
48
+ 사용 가능값: [`camel`, `snake`] (available values)
49
+ ```yaml
50
+ postman:
51
+ case: snake # 기본값: camel
52
+ ```
53
+
54
+ #### 제외 경로 설정 (Set exclude path)
55
+
56
+ 변환에서 제외할 경로를 설정합니다. (set the paths that will be excluded while converting)
57
+ ```yaml
58
+ postman:
59
+ exclude-paths:
60
+ - "/foo/*/move"
61
+ - "/bar/internal/**"
62
+ - "/"
63
+ ```
64
+
65
+ #### 기본 헤더 추가 (Set the default headers)
66
+
67
+ 모든 요청에 추가할 기본 헤더를 설정합니다. (set the default header pairs)
68
+ ```yaml
69
+ postman:
70
+ headers:
71
+ Authorization: "Bearer {{token}}"
72
+ Content-Type: application/json
73
+ ```
74
+
75
+ #### 플레이스홀더 설정 (Set the placeholder)
76
+
77
+ 변환된 요청에 사용할 플레이스홀더를 설정합니다. (Set the placeholders that be used while converting)
78
+ 포맷은 타입에따라 자동으로 적용됩니다. (The format specified according to its type)
79
+ ```yaml
80
+ postman:
81
+ placeholders:
82
+ userId: uid
83
+ ```
84
+ 결과: (result)
85
+ ```text
86
+ {
87
+ "userId": {{uid}}, // 숫자형인 경우
88
+ "userId": "{{uid}}" // 문자열인 경우
89
+ }
90
+ ```
91
+
92
+ #### 요청 래핑 또는 기본값 추가 (Wrapping request of add default values)
93
+
94
+ 생성되는 요청을 다른 객체로 감싸서 내부적인 프로토콜에 대응할 수 있습니다. (To cover up for internal protocol, You can wrapping request into other object)
95
+
96
+ **JSON 형식의 내부 프로토콜** (The protocol of JSON for internally)
97
+
98
+ 🚨 **`type`을 `raw`로 적용해야 합니다.** (type should be applied as row)
99
+
100
+ 아래와 같이 옵션을 적용하는 경우 다음과 같이 `${body}`에 바인딩 되어 적용 됩니다. (The keyword that named `${body}` will be converted like bellow:)
101
+
102
+ ```yaml
103
+ postman:
104
+ request-wrapper:
105
+ - path: /api/v1/**
106
+ type: raw
107
+ format: |
108
+ {
109
+ "id": {{id}},
110
+ "app": "{{version}}",
111
+ "message": ${body}
112
+ }
113
+ ```
114
+
115
+ *AS IS*
116
+
117
+ ```
118
+ {
119
+ "userId": {{userId}}
120
+ }
121
+ ```
122
+
123
+ *TO BE*
124
+
125
+ /api/v1/users: `/api/v1/**`에 해당 되므로 옵션이 요청이 래핑됩니다.
126
+
127
+ ```
128
+ {
129
+ "id": {{id}},
130
+ "app": "{{version}}",
131
+ "message": {
132
+ "userId": {{userId}}
133
+ }
134
+ }
135
+ ```
136
+
137
+ /api/v2/users: `/api/v1/**`에 해당되지 않으므로 그대로 출력됩니다.
138
+
139
+ ```
140
+ {
141
+ "userId": {{userId}}
142
+ }
143
+ ```
144
+
145
+ **Formdata 형식의 파라미터 목록**
146
+
147
+ 🚨 **`type`을 `formdata`로 적용해야 합니다.**
148
+
149
+ ```yaml
150
+ postman:
151
+ request-wrapper:
152
+ - path: /api/v1/**
153
+ type: formdata
154
+ values:
155
+ - name: token
156
+ description: 인증토큰
157
+ value: "{{token}}"
158
+ - name: timestamp
159
+ description: 클라이언트 시간
160
+ value: "{{timestamp}}"
161
+ - name: isAdult
162
+ description: 성인여부
163
+ value: "{{isAdult}}"
164
+ ```
165
+
166
+ 위와 같이 적용시 다른 formdata 파라미터와 함께 적용되어 아래와 같이 보여집니다.
167
+
168
+ ![Formdata 옵션](/images/formdata-option.png)
169
+
170
+ ---
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConvertType = void 0;
4
+ var ConvertType = /** @class */ (function () {
5
+ function ConvertType(value) {
6
+ this._value = value;
7
+ }
8
+ Object.defineProperty(ConvertType.prototype, "value", {
9
+ get: function () {
10
+ return this._value;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ ConvertType.POSTMAN = new ConvertType('postman-import file');
16
+ return ConvertType;
17
+ }());
18
+ exports.ConvertType = ConvertType;
19
+ //# sourceMappingURL=convert-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-type.js","sourceRoot":"","sources":["../../../src/converter/constant/convert-type.ts"],"names":[],"mappings":";;;AAAA;IAKI,qBAAoB,KAAa;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,sBAAI,8BAAK;aAAT;YACI,OAAO,IAAI,CAAC,MAAM,CAAC;QACvB,CAAC;;;OAAA;IATuB,mBAAO,GAAG,IAAI,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAU7E,kBAAC;CAAA,AAZD,IAYC;AAZY,kCAAW"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=i-convert-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-convert-output.js","sourceRoot":"","sources":["../../../src/converter/constant/i-convert-output.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=i-openapi-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-openapi-converter.js","sourceRoot":"","sources":["../../src/converter/i-openapi-converter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var postman_import_file_1 = __importDefault(require("@/type/postman/postman-import-file"));
43
+ var collection_util_1 = require("@/util/collection-util");
44
+ var postman_info_1 = __importDefault(require("@/type/postman/postman-info"));
45
+ var crypto_1 = __importDefault(require("crypto"));
46
+ var path_1 = __importDefault(require("@/type/path"));
47
+ var postman_directory_1 = __importDefault(require("@/type/postman/postman-directory"));
48
+ var postman_request_1 = __importDefault(require("@/type/postman/postman-request"));
49
+ var postman_url_1 = __importDefault(require("@/type/postman/postman-url"));
50
+ var postman_body_wrapper_1 = __importDefault(require("@/type/postman/postman-body-wrapper"));
51
+ var postman_formdata_1 = __importDefault(require("@/type/postman/postman-formdata"));
52
+ var empty_body_1 = __importDefault(require("@/type/open-api/protocol/empty-body"));
53
+ var default_value_1 = __importDefault(require("@/type/postman/constant/default-value"));
54
+ var case_mode_1 = __importDefault(require("@/type/postman/constant/case-mode"));
55
+ var in_type_1 = __importDefault(require("@/type/open-api/constant/in-type"));
56
+ var postman_path_variable_1 = __importDefault(require("@/type/postman/postman-path-variable"));
57
+ var PostmanCollectionConverter = /** @class */ (function () {
58
+ function PostmanCollectionConverter(openAPI, configures) {
59
+ var _this = this;
60
+ this.toPostmanRequest = function (spec) {
61
+ var pathVariables = spec.hasParameters ? _this.extractPathVariables(spec.parameters) : [];
62
+ var url = new postman_url_1.default(_this._configures.host, spec, pathVariables);
63
+ var body = _this.extractRequestBody(spec);
64
+ return new postman_request_1.default(spec.method, _this._configures.headers, url, body);
65
+ };
66
+ this.compactDirectories = function () {
67
+ return __spreadArray([], __read(_this._directoryMap.entries()), false).sort(function (_a, _b) {
68
+ var _c = __read(_a, 1), a = _c[0];
69
+ var _d = __read(_b, 1), b = _d[0];
70
+ return a.localeCompare(b);
71
+ })
72
+ .reduce(function (root, _a) {
73
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
74
+ var path = new path_1.default(key);
75
+ var startDepth = 0;
76
+ var rootChildPath = path.subset(startDepth);
77
+ var foundChild = root.find(function (node) { return node instanceof postman_directory_1.default && node.path.equals(rootChildPath); });
78
+ if (!foundChild) {
79
+ foundChild = new postman_directory_1.default(rootChildPath.lastValue, rootChildPath.value, []);
80
+ foundChild.addNodeRecursive(path, value, startDepth + 1);
81
+ root.push(foundChild);
82
+ }
83
+ else {
84
+ foundChild.addNodeRecursive(path, value, startDepth + 1);
85
+ }
86
+ return root;
87
+ }, _this._nodes);
88
+ };
89
+ this.extractPathVariables = function (parameters) {
90
+ var pathVariables = parameters.getValues(in_type_1.default.PATH);
91
+ if (pathVariables.length === 0) {
92
+ return [];
93
+ }
94
+ return postman_path_variable_1.default.ofParameters(pathVariables);
95
+ };
96
+ this.extractRequestBody = function (specification) {
97
+ //form data 의 경우
98
+ if (specification.hasParameters) {
99
+ var parameters = specification.parameters;
100
+ var queryParameters = parameters.getValues(in_type_1.default.QUERY);
101
+ //Query String
102
+ if (specification.requestBody instanceof empty_body_1.default) {
103
+ return undefined;
104
+ }
105
+ var formdata = _this.toPostmanFormData(queryParameters);
106
+ formdata.concat(_this._configures.getDefaultParameters(specification.path));
107
+ return postman_body_wrapper_1.default.fromFormData(formdata);
108
+ }
109
+ //Request Body 또는 비어있는 경우
110
+ if (specification.requestBody instanceof empty_body_1.default) {
111
+ return undefined;
112
+ }
113
+ else {
114
+ var rawBody = _this.toPostmanRawBody(specification.requestBody.fields);
115
+ var wrappedBody = _this._configures.wrappingBody(specification.path, rawBody);
116
+ return postman_body_wrapper_1.default.fromRaw(wrappedBody);
117
+ }
118
+ };
119
+ this.toPostmanFormData = function (queryParameters) {
120
+ return queryParameters.map(function (parameter) {
121
+ var parameterKey = case_mode_1.default.to(parameter.name, _this._configures.casingMode);
122
+ var value = _this._configures.valuePlaceholder.has(parameterKey)
123
+ ? "{{".concat(_this._configures.valuePlaceholder.get(parameterKey), "}}")
124
+ : default_value_1.default.fromTypeFormat(parameter.type, parameter.format).value;
125
+ return new postman_formdata_1.default(parameterKey, value, "text", parameter.description);
126
+ });
127
+ };
128
+ this.toPostmanRawBody = function (fields) {
129
+ return fields.reduce(function (body, field) {
130
+ var casedKey = case_mode_1.default.to(field.name, _this._configures.casingMode);
131
+ body[casedKey] = _this.extractFieldValueRecursive(field);
132
+ return body;
133
+ }, {});
134
+ };
135
+ this.extractFieldValueRecursive = function (field) {
136
+ var _a;
137
+ if (field.type.isObject()) {
138
+ var objectField = field;
139
+ var body_1 = {};
140
+ (_a = objectField.fields) === null || _a === void 0 ? void 0 : _a.forEach(function (field) { return body_1[case_mode_1.default.to(field.name, _this._configures.casingMode)] = _this.extractFieldValueRecursive(field); });
141
+ return body_1;
142
+ }
143
+ var valueField = field;
144
+ var fieldName = case_mode_1.default.to(valueField.name, _this._configures.casingMode);
145
+ if (_this._configures.valuePlaceholder.has(fieldName)) {
146
+ var placeholder = _this._configures.valuePlaceholder.get(fieldName);
147
+ return "{{".concat(placeholder, "}}");
148
+ }
149
+ return default_value_1.default.fromTypeFormat(valueField.type, valueField.format).typeValue;
150
+ };
151
+ this.getDirectoryName = function (path) {
152
+ var _a, _b;
153
+ return _this._tagMap.has(path.value)
154
+ ? (_b = (_a = _this._tagMap.get(path.value)) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : 'no-description'
155
+ : path.indexOf(path.array.length - 1);
156
+ };
157
+ this.excludePathFilter = function (spec) {
158
+ var path = spec.path;
159
+ return !_this._configures.excludePaths.some(function (excludePath) { return excludePath.matches(path); });
160
+ };
161
+ this._openAPI = openAPI;
162
+ this._group = (0, collection_util_1.groupingAndThen)(openAPI.specs, function (spec) { return spec.path.value; }, function (values) { return (0, collection_util_1.toMap)(values, function (spec) { return spec.method.value.toUpperCase(); }); });
163
+ this._info = new postman_info_1.default(crypto_1.default.randomUUID(), openAPI.info.title, 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json', '23012590');
164
+ this._nodes = [];
165
+ this._configures = configures;
166
+ this._tagMap = (0, collection_util_1.toMap)(openAPI.tags, function (tag) {
167
+ // extract end point from description
168
+ var extractedTag = /\/[a-zA-Z_{}\/]+/g.exec(tag.description);
169
+ if (extractedTag) {
170
+ return extractedTag[0];
171
+ }
172
+ return tag.description;
173
+ });
174
+ this._directoryMap = new Map();
175
+ }
176
+ PostmanCollectionConverter.prototype.convert = function () {
177
+ var e_1, _a;
178
+ var filtered = this._openAPI.specs.filter(this.excludePathFilter);
179
+ try {
180
+ for (var filtered_1 = __values(filtered), filtered_1_1 = filtered_1.next(); !filtered_1_1.done; filtered_1_1 = filtered_1.next()) {
181
+ var spec = filtered_1_1.value;
182
+ var method = spec.method;
183
+ var path = spec.path;
184
+ var methodMap = this._group.get(path.value);
185
+ var specification = methodMap === null || methodMap === void 0 ? void 0 : methodMap.get(method.value.toUpperCase());
186
+ var existDirectory = this._directoryMap.has(path.value);
187
+ var directory = existDirectory
188
+ ? this._directoryMap.get(path.value)
189
+ : new postman_directory_1.default(this.getDirectoryName(path), path.value, []);
190
+ var postmanRequest = this.toPostmanRequest(specification);
191
+ directory.addRequest(specification.summary, postmanRequest);
192
+ //디렉토리가 없는 경우
193
+ if (!existDirectory) {
194
+ this._directoryMap.set(path.value, directory);
195
+ }
196
+ }
197
+ }
198
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
199
+ finally {
200
+ try {
201
+ if (filtered_1_1 && !filtered_1_1.done && (_a = filtered_1.return)) _a.call(filtered_1);
202
+ }
203
+ finally { if (e_1) throw e_1.error; }
204
+ }
205
+ return new postman_import_file_1.default(this._info, this.compactDirectories());
206
+ };
207
+ return PostmanCollectionConverter;
208
+ }());
209
+ exports.default = PostmanCollectionConverter;
210
+ //# sourceMappingURL=postman-collection-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postman-collection-converter.js","sourceRoot":"","sources":["../../../src/converter/postman/postman-collection-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2FAAmE;AAGnE,0DAA8D;AAC9D,6EAAsD;AACtD,kDAA4B;AAG5B,qDAA+B;AAC/B,uFAAgE;AAChE,mFAA4D;AAC5D,2EAAoD;AACpD,6FAAqE;AAErE,qFAA8D;AAE9D,mFAA4D;AAI5D,wFAAiE;AAEjE,gFAAyD;AAEzD,6EAAsD;AACtD,+FAAuE;AAEvE;IAUI,oCAAmB,OAA6B,EAAE,UAAoC;QAAtF,iBAoBC;QA8BgB,qBAAgB,GAAG,UAAC,IAAsB;YACvD,IAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5F,IAAM,GAAG,GAAG,IAAI,qBAAU,CAAC,KAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;YACvE,IAAM,IAAI,GAAG,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAE3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iB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAA;IACvE,CAAC;IAqHL,iCAAC;AAAD,CAAC,AA9KD,IA8KC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var postman_convert_configures_1 = __importDefault(require("@/converter/postman/postman-convert-configures"));
7
+ var open_api_parser_1 = __importDefault(require("@/parser/open-api-parser"));
8
+ var string_util_1 = require("@/util/string-util");
9
+ var file_util_1 = require("@/util/file-util");
10
+ var postman_config_parser_1 = __importDefault(require("@/parser/postman-config-parser"));
11
+ var postman_collection_converter_1 = __importDefault(require("@/converter/postman/postman-collection-converter"));
12
+ var parsed_postman_option_1 = __importDefault(require("@/type/postman/parsed-postman-option"));
13
+ var PostmanCommandBuilder = /** @class */ (function () {
14
+ function PostmanCommandBuilder(option) {
15
+ this._existConfig = false;
16
+ this._configures = new postman_convert_configures_1.default();
17
+ this._option = option;
18
+ this.applyConfigOption();
19
+ if (option.lint === true) {
20
+ console.log('Lint Mode');
21
+ return;
22
+ }
23
+ this.applyFileOption();
24
+ this.applyOutputOption();
25
+ }
26
+ PostmanCommandBuilder.prototype.applyFileOption = function () {
27
+ var openapiJsonPath = this._option.file;
28
+ if ((0, string_util_1.isEmpty)(openapiJsonPath)) {
29
+ throw new Error('Input File Path is Empty');
30
+ }
31
+ if ((0, file_util_1.notExist)(openapiJsonPath)) {
32
+ throw new Error('Invalid file path:' + openapiJsonPath);
33
+ }
34
+ return this;
35
+ };
36
+ PostmanCommandBuilder.prototype.applyConfigOption = function () {
37
+ var configYamlPath = this._option.config;
38
+ if ((0, string_util_1.isEmpty)(configYamlPath)) {
39
+ return;
40
+ }
41
+ if ((0, file_util_1.notExist)(configYamlPath)) {
42
+ throw new Error('Invalid config file path:' + configYamlPath);
43
+ }
44
+ this._existConfig = true;
45
+ return this;
46
+ };
47
+ PostmanCommandBuilder.prototype.applyOutputOption = function () {
48
+ var outputJsonPath = this._option.output;
49
+ if ((0, string_util_1.isEmpty)(outputJsonPath)) {
50
+ throw new Error('Output File Path is Empty');
51
+ }
52
+ return this;
53
+ };
54
+ PostmanCommandBuilder.prototype.execute = function () {
55
+ var configParser = new postman_config_parser_1.default();
56
+ var parsedPostmanOption = this._option.config
57
+ ? configParser.parse((0, file_util_1.readFile)(this._option.config)) : parsed_postman_option_1.default.ofDefault();
58
+ if (this._option.lint === true) {
59
+ parsedPostmanOption.printStatus();
60
+ return;
61
+ }
62
+ this._configures.applyPostmanOption(parsedPostmanOption);
63
+ var openApiParser = new open_api_parser_1.default(this._option.file);
64
+ var openAPI = openApiParser.parse();
65
+ var converter = new postman_collection_converter_1.default(openAPI, this._configures);
66
+ var output = converter.convert();
67
+ var content = JSON.stringify(output);
68
+ (0, file_util_1.refreshFile)(this._option.output, content);
69
+ };
70
+ return PostmanCommandBuilder;
71
+ }());
72
+ exports.default = PostmanCommandBuilder;
73
+ //# sourceMappingURL=postman-command-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postman-command-builder.js","sourceRoot":"","sources":["../../../src/converter/postman/postman-command-builder.ts"],"names":[],"mappings":";;;;;AAAA,8GAAsF;AAGtF,6EAAqD;AACrD,kDAA2C;AAC3C,8CAAiE;AACjE,yFAAiE;AAEjE,kHAA0F;AAC1F,+FAAuE;AAEvE;IAOI,+BAAmB,MAAqB;QAFhC,iBAAY,GAAY,KAAK,CAAC;QAGlC,IAAI,CAAC,WAAW,GAAG,IAAI,oCAAwB,EAAE,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QAErB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YACxB,OAAO;QACX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AAC,IAAA,oBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,MAAO,CAAC,CAAC,CAAC,CAAC,CAAC,+BAAmB,CAAC,SAAS,EAAE,CAAC;QAE3F,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC7B,mBAAmB,CAAC,WAAW,EAAE,CAAC;YAClC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;QAEzD,IAAM,aAAa,GAAG,IAAI,yBAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAK,CAAC,CAAC;QAC5D,IAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;QAEtC,IAAM,SAAS,GAAG,IAAI,sCAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAE5E,IAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QACnC,IAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAA,uBAAW,EAAC,IAAI,CAAC,OAAO,CAAC,MAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IACL,4BAAC;AAAD,CAAC,AA7ED,IA6EC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var case_mode_1 = __importDefault(require("@/type/postman/constant/case-mode"));
7
+ var request_mode_1 = __importDefault(require("@/type/postman/constant/request-mode"));
8
+ var PostmanConvertConfigures = /** @class */ (function () {
9
+ function PostmanConvertConfigures() {
10
+ this._excludePaths = [];
11
+ this._host = '{{url}}';
12
+ this._headers = [];
13
+ this._casingMode = case_mode_1.default.CAMEL;
14
+ this._defaultRequestWrappers = [];
15
+ this._valuePlaceholder = new Map();
16
+ }
17
+ Object.defineProperty(PostmanConvertConfigures.prototype, "excludePaths", {
18
+ get: function () {
19
+ return this._excludePaths;
20
+ },
21
+ enumerable: false,
22
+ configurable: true
23
+ });
24
+ Object.defineProperty(PostmanConvertConfigures.prototype, "host", {
25
+ get: function () {
26
+ return this._host;
27
+ },
28
+ enumerable: false,
29
+ configurable: true
30
+ });
31
+ Object.defineProperty(PostmanConvertConfigures.prototype, "headers", {
32
+ get: function () {
33
+ return this._headers;
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ Object.defineProperty(PostmanConvertConfigures.prototype, "casingMode", {
39
+ get: function () {
40
+ return this._casingMode;
41
+ },
42
+ enumerable: false,
43
+ configurable: true
44
+ });
45
+ Object.defineProperty(PostmanConvertConfigures.prototype, "valuePlaceholder", {
46
+ get: function () {
47
+ return this._valuePlaceholder;
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ PostmanConvertConfigures.prototype.wrappingBody = function (path, body) {
53
+ var found = this._defaultRequestWrappers.find(function (template) {
54
+ return template.type.equalsValue(request_mode_1.default.RAW) && template.path.matches(path);
55
+ });
56
+ if (found) {
57
+ return found.format(body);
58
+ }
59
+ return body;
60
+ };
61
+ PostmanConvertConfigures.prototype.getDefaultParameters = function (path) {
62
+ var found = this._defaultRequestWrappers.find(function (template) {
63
+ return template.type.equalsValue(request_mode_1.default.FORMDATA) && template.path.matches(path);
64
+ });
65
+ if (found) {
66
+ return found.values;
67
+ }
68
+ return [];
69
+ };
70
+ PostmanConvertConfigures.prototype.applyPostmanOption = function (parsedPostmanOption) {
71
+ this._host = parsedPostmanOption.host;
72
+ this._excludePaths = parsedPostmanOption.excludePath;
73
+ this._headers = parsedPostmanOption.headers;
74
+ this._casingMode = parsedPostmanOption.caseMode;
75
+ this._valuePlaceholder = parsedPostmanOption.placeholders;
76
+ this._defaultRequestWrappers = parsedPostmanOption.templates;
77
+ };
78
+ return PostmanConvertConfigures;
79
+ }());
80
+ exports.default = PostmanConvertConfigures;
81
+ //# sourceMappingURL=postman-convert-configures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postman-convert-configures.js","sourceRoot":"","sources":["../../../src/converter/postman/postman-convert-configures.ts"],"names":[],"mappings":";;;;;AAEA,gFAAyD;AAKzD,sFAA+D;AAG/D;IASI;QACI,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,mBAAQ,CAAC,KAAK,CAAC;QAClC,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC1D,CAAC;IAED,sBAAI,kDAAY;aAAhB;YACI,OAAO,IAAI,CAAC,aAAa,CAAC;QAC9B,CAAC;;;OAAA;IAED,sBAAI,0CAAI;aAAR;YACI,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;;;OAAA;IAED,sBAAI,6CAAO;aAAX;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;;;OAAA;IAED,sBAAI,gDAAU;aAAd;YACI,OAAO,IAAI,CAAC,WAAW,CAAC;QAC5B,CAAC;;;OAAA;IAED,sBAAI,sDAAgB;aAApB;YACI,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAClC,CAAC;;;OAAA;IAEM,+CAAY,GAAnB,UAAoB,IAAU,EAAE,IAAyB;QACrD,IAAM,KAAK,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAA,QAAQ;YACpD,OAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,sBAAW,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAAzE,CAAyE,CAAC,CAAC;QAE/E,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAA2B,CAAC;IACvC,CAAC;IAEM,uDAAoB,GAA3B,UAA4B,IAAU;QAClC,IAAM,KAAK,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAA,QAAQ;YACpD,OAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,sBAAW,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAA9E,CAA8E,CAAC,CAAC;QACpF,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,KAAK,CAAC,MAAM,CAAC;QACxB,CAAC;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAEM,qDAAkB,GAAzB,UAA0B,mBAAwC;QAC9D,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,WAAW,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAChD,IAAI,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,YAAY,CAAC;QAC1D,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC,SAAS,CAAC;IACjE,CAAC;IACL,+BAAC;AAAD,CAAC,AAjED,IAiEC"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ require("module-alias/register");
8
+ var commander_1 = require("commander");
9
+ var postman_command_builder_1 = __importDefault(require("@/converter/postman/postman-command-builder"));
10
+ var postmanFilePath = '/static/postman.json';
11
+ var openApiFilePath = '/resources/openapi.json';
12
+ // const json = readFile(`${currentPath}${postmanFilePath}`);
13
+ var program = new commander_1.Command();
14
+ program
15
+ .name('orc')
16
+ .description('OpenAPI Resource Converter')
17
+ .option('-h, --help', '도움말 표시');
18
+ program
19
+ .command('postman')
20
+ .description('convert openapi to postman')
21
+ .option('-f, --file <openapi-file-path>', 'openapi.json 파일 경로(openapi.json file path)')
22
+ .option('-o, --output <output-file-path>', '변환된 파일 저장 경로.(to be saved output file path)')
23
+ .option('-l, --lint', '설정파일을 검증합니다.(validate the configuration file)', false)
24
+ .option('-c, --config <config-file-path>', '설정파일 경로 지정 (set the configuration yaml file path)')
25
+ .action(function (option) {
26
+ try {
27
+ var commandBuilder = new postman_command_builder_1.default(option);
28
+ commandBuilder.execute();
29
+ }
30
+ catch (error) {
31
+ console.error('Error Occurred with command postman:', error);
32
+ process.exit(1);
33
+ }
34
+ });
35
+ program.parse(process.argv);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,iCAA+B;AAC/B,uCAAkC;AAClC,wGAAgF;AAGhF,IAAM,eAAe,GAAG,sBAAsB,CAAC;AAC/C,IAAM,eAAe,GAAG,yBAAyB,CAAC;AAClD,6DAA6D;AAE7D,IAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO;KACF,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAEpC,OAAO;KACF,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,gCAAgC,EAAE,4CAA4C,CAAC;KACtF,MAAM,CAAC,iCAAiC,EAAE,6CAA6C,CAAC;KACxF,MAAM,CAAC,YAAY,EAAE,+CAA+C,EAAE,KAAK,CAAC;KAC5E,MAAM,CAAC,iCAAiC,EAAE,mDAAmD,CAAC;KAC9F,MAAM,CAAC,UAAC,MAAqB;IAC1B,IAAI,CAAC;QACD,IAAM,cAAc,GAAG,IAAI,iCAAqB,CAAC,MAAM,CAAC,CAAC;QACzD,cAAc,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAA;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAIP,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}