@@ -157,6 +157,12 @@ declare global {
157157 }
158158}
159159
160+ interface BasePathOption {
161+ label : string ;
162+ value : string ;
163+ }
164+
165+
160166export default function RestImport ( { language, restImportConfig } : { language : string , restImportConfig : restImportConfigI } ) {
161167 const theme = createTheme ( {
162168 typography : {
@@ -302,7 +308,7 @@ export default function RestImport({ language, restImportConfig }: { language: s
302308 var multiParamInfoList : any [ ] = [ ]
303309 var oAuthRetry = true
304310 const [ basePath , setBasePath ] = useState < string > ( restImportConfig ?. urlBasePath )
305- const [ basePathList , setBasePathList ] = useState < string [ ] > ( [ ] ) ;
311+ const [ basePathList , setBasePathList ] = useState < BasePathOption [ ] > ( [ ] ) ;
306312 const [ basePathEnabled , setBasePathEnabled ] = useState ( ! restImportConfig ?. viewMode )
307313 const [ settingsDetailsResponse , setSettingsDetailsResponse ] = useState ( restImportConfig ?. settingsDetailsResponse || { } )
308314
@@ -344,10 +350,23 @@ export default function RestImport({ language, restImportConfig }: { language: s
344350 return decodePart . includes ( "{" ) || decodePart . includes ( "}" )
345351 } ) ;
346352 const filteredParts = firstValidIndex === - 1 ? parts : parts . slice ( 0 , firstValidIndex ) ;
347-
348- const basePathDetails = filteredParts . map ( ( _ , index ) => decodeURIComponent ( "/" + filteredParts . slice ( 0 , index + 1 ) . join ( "/" ) ) ) ;
353+
354+ const basePathDetails : BasePathOption [ ] = [
355+ { label : "None" , value : "/" }
356+ ] ;
357+
358+ for ( let i = 0 ; i < filteredParts . length ; i ++ ) {
359+ const segment = filteredParts . slice ( 0 , i + 1 ) . join ( "/" ) ;
360+ const decodedSegment = decodeURIComponent ( segment ) ;
361+ basePathDetails . push ( {
362+ label : `/${ decodedSegment } ` ,
363+ value : `/${ decodedSegment } `
364+ } ) ;
365+ }
366+
367+
349368 if ( basePathDetails . length > 0 ) {
350- setBasePath ( restImportConfig ?. urlBasePath ? restImportConfig ?. urlBasePath : basePathDetails [ 0 ] ) ;
369+ setBasePath ( restImportConfig ?. urlBasePath ? restImportConfig ?. urlBasePath : basePathDetails [ 1 ] . value ) ;
351370 }
352371 setBasePathList ( basePathDetails )
353372 } catch ( error ) {
@@ -1307,7 +1326,11 @@ export default function RestImport({ language, restImportConfig }: { language: s
13071326 disabled = { basePathEnabled }
13081327 onChange = { handleChangeBasePath }
13091328 >
1310- { basePathList . map ( ( basePath ) => < MenuItem key = { basePath } title = { basePath } value = { basePath } > { basePath } </ MenuItem > ) }
1329+ { basePathList . map ( ( option ) => (
1330+ < MenuItem key = { option . label } title = { option . label } value = { option . value } >
1331+ { option . label }
1332+ </ MenuItem >
1333+ ) ) }
13111334 </ Select >
13121335 </ FormControl >
13131336 </ Stack >
0 commit comments