1- import path from 'node:path' ;
2-
31import { type IRuleResult } from '@stoplight/spectral-core' ;
42import CodeMirror from 'codemirror' ;
53import type { OpenAPIV3 } from 'openapi-types' ;
@@ -86,11 +84,13 @@ export async function clientLoader({ params }: Route.ClientLoaderArgs) {
8684
8785 const workspaceMeta = await services . workspaceMeta . getByParentId ( workspaceId ) ;
8886
89- const gitRepositoryId = models . project . isGitProject ( project ) ? project . gitRepositoryId : workspaceMeta ?. gitRepositoryId ;
87+ const gitRepositoryId = models . project . isGitProject ( project )
88+ ? project . gitRepositoryId
89+ : workspaceMeta ?. gitRepositoryId ;
9090 // we don't run the lint here because it is expensive and slows first render too much
9191 // TODO: add this in once we run this loader outside the renderer
9292 const rulesetPath = gitRepositoryId
93- ? path . join ( window . app . getPath ( 'userData' ) , `version-control/git/${ gitRepositoryId } /other/.spectral.yaml` )
93+ ? window . path . join ( window . app . getPath ( 'userData' ) , `version-control/git/${ gitRepositoryId } /other/.spectral.yaml` )
9494 : '' ;
9595
9696 let parsedSpec : OpenAPIV3 . Document | undefined ;
@@ -373,8 +373,7 @@ const Component = ({ params }: Route.ComponentProps) => {
373373 let parsedSpec : string | undefined ;
374374 try {
375375 // yaml parses json correctly
376- parsedSpec = YAML . parse ( editorValue )
377-
376+ parsedSpec = YAML . parse ( editorValue ) ;
378377 } catch {
379378 showToast ( {
380379 title : 'Failed to convert spec format' ,
@@ -387,8 +386,7 @@ const Component = ({ params }: Route.ComponentProps) => {
387386 const contents = to === 'json' ? JSON . stringify ( parsedSpec , null , 2 ) : YAML . stringify ( parsedSpec ) ;
388387 editor . current ?. setValue ( contents ) ;
389388 updateApiSpec ( { organizationId, projectId, workspaceId, contents } ) ;
390-
391- }
389+ } ;
392390
393391 const specActionList : SpecActionItem [ ] = [
394392 {
@@ -417,17 +415,25 @@ const Component = ({ params }: Route.ComponentProps) => {
417415 setIsSpecPaneOpen ( ! isSpecPaneOpen ) ;
418416 } ,
419417 } ,
420- ...( specFormat === 'json' ? [ {
421- id : 'convert-to-yaml' ,
422- name : 'Convert to YAML' ,
423- icon : < Icon className = "w-3" icon = "sync-alt" /> ,
424- action : ( ) => switchFormat ( 'yaml' ) ,
425- } ] : specFormat === 'yaml' ? [ {
426- id : 'convert-to-json' ,
427- name : 'Convert to JSON' ,
428- icon : < Icon className = "w-3" icon = "sync-alt" /> ,
429- action : ( ) => switchFormat ( 'json' ) ,
430- } ] : [ ] ) ,
418+ ...( specFormat === 'json'
419+ ? [
420+ {
421+ id : 'convert-to-yaml' ,
422+ name : 'Convert to YAML' ,
423+ icon : < Icon className = "w-3" icon = "sync-alt" /> ,
424+ action : ( ) => switchFormat ( 'yaml' ) ,
425+ } ,
426+ ]
427+ : specFormat === 'yaml'
428+ ? [
429+ {
430+ id : 'convert-to-json' ,
431+ name : 'Convert to JSON' ,
432+ icon : < Icon className = "w-3" icon = "sync-alt" /> ,
433+ action : ( ) => switchFormat ( 'json' ) ,
434+ } ,
435+ ]
436+ : [ ] ) ,
431437 ] ;
432438
433439 const disabledKeys = specActionList . filter ( item => item . isDisabled ) . map ( item => item . id ) ;
0 commit comments