api-render-ui 1.1.2 → 1.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-render-ui",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "api-render-ui is a UI library that pursues simple and efficient data rendering for openapi.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,12 +1,54 @@
1
1
  .codigma-apioperatorlist {
2
2
  align-items: flex-start;
3
- background: white;
3
+ background: var(--surface, white);
4
4
  display: inline-flex;
5
5
  flex-direction: column;
6
6
  gap: 5px;
7
7
  justify-content: flex-start;
8
8
  width: 100%
9
9
  }
10
+ /* Theme variables and mappings */
11
+ :root {
12
+ --Labels---Vibrant---Controls-Primary-√: #404040;
13
+ --primary: #404040;
14
+ --main-color: #404040; /* main / primary color */
15
+ --aux-color: #a9c7ef; /* auxiliary color for hover / accents */
16
+ --embellish-color: #ced8e7; /* embellishment color for active states */
17
+ --surface: white;
18
+ --text: black;
19
+ --even-bg: rgb(235, 239, 244);
20
+ --odd-bg: rgb(250, 246, 246);
21
+ --hover-bg: var(--aux-color, rgb(169, 199, 239));
22
+ --active-bg: var(--embellish-color, rgb(206, 216, 231));
23
+ }
24
+
25
+ .codigma-theme-light {
26
+ --main-color: #404040;
27
+ --aux-color: #a9c7ef;
28
+ --embellish-color: #ced8e7;
29
+ --primary: var(--main-color);
30
+ --Labels---Vibrant---Controls-Primary-√: var(--main-color);
31
+ --surface: white;
32
+ --text: black;
33
+ --even-bg: rgb(235, 239, 244);
34
+ --odd-bg: rgb(250, 246, 246);
35
+ --hover-bg: var(--aux-color);
36
+ --active-bg: var(--embellish-color);
37
+ }
38
+
39
+ .codigma-theme-dark {
40
+ --main-color: #9fb8ff;
41
+ --aux-color: #334155;
42
+ --embellish-color: #22303a;
43
+ --primary: var(--main-color);
44
+ --Labels---Vibrant---Controls-Primary-√: var(--main-color);
45
+ --surface: #1f1f1f;
46
+ --text: #e6e6e6;
47
+ --even-bg: #2a2a2a;
48
+ --odd-bg: #222222;
49
+ --hover-bg: var(--aux-color);
50
+ --active-bg: var(--embellish-color);
51
+ }
10
52
  .codigma-apioperator {
11
53
  align-items: center;
12
54
  align-self: stretch;
@@ -17,18 +59,18 @@
17
59
  justify-content: flex-start
18
60
  }
