@@ -60,11 +60,12 @@ public class ImportDialog extends AbstractDialog {
60
60
private static final long serialVersionUID = -7074394202143400215L ;
61
61
62
62
private final ExtensionLlm extLlm ;
63
- private JTextField fieldSwagger ;
63
+ private JTextField fieldOpenapi ;
64
64
private JButton buttonChooseFile ;
65
65
private JButton buttonCancel ;
66
66
private JButton buttonImport ;
67
67
private JProgressBar progressBar ;
68
+ private LlmOptionsParam llmOptionsParam ;
68
69
69
70
public ImportDialog (JFrame parent , final ExtensionLlm extLlm ) {
70
71
super (parent , true );
@@ -79,12 +80,12 @@ public ImportDialog(JFrame parent, final ExtensionLlm extLlm) {
79
80
var labelWsdl =
80
81
new ZapHtmlLabel (
81
82
"<html>"
82
- + Constant .messages .getString ("llm.importDialog.labelSwagger " )
83
+ + Constant .messages .getString ("llm.importDialog.labelOpenAPI " )
83
84
+ "<font color=red>*</font></html>" );
84
85
fieldsPanel .add (
85
86
labelWsdl , LayoutHelper .getGBC (0 , fieldsRow , 1 , 0.5 , new Insets (0 , 0 , 4 , 4 )));
86
87
fieldsPanel .add (
87
- getSwaggerField (),
88
+ getOpenapiField (),
88
89
LayoutHelper .getGBC (1 , fieldsRow , 1 , 0.5 , new Insets (0 , 4 , 4 , 4 )));
89
90
fieldsPanel .add (
90
91
getChooseFileButton (),
@@ -111,11 +112,11 @@ public ImportDialog(JFrame parent, final ExtensionLlm extLlm) {
111
112
setDefaultCloseOperation (DISPOSE_ON_CLOSE );
112
113
}
113
114
114
- private boolean importSwagger ()
115
+ private boolean importOpenapi ()
115
116
throws IOException , URISyntaxException , ApiException , DatabaseException {
116
117
117
- String swaggerLocation = getSwaggerField ().getText ();
118
- LlmOptionsParam llmOptionsParam = extLlm .getOptionsParam ();
118
+ String openapiLocation = getOpenapiField ().getText ();
119
+ llmOptionsParam = extLlm .getOptionsParam ();
119
120
Integer endpointCount = 0 ;
120
121
121
122
if (StringUtils .isEmpty (llmOptionsParam .getApiKey ())) {
@@ -134,40 +135,39 @@ private boolean importSwagger()
134
135
new LlmCommunicationService (
135
136
llmOptionsParam .getModelName (), llmOptionsParam .getApiKey (), llmOptionsParam .getEndpoint ());
136
137
137
- if (StringUtils .isEmpty (swaggerLocation )) {
138
+ if (StringUtils .isEmpty (openapiLocation )) {
138
139
ThreadUtils .invokeAndWaitHandled (
139
140
() -> {
140
141
showWarningDialog (
141
142
Constant .messages .getString (
142
- "llm.importDialog.error.missingSwagger " ));
143
- getSwaggerField ().requestFocusInWindow ();
143
+ "llm.importDialog.error.missingOpenapi " ));
144
+ getOpenapiField ().requestFocusInWindow ();
144
145
});
145
146
return false ;
146
147
}
147
148
148
149
try {
149
- new URL (swaggerLocation ).toURI ();
150
- new URI (swaggerLocation , true );
151
- // implement logic here
152
- endpointCount = llmCommunicationService .importSwaggerFromUrl (swaggerLocation );
150
+ new URL (openapiLocation ).toURI ();
151
+ new URI (openapiLocation , true );
152
+ endpointCount = llmCommunicationService .importOpenapiFromUrl (openapiLocation );
153
153
154
154
return true ;
155
155
} catch (URIException | MalformedURLException | URISyntaxException e ) {
156
156
// Not a valid URI, try to import as a file
157
- endpointCount = llmCommunicationService .importSwaggerFromFile ( swaggerLocation );
157
+ endpointCount = llmCommunicationService .importOpenapiFromFile ( openapiLocation );
158
158
}
159
159
160
- var file = new File (swaggerLocation );
160
+ var file = new File (openapiLocation );
161
161
if (!file .canRead ()) {
162
162
ThreadUtils .invokeAndWaitHandled (
163
163
() -> {
164
- showWarningFileNotFound (swaggerLocation );
165
- getSwaggerField ().requestFocusInWindow ();
164
+ showWarningFileNotFound (openapiLocation );
165
+ getOpenapiField ().requestFocusInWindow ();
166
166
});
167
167
return false ;
168
168
}
169
169
170
- endpointCount = llmCommunicationService .importSwaggerFromFile ( swaggerLocation );
170
+ endpointCount = llmCommunicationService .importOpenapiFromFile ( openapiLocation );
171
171
172
172
showMessageDialog (
173
173
Constant .messages .getString ("llm.importDialog.import.success" , endpointCount ));
@@ -185,12 +185,12 @@ private static void setContextMenu(JTextField field) {
185
185
field .setComponentPopupMenu (jPopupMenu );
186
186
}
187
187
188
- private JTextField getSwaggerField () {
189
- if (fieldSwagger == null ) {
190
- fieldSwagger = new JTextField (25 );
191
- setContextMenu (fieldSwagger );
188
+ private JTextField getOpenapiField () {
189
+ if (fieldOpenapi == null ) {
190
+ fieldOpenapi = new JTextField (25 );
191
+ setContextMenu (fieldOpenapi );
192
192
}
193
- return fieldSwagger ;
193
+ return fieldOpenapi ;
194
194
}
195
195
196
196
private JButton getChooseFileButton () {
@@ -213,7 +213,7 @@ private JButton getChooseFileButton() {
213
213
if (state == JFileChooser .APPROVE_OPTION ) {
214
214
String filename = fileChooser .getSelectedFile ().getAbsolutePath ();
215
215
try {
216
- getSwaggerField ().setText (filename );
216
+ getOpenapiField ().setText (filename );
217
217
Model .getSingleton ()
218
218
.getOptionsParam ()
219
219
.setUserDirectory (fileChooser .getCurrentDirectory ());
@@ -248,20 +248,14 @@ private JButton getImportButton() {
248
248
new Thread (
249
249
() -> {
250
250
try {
251
- if (importSwagger ()) {
251
+ if (importOpenapi ()) {
252
252
ThreadUtils .invokeAndWaitHandled (
253
253
() -> {
254
254
dispose ();
255
255
showProgressBar (false );
256
256
});
257
257
}
258
- } catch (IOException ex ) {
259
- throw new RuntimeException (ex );
260
- } catch (URISyntaxException ex ) {
261
- throw new RuntimeException (ex );
262
- } catch (ApiException ex ) {
263
- throw new RuntimeException (ex );
264
- } catch (DatabaseException ex ) {
258
+ } catch (Exception ex ) {
265
259
throw new RuntimeException (ex );
266
260
}
267
261
},
@@ -296,7 +290,7 @@ private void showProgressBar(boolean show) {
296
290
getProgressBar ().setVisible (show );
297
291
298
292
getImportButton ().setEnabled (!show );
299
- getSwaggerField ().setEnabled (!show );
293
+ getOpenapiField ().setEnabled (!show );
300
294
getChooseFileButton ().setEnabled (!show );
301
295
}
302
296
@@ -310,6 +304,6 @@ private JProgressBar getProgressBar() {
310
304
}
311
305
312
306
public void clearFields () {
313
- getSwaggerField ().setText ("" );
307
+ getOpenapiField ().setText ("" );
314
308
}
315
309
}
0 commit comments