api-render-ui 1.1.3 → 1.1.5

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.3",
3
+ "version": "1.1.5",
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,21 @@
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(--text, black);
71
+ background-color: var(--hover-bg, rgba(169,199,239,0.12));
72
+ transition: background-color .12s ease, color .12s ease;
73
+ border-radius: 4px;
29
74
  }
30
75
  .codigma-apioperator:active {
31
- background: rgb(206, 216, 231);
76
+ color: var(--main-color, var(--primary, #404040));
32
77
  }
33
78
  .codigma-method {
34
79
  align-items: center;
@@ -44,18 +89,18 @@
44
89
  justify-content: center
45
90
  }
46
91
  .codigma-get {
47
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
92
+ color: var(--main-color, var(--primary, #404040));
48
93
  word-wrap: break-word
49
94
  }
50
95
  .codigma-requrl {
51
- color: black;
96
+ color: var(--text, black);
52
97
  flex: 1 1 0;
53
98
  word-wrap: break-word
54
99
  }
55
100
  /**********************apiunit css style*************************/
56
101
  .codigma-apiunit {
57
102
  align-items: flex-start;
58
- background: white;
103
+ background: var(--surface, white);
59
104
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
60
105
  display: inline-flex;
61
106
  flex-direction: column;
@@ -66,8 +111,8 @@
66
111
  .codigma-apiunit-apioperator {
67
112
  align-items: center;
68
113
  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;
114
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
115
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
71
116
  display: inline-flex;
72
117
  gap: 10px;
73
118
  height: 48px;
@@ -88,17 +133,18 @@
88
133
  justify-content: center
89
134
  }
90
135
  .codigma-apiunit-post {
91
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
136
+ color: var(--main-color, var(--primary, #404040));
92
137
  word-wrap: break-word
93
138
  }
94
139
  .codigma-apiunit-requrl {
95
- color: black;
140
+ color: var(--text, black);
96
141
  flex: 1 1 0;
97
142
  word-wrap: break-word;
98
143
  border-left: 0;
99
144
  border-right: 0;
100
145
  border-top: 0;
101
- border-bottom: 1px solid black;
146
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
147
+ height: 70%;
102
148
  }
103
149
  .codigma-apiunit-send-button {
104
150
  align-items: center;
@@ -109,7 +155,7 @@
109
155
  width: 88px
110
156
  }
111
157
  .codigma-apiunit-send {
112
- color: black;
158
+ color: var(--text, black);
113
159
  word-wrap: break-word
114
160
  }
115
161
  .codigma-apiunit-send-button:hover {
@@ -138,7 +184,7 @@
138
184
  }
139
185
  .codigma-apiunit-parameters-cnr {
140
186
  align-items: center;
141
- background: white;
187
+ background: var(--surface, white);
142
188
  display: flex;
143
189
  height: 42px;
144
190
  justify-content: space-between;
@@ -147,7 +193,7 @@
147
193
  .codigma-apiunit-parakeyvalues {
148
194
  align-items: flex-start;
149
195
  align-self: stretch;
150
- background: white;
196
+ background: var(--surface, white);
151
197
  display: inline-flex;
152
198
  flex-direction: column;
153
199
  flex: 1 1 0;
@@ -165,11 +211,11 @@
165
211
  }
166
212
  .codigma-apiunit-valuetext {
167
213
  align-self: stretch;
168
- background: white;
214
+ background: var(--surface, white);
169
215
  border-left: 0;
170
216
  border-right: 0;
171
217
  border-top: 0;
172
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
218
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
173
219
  padding: 10px;
174
220
  width: 161px
175
221
  }
@@ -194,21 +240,21 @@
194
240
  .codigma-apiunit-parakeyvalues {
195
241
  align-items: flex-start;
196
242
  align-self: stretch;
197
- background: white;
243
+ background: var(--surface, white);
198
244
  display: flex;
199
245
  flex: 1 1 0;
200
246
  gap: 10px;
201
247
  justify-content: flex-start;
202
248
  outline-offset: -1px;
203
- outline: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
249
+ outline: 1px var(--main-color, var(--primary, #404040)) solid;
204
250
  overflow: hidden;
205
251
  padding: 10px
206
252
  }
207
253
  .codigma-apiunit-reqresponse {
208
254
  align-items: flex-start;
209
255
  align-self: stretch;
210
- background: white;
211
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
256
+ background: var(--surface, white);
257
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
212
258
  display: flex;
213
259
  flex-direction: column;
214
260
  flex: 1 1 0;
@@ -226,7 +272,7 @@
226
272
  }
227
273
  .codigma-apiunit-responsetitle {
228
274
  align-items: center;
229
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
275
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
230
276
  display: flex;
231
277
  height: 42px;
232
278
  justify-content: space-between;
@@ -235,7 +281,7 @@
235
281
  .codigma-apiunit-response-cnr {
236
282
  align-items: center;
237
283
  align-self: stretch;
238
- background: white;
284
+ background: var(--surface, white);
239
285
  display: flex;
240
286
  justify-content: space-between;
241
287
  padding-top: 2px;
@@ -247,4 +293,10 @@
247
293
  flex: 1 1 0;
248
294
  min-height: 5rem;
249
295
  /* padding: 2px */
296
+ }
297
+ .codigma-apiunit-apioperator:hover {
298
+ cursor: pointer;
299
+ color: var(--text, black);
300
+ background-color: var(--hover-bg, rgba(169,199,239,0.08));
301
+ transition: background-color .12s ease, color .12s ease;
250
302
  }
@@ -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,6 +16,9 @@ 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;
@@ -46,6 +50,54 @@ 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);
@@ -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');
@@ -1522,7 +1574,7 @@ function isHttpMethod(method: string): method is HttpMethod {
1522
1574
 
1523
1575
  // 解析OpenAPI规范并构建API操作列表
1524
1576
  function parseOpenApiSpec(openapiSpec: OpenAPIV3CustomDoc, currentServer?: any, serviceName?: string) {
1525
- const apiOperatorList: any = [];
1577
+ const apiOperatorList: AstTreeNode[] = [];
1526
1578
 
1527
1579
  const pathEntries: [string, OpenAPIV3.PathItemObject | undefined][] = [];
1528
1580
  for (const path in openapiSpec.paths) {
@@ -1556,7 +1608,10 @@ function parseOpenApiSpec(openapiSpec: OpenAPIV3CustomDoc, currentServer?: any,
1556
1608
  url = openapiSpec.servers[0].url + path;
1557
1609
  }
1558
1610
 
1559
- const apiOperator: any = {
1611
+ const apiOperator: AstTreeNode = {
1612
+ id: uuid(),
1613
+ label: path,
1614
+ children: [],
1560
1615
  method: method.toUpperCase(),
1561
1616
  url: url,
1562
1617
  rawApiInfo: operation,
@@ -1686,6 +1741,24 @@ function parseOpenApiSpec(openapiSpec: OpenAPIV3CustomDoc, currentServer?: any,
1686
1741
  return apiOperatorList;
1687
1742
  }
1688
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
+
1689
1762
  function countOpenAPI(openapiSpec: OpenAPIV3CustomDoc) {
1690
1763
  let apiCount = 0;
1691
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,21 @@ 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(--text, black);
72
+ background-color: var(--hover-bg, rgba(169,199,239,0.12));
73
+ transition: background-color .12s ease, color .12s ease;
74
+ border-radius: 4px;
30
75
  }
31
76
  .codigma-apioperator:active {
32
- background: rgb(206, 216, 231);
77
+ color: var(--main-color, var(--primary, #404040));
33
78
  }
34
79
  .codigma-method {
35
80
  align-items: center;
@@ -45,18 +90,18 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
45
90
  justify-content: center
46
91
  }
47
92
  .codigma-get {
48
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
93
+ color: var(--main-color, var(--primary, #404040));
49
94
  word-wrap: break-word
50
95
  }
51
96
  .codigma-requrl {
52
- color: black;
97
+ color: var(--text, black);
53
98
  flex: 1 1 0;
54
99
  word-wrap: break-word
55
100
  }
56
101
  /**********************apiunit css style*************************/
57
102
  .codigma-apiunit {
58
103
  align-items: flex-start;
59
- background: white;
104
+ background: var(--surface, white);
60
105
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
61
106
  display: inline-flex;
62
107
  flex-direction: column;
@@ -67,8 +112,8 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
67
112
  .codigma-apiunit-apioperator {
68
113
  align-items: center;
69
114
  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;
115
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
116
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
72
117
  display: inline-flex;
73
118
  gap: 10px;
74
119
  height: 48px;
@@ -89,17 +134,18 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
89
134
  justify-content: center
90
135
  }
91
136
  .codigma-apiunit-post {
92
- color: var(--Labels---Vibrant---Controls-Primary-√, #404040);
137
+ color: var(--main-color, var(--primary, #404040));
93
138
  word-wrap: break-word
94
139
  }
95
140
  .codigma-apiunit-requrl {
96
- color: black;
141
+ color: var(--text, black);
97
142
  flex: 1 1 0;
98
143
  word-wrap: break-word;
99
144
  border-left: 0;
100
145
  border-right: 0;
101
146
  border-top: 0;
102
- border-bottom: 1px solid black;
147
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
148
+ height: 70%;
103
149
  }
104
150
  .codigma-apiunit-send-button {
105
151
  align-items: center;
@@ -110,7 +156,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
110
156
  width: 88px
111
157
  }
112
158
  .codigma-apiunit-send {
113
- color: black;
159
+ color: var(--text, black);
114
160
  word-wrap: break-word
115
161
  }
116
162
  .codigma-apiunit-send-button:hover {
@@ -139,7 +185,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
139
185
  }
140
186
  .codigma-apiunit-parameters-cnr {
141
187
  align-items: center;
142
- background: white;
188
+ background: var(--surface, white);
143
189
  display: flex;
144
190
  height: 42px;
145
191
  justify-content: space-between;
@@ -148,7 +194,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
148
194
  .codigma-apiunit-parakeyvalues {
149
195
  align-items: flex-start;
150
196
  align-self: stretch;
151
- background: white;
197
+ background: var(--surface, white);
152
198
  display: inline-flex;
153
199
  flex-direction: column;
154
200
  flex: 1 1 0;
@@ -166,11 +212,11 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
166
212
  }
167
213
  .codigma-apiunit-valuetext {
168
214
  align-self: stretch;
169
- background: white;
215
+ background: var(--surface, white);
170
216
  border-left: 0;
171
217
  border-right: 0;
172
218
  border-top: 0;
173
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
219
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
174
220
  padding: 10px;
175
221
  width: 161px
176
222
  }
@@ -195,21 +241,21 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
195
241
  .codigma-apiunit-parakeyvalues {
196
242
  align-items: flex-start;
197
243
  align-self: stretch;
198
- background: white;
244
+ background: var(--surface, white);
199
245
  display: flex;
200
246
  flex: 1 1 0;
201
247
  gap: 10px;
202
248
  justify-content: flex-start;
203
249
  outline-offset: -1px;
204
- outline: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
250
+ outline: 1px var(--main-color, var(--primary, #404040)) solid;
205
251
  overflow: hidden;
206
252
  padding: 10px
207
253
  }
208
254
  .codigma-apiunit-reqresponse {
209
255
  align-items: flex-start;
210
256
  align-self: stretch;
211
- background: white;
212
- border-top: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
257
+ background: var(--surface, white);
258
+ border-top: 1px var(--main-color, var(--primary, #404040)) solid;
213
259
  display: flex;
214
260
  flex-direction: column;
215
261
  flex: 1 1 0;
@@ -227,7 +273,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
227
273
  }
228
274
  .codigma-apiunit-responsetitle {
229
275
  align-items: center;
230
- border-bottom: 1px var(--Labels---Vibrant---Controls-Primary-√, #404040) solid;
276
+ border-bottom: 1px var(--main-color, var(--primary, #404040)) solid;
231
277
  display: flex;
232
278
  height: 42px;
233
279
  justify-content: space-between;
@@ -236,7 +282,7 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
236
282
  .codigma-apiunit-response-cnr {
237
283
  align-items: center;
238
284
  align-self: stretch;
239
- background: white;
285
+ background: var(--surface, white);
240
286
  display: flex;
241
287
  justify-content: space-between;
242
288
  padding-top: 2px;
@@ -248,4 +294,10 @@ export const GLOBAL_STYLES = `.codigma-apioperatorlist {
248
294
  flex: 1 1 0;
249
295
  min-height: 5rem;
250
296
  /* padding: 2px */
297
+ }
298
+ .codigma-apiunit-apioperator:hover {
299
+ cursor: pointer;
300
+ color: var(--text, black);
301
+ background-color: var(--hover-bg, rgba(169,199,239,0.08));
302
+ transition: background-color .12s ease, color .12s ease;
251
303
  }`;
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
+ }