19
61
  .codigma-apioperator:nth-child(even) {
20
- background-color: rgb(235, 239, 244);
62
+ color: var(--main-color, var(--primary, #404040));
21
63
  }
22
64
  .codigma-apioperator:nth-child(odd) {
23
- background-color: rgb(250, 246, 246);
65
+ color: var(--main-color, var(--primary, #404040));
24
66
  }
25
67
 
26
68
  .codigma-apioperator:hover {
27
69
  cursor: pointer;
28
- background: rgb(169, 199, 239);
70
+ color: var(--main-color, var(--primary, #404040));
29
71
  }
30
72
  .codigma-apioperator:active {
31
- background: rgb(206, 216, 231);
73
+ color: var(--main-color, var(--primary, #404040));
32
74
  }
33
75
  .codigma-method {
34
76
  align-items: center;
@@ -44,18 +86,18 @@
44
86
  justify-content: center
45
87
  }
46
88
  .codigma-get {
47
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
89
+ color: var(--main-color, var(--primary, #404040));
48
90
  word-wrap: break-word
49
91
  }
50
92
  .codigma-requrl {
51
- color: black;
93
+ color: var(--text, black);
52
94
  flex: 1 1 0;
53
95
  word-wrap: break-word
54
96
  }
55
97
  /**********************apiunit css style*************************/
56
98
  .codigma-apiunit {
57
99
  align-items: flex-start;
58
- background: white;
100
+ background: var(--surface, white);
59
101
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
60
102
  display: inline-flex;
61
103
  flex-direction: column;
@@ -66,8 +108,8 @@
66
108
  .codigma-apiunit-apioperator {
67
109
  align-items: center;
68
110
  align-self: stretch;
69
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
70
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
111
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
112
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
71
113
  display: inline-flex;
72
114
  gap: 10px;
73
115
  height: 48px;
@@ -88,17 +130,18 @@
88
130
  justify-content: center
89
131
  }
90
132
  .codigma-apiunit-post {
91
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
133
+ color: var(--main-color, var(--primary, #404040));
92
134
  word-wrap: break-word
93
135
  }
94
136
  .codigma-apiunit-requrl {
95
- color: black;
137
+ color: var(--text, black);
96
138
  flex: 1 1 0;
97
139
  word-wrap: break-word;
98
140
  border-left: 0;
99
141
  border-right: 0;
100
142
  border-top: 0;
101
- border-bottom: 1px solid black;
143
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
144
+ height: 70%;
102
145
  }
103
146
  .codigma-apiunit-send-button {
104
147
  align-items: center;
@@ -109,7 +152,7 @@
109
152
  width: 88px
110
153
  }
111
154
  .codigma-apiunit-send {
112
- color: black;
155
+ color: var(--text, black);
113
156
  word-wrap: break-word
114
157
  }
115
158
  .codigma-apiunit-send-button:hover {
@@ -138,7 +181,7 @@
138
181
  }
139
182
  .codigma-apiunit-parameters-cnr {
140
183
  align-items: center;
141
- background: white;
184
+ background: var(--surface, white);
142
185
  display: flex;
143
186
  height: 42px;
144
187
  justify-content: space-between;
@@ -147,7 +190,7 @@
147
190
  .codigma-apiunit-parakeyvalues {
148
191
  align-items: flex-start;
149
192
  align-self: stretch;
150
- background: white;
193
+ background: var(--surface, white);
151
194
  display: inline-flex;
152
195
  flex-direction: column;
153
196
  flex: 1 1 0;
@@ -165,11 +208,11 @@
165
208
  }
166
209
  .codigma-apiunit-valuetext {
167
210
  align-self: stretch;
168
- background: white;
211
+ background: var(--surface, white);
169
212
  border-left: 0;
170
213
  border-right: 0;
171
214
  border-top: 0;
172
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
215
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
173
216
  padding: 10px;
174
217
  width: 161px
175
218
  }
@@ -194,21 +237,21 @@
194
237
  .codigma-apiunit-parakeyvalues {
195
238
  align-items: flex-start;
196
239
  align-self: stretch;
197
- background: white;
240
+ background: var(--surface, white);
198
241
  display: flex;
199
242
  flex: 1 1 0;
200
243
  gap: 10px;
201
244
  justify-content: flex-start;
202
245
  outline-offset: -1px;
203
- outline: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
246
+ outline: 1px var(--main-color, var(--primary, #404040)) solid;
204
247
  overflow: hidden;
205
248
  padding: 10px
206
249
  }
207
250
  .codigma-apiunit-reqresponse {
208
251
  align-items: flex-start;
209
252
  align-self: stretch;
210
- background: white;
211
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
253
+ background: var(--surface, white);
254
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
212
255
  display: flex;
213
256
  flex-direction: column;
214
257
  flex: 1 1 0;
@@ -226,7 +269,7 @@
226
269
  }
227
270
  .codigma-apiunit-responsetitle {
228
271
  align-items: center;
229
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
272
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
230
273
  display: flex;
231
274
  height: 42px;
232
275
  justify-content: space-between;
@@ -235,7 +278,7 @@
235
278
  .codigma-apiunit-response-cnr {
236
279
  align-items: center;
237
280
  align-self: stretch;
238
- background: white;
281
+ background: var(--surface, white);
239
282
  display: flex;
240
283
  justify-content: space-between;
241
284
  padding-top: 2px;
@@ -1,5 +1,6 @@
1
1
  import { GLOBAL_STYLES } from './inlined-styles';
2
2
  import { OpenAPIV3 } from 'openapi-types';
3
+ import { AstTreeNode } from './model';
3
4
 
4
5
  type OpenAPIV3CustomDoc = OpenAPIV3.Document & { swagger: string; definitions: any } //Compatible with version 2.0
5
6
 
@@ -15,12 +16,15 @@ export class ApiRenderer {
15
16
  mountPoint: document?.body, // 默认挂载到body
16
17
  className: 'Apioperatorlist codigma-apioperatorlist',
17
18
  layerName: 'apioperatorlist'
19
+ ,
20
+ // theme: can be a string like 'light' or 'dark', or an object palette
21
+ theme: 'light'
18
22
  }, options);
19
23
 
20
24
  this.container = null;
21
25
  }
22
26
 
23
- render(apiSpec: OpenAPIV3CustomDoc, renderUnit: boolean = false) {
27
+ render(apiSpec: OpenAPIV3CustomDoc, currentServer?: any, serviceName?: string, renderUnit: boolean = false) {
24
28
 
25
29
  const appendInlineStyle = (text: string) => {
26
30
  if (!ApiRenderer.globalStyleInjected) {
@@ -46,10 +50,58 @@ export class ApiRenderer {
46
50
  throw new Error('Invalid mount point specified');
47
51
  }
48
52
 
53
+ // Apply theme: string name -> add class; object -> set CSS variables on mount element
54
+ try {
55
+ const themeOpt = this.options.theme;
56
+ if (typeof themeOpt === 'string') {
57
+ mountElement.classList.add(`codigma-theme-${themeOpt}`);
58
+ } else if (themeOpt && typeof themeOpt === 'object') {
59
+ const palette = themeOpt as Record<string, any>;
60
+
61
+ const setVar = (key: string, value: any) => {
62
+ if (value == null) return;
63
+ const varName = key.startsWith('--') ? key : `--${key}`;
64
+ try { mountElement.style.setProperty(varName, String(value)); } catch { }
65
+ }
66
+
67
+ // Support both short keys and direct CSS variable names
68
+ // Short keys: main, aux, embellish, surface, primary
69
+ if (palette.main) {
70
+ setVar('--main-color', palette.main);
71
+ setVar('--primary', palette.main);
72
+ setVar('--Labels---Vibrant---Controls-Primary-√', palette.main);
73
+ }
74
+ if (palette.aux) {
75
+ setVar('--aux-color', palette.aux);
76
+ setVar('--hover-bg', palette.aux);
77
+ }
78
+ if (palette.embellish || palette.embellishment) {
79
+ setVar('--embellish-color', palette.embellish || palette.embellishment);
80
+ setVar('--active-bg', palette.embellish || palette.embellishment);
81
+ }
82
+ // fallbacks for previously used keys
83
+ if (palette.primary) {
84
+ setVar('--primary', palette.primary);
85
+ setVar('--Labels---Vibrant---Controls-Primary-√', palette.primary);
86
+ setVar('--main-color', palette.primary);
87
+ }
88
+ if (palette['--even-bg']) setVar('--even-bg', palette['--even-bg']);
89
+ if (palette['--odd-bg']) setVar('--odd-bg', palette['--odd-bg']);
90
+ if (palette.surface) setVar('--surface', palette.surface);
91
+
92
+ // Allow direct CSS variable keys as well
93
+ Object.entries(palette).forEach(([k, v]) => {
94
+ if (k.startsWith('--')) setVar(k, v);
95
+ });
96
+ }
97
+ } catch (e) {
98
+ // swallow theme errors
99
+ }
100
+
49
101
  if ((apiSpec["openapi"] && apiSpec["openapi"].startsWith("3."))
50
102
  || (apiSpec["swagger"] && apiSpec["swagger"].startsWith("2."))) {
51
103
  const countApi = countOpenAPI(apiSpec);
52
- const apiOperatorList = parseOpenAPI(apiSpec);
104
+ const apiOperatorList = parseOpenApiSpec(apiSpec, currentServer, serviceName);
53
105
  // console.log('解析结果:', apiOperatorList);
54
106
  if (countApi == 1 && renderUnit) {
55
107
  // If the count of api <=1, create the api unit only.
@@ -1361,7 +1413,7 @@ function createSvg() {
1361
1413
 
1362
1414
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1363
1415
  path.setAttribute('d', 'M5.5 8.5L10.5 13.5L15.5 8.5');
1364
- path.setAttribute('stroke', 'var(--Labels---Vibrant---Controls-Primary--, #404040)');
1416
+ path.setAttribute('stroke', 'var(--main-color, var(--primary, #404040) )');
1365
1417
  path.setAttribute('stroke-width', '2');
1366
1418
  path.setAttribute('stroke-linecap', 'round');
1367
1419
  path.setAttribute('stroke-linejoin', 'round');
@@ -1521,8 +1573,8 @@ function isHttpMethod(method: string): method is HttpMethod {
1521
1573
  }
1522
1574
 
1523
1575
  // 解析OpenAPI规范并构建API操作列表
1524
- function parseOpenAPI(openapiSpec: OpenAPIV3CustomDoc) {
1525
- const apiOperatorList: any = [];
1576
+ function parseOpenApiSpec(openapiSpec: OpenAPIV3CustomDoc, currentServer?: any, serviceName?: string) {
1577
+ const apiOperatorList: AstTreeNode[] = [];
1526
1578
 
1527
1579
  const pathEntries: [string, OpenAPIV3.PathItemObject | undefined][] = [];
1528
1580
  for (const path in openapiSpec.paths) {
@@ -1549,9 +1601,19 @@ function parseOpenAPI(openapiSpec: OpenAPIV3CustomDoc) {
1549
1601
  // 遍历路径下的所有方法
1550
1602
  pathItemEntries.forEach(([method, operation]) => {
1551
1603
  // 初始化当前API操作对象
1552
- const apiOperator: any = {
1604
+ let url = path
1605
+ if (currentServer) {
1606
+ url = currentServer.value + "/api/" + serviceName + "/v1" + path;
1607
+ } else if (openapiSpec.servers && openapiSpec.servers.length > 0) {
1608
+ url = openapiSpec.servers[0].url + path;
1609
+ }
1610
+
1611
+ const apiOperator: AstTreeNode = {
1612
+ id: uuid(),
1613
+ label: path,
1614
+ children: [],
1553
1615
  method: method.toUpperCase(),
1554
- url: path,
1616
+ url: url,
1555
1617
  rawApiInfo: operation,
1556
1618
  requestBody: null,
1557
1619
  response: {},
@@ -1679,6 +1741,24 @@ function parseOpenAPI(openapiSpec: OpenAPIV3CustomDoc) {
1679
1741
  return apiOperatorList;
1680
1742
  }
1681
1743
 
1744
+
1745
+ function uuid(): string {
1746
+ let s: Array<any> = [];
1747
+ const hexDigits = "0123456789abcdef";
1748
+ for (let i = 0; i < 28; i++) {
1749
+ const start = Math.floor(Math.random() * 0x10);
1750
+ s[i] = hexDigits.substring(start, start + 1);
1751
+ }
1752
+ s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
1753
+ const start1 = (s[19] & 0x3) | 0x8;
1754
+ s[19] = hexDigits.substring(start1, start1 + 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
1755
+ s[8] = s[13] = s[18] = s[23] = "-";
1756
+ s[0] = "a";
1757
+
1758
+ var uuid = s.join("");
1759
+ return uuid;
1760
+ }
1761
+
1682
1762
  function countOpenAPI(openapiSpec: OpenAPIV3CustomDoc) {
1683
1763
  let apiCount = 0;
1684
1764
  const pathEntries: [string, OpenAPIV3.PathItemObject | undefined][] = [];
@@ -1,13 +1,55 @@
1
1
  // Auto-generated by inline-styles.mjs
2
2
  export const GLOBAL_STYLES = `.codigma-apioperatorlist {
3
3
  align-items: flex-start;
4
- background: white;
4
+ background: var(--surface, white);
5
5
  display: inline-flex;
6
6
  flex-direction: column;
7
7
  gap: 5px;
8
8
  justify-content: flex-start;
9
9
  width: 100%
10
10
  }
11
+ /* Theme variables and mappings */
12
+ :root {
13
+ --Labels---Vibrant---Controls-Primary-√: #404040;
14
+ --primary: #404040;
15
+ --main-color: #404040; /* main / primary color */
16
+ --aux-color: #a9c7ef; /* auxiliary color for hover / accents */
17
+ --embellish-color: #ced8e7; /* embellishment color for active states */
18
+ --surface: white;
19
+ --text: black;
20
+ --even-bg: rgb(235, 239, 244);
21
+ --odd-bg: rgb(250, 246, 246);
22
+ --hover-bg: var(--aux-color, rgb(169, 199, 239));
23
+ --active-bg: var(--embellish-color, rgb(206, 216, 231));
24
+ }
25
+
26
+ .codigma-theme-light {
27
+ --main-color: #404040;
28
+ --aux-color: #a9c7ef;
29
+ --embellish-color: #ced8e7;
30
+ --primary: var(--main-color);
31
+ --Labels---Vibrant---Controls-Primary-√: var(--main-color);
32
+ --surface: white;
33
+ --text: black;
34
+ --even-bg: rgb(235, 239, 244);
35
+ --odd-bg: rgb(250, 246, 246);
36
+ --hover-bg: var(--aux-color);
37
+ --active-bg: var(--embellish-color);
38
+ }
39
+
40
+ .codigma-theme-dark {
41
+ --main-color: #9fb8ff;
42
+ --aux-color: #334155;
43
+ --embellish-color: #22303a;
44
+ --primary: var(--main-color);
45
+ --Labels---Vibrant---Controls-Primary-√: var(--main-color);
46
+ --surface: #1f1f1f;
47
+ --text: #e6e6e6;
48
+ --even-bg: #2a2a2a;
49
+ --odd-bg: #222222;
50
+ --hover-bg: var(--aux-color);
51
+ --active-bg: var(--embellish-color);
52
+ }
11
53
  .codigma-apioperator {
12
54
  align-items: center;
13
55
  align-self: stretch;
@@ -18,18 +60,18 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
18
60
  justify-content: flex-start
19
61
  }
20
62
  .codigma-apioperator:nth-child(even) {
21
- background-color: rgb(235, 239, 244);
63
+ color: var(--main-color, var(--primary, #404040));
22
64
  }
23
65
  .codigma-apioperator:nth-child(odd) {
24
- background-color: rgb(250, 246, 246);
66
+ color: var(--main-color, var(--primary, #404040));
25
67
  }
26
68
 
27
69
  .codigma-apioperator:hover {
28
70
  cursor: pointer;
29
- background: rgb(169, 199, 239);
71
+ color: var(--main-color, var(--primary, #404040));
30
72
  }
31
73
  .codigma-apioperator:active {
32
- background: rgb(206, 216, 231);
74
+ color: var(--main-color, var(--primary, #404040));
33
75
  }
34
76
  .codigma-method {
35
77
  align-items: center;
@@ -45,18 +87,18 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
45
87
  justify-content: center
46
88
  }
47
89
  .codigma-get {
48
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
90
+ color: var(--main-color, var(--primary, #404040));
49
91
  word-wrap: break-word
50
92
  }
51
93
  .codigma-requrl {
52
- color: black;
94
+ color: var(--text, black);
53
95
  flex: 1 1 0;
54
96
  word-wrap: break-word
55
97
  }
56
98
  /**********************apiunit css style*************************/
57
99
  .codigma-apiunit {
58
100
  align-items: flex-start;
59
- background: white;
101
+ background: var(--surface, white);
60
102
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
61
103
  display: inline-flex;
62
104
  flex-direction: column;
@@ -67,8 +109,8 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
67
109
  .codigma-apiunit-apioperator {
68
110
  align-items: center;
69
111
  align-self: stretch;
70
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
71
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
112
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
113
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
72
114
  display: inline-flex;
73
115
  gap: 10px;
74
116
  height: 48px;
@@ -89,17 +131,18 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
89
131
  justify-content: center
90
132
  }
91
133
  .codigma-apiunit-post {
92
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
134
+ color: var(--main-color, var(--primary, #404040));
93
135
  word-wrap: break-word
94
136
  }
95
137
  .codigma-apiunit-requrl {
96
- color: black;
138
+ color: var(--text, black);
97
139
  flex: 1 1 0;
98
140
  word-wrap: break-word;
99
141
  border-left: 0;
100
142
  border-right: 0;
101
143
  border-top: 0;
102
- border-bottom: 1px solid black;
144
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
145
+ height: 70%;
103
146
  }
104
147
  .codigma-apiunit-send-button {
105
148
  align-items: center;
@@ -110,7 +153,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
110
153
  width: 88px
111
154
  }
112
155
  .codigma-apiunit-send {
113
- color: black;
156
+ color: var(--text, black);
114
157
  word-wrap: break-word
115
158
  }
116
159
  .codigma-apiunit-send-button:hover {
@@ -139,7 +182,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
139
182
  }
140
183
  .codigma-apiunit-parameters-cnr {
141
184
  align-items: center;
142
- background: white;
185
+ background: var(--surface, white);
143
186
  display: flex;
144
187
  height: 42px;
145
188
  justify-content: space-between;
@@ -148,7 +191,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
148
191
  .codigma-apiunit-parakeyvalues {
149
192
  align-items: flex-start;
150
193
  align-self: stretch;
151
- background: white;
194
+ background: var(--surface, white);
152
195
  display: inline-flex;
153
196
  flex-direction: column;
154
197
  flex: 1 1 0;
@@ -166,11 +209,11 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
166
209
  }
167
210
  .codigma-apiunit-valuetext {
168
211
  align-self: stretch;
169
- background: white;
212
+ background: var(--surface, white);
170
213
  border-left: 0;
171
214
  border-right: 0;
172
215
  border-top: 0;
173
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
216
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
174
217
  padding: 10px;
175
218
  width: 161px
176
219
  }
@@ -195,21 +238,21 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
195
238
  .codigma-apiunit-parakeyvalues {
196
239
  align-items: flex-start;
197
240
  align-self: stretch;
198
- background: white;
241
+ background: var(--surface, white);
199
242
  display: flex;
200
243
  flex: 1 1 0;
201
244
  gap: 10px;
202
245
  justify-content: flex-start;
203
246
  outline-offset: -1px;
204
- outline: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
247
+ outline: 1px var(--main-color, var(--primary, #404040)) solid;
205
248
  overflow: hidden;
206
249
  padding: 10px
207
250
  }
208
251
  .codigma-apiunit-reqresponse {
209
252
  align-items: flex-start;
210
253
  align-self: stretch;
211
- background: white;
212
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
254
+ background: var(--surface, white);
255
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
213
256
  display: flex;
214
257
  flex-direction: column;
215
258
  flex: 1 1 0;
@@ -227,7 +270,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
227
270
  }
228
271
  .codigma-apiunit-responsetitle {
229
272
  align-items: center;
230
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
273
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
231
274
  display: flex;
232
275
  height: 42px;
233
276
  justify-content: space-between;
@@ -236,7 +279,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
236
279
  .codigma-apiunit-response-cnr {
237
280
  align-items: center;
238
281
  align-self: stretch;
239
- background: white;
282
+ background: var(--surface, white);
240
283
  display: flex;
241
284
  justify-content: space-between;
242
285
  padding-top: 2px;
package/src/model.ts ADDED
@@ -0,0 +1,45 @@
1
+ export type TreeNodeType = "folder" | "file" | "bookmark" | "api";
2
+ export interface AstTreeNode {
3
+ id: string;
4
+ label: string;
5
+ children: Array<AstTreeNode>;
6
+ deepLevel?: number;
7
+ isExpanded?: boolean;
8
+ nodeType?: TreeNodeType;
9
+ isNewData?: boolean;
10
+ servers?: Array<string>;
11
+ folder?: string;
12
+ folderInfo?: {
13
+ servers: Array<any>
14
+ };
15
+ serviceName?: string;
16
+ method?: string;
17
+ symbol?: string;
18
+ path?: string;
19
+ url?: string;
20
+ summary?: string;
21
+ tabLabel?: string;
22
+ rawApiInfo?: any;
23
+ server?: any;
24
+ parentItem?: any,
25
+ symbolColor?: string;
26
+ consumes?: Array<any>;
27
+ produces?: Array<any>;
28
+ currentConsume?: string;
29
+ requestBody?: any; //适用于openapi 3.0
30
+ response?: {
31
+ status?: number | string;
32
+ statusText?: string;
33
+ body?: string;//响应体统一转换成字符串
34
+ };
35
+ parameterHasBody?: boolean;
36
+ parameterHasFormDataVer2?: boolean; //区分openapi 2.0
37
+ isActive?: boolean;
38
+ hideActiveStatus?: boolean;//当激活了其它的节点的类型为folder的节点被激活时,隐藏非folder节点的激活状态
39
+ custom?: boolean;
40
+ customQueryparameters?: Array<any>;
41
+ customHeaderparameters?: Array<any>;
42
+ sourceCodeText?: string;
43
+ auth?: any;
44
+ rename?: boolean
45
+ }