@@ -10,6 +10,7 @@ import { lightTheme, darkTheme } from "../themes/theme";
1010import { useTranslation } from "react-i18next" ;
1111import SplitPane from "react-split-pane" ;
1212import Transpiler , { SupportedLanguages } from "@json-schema-tools/transpiler" ;
13+ import Dereferencer from "@json-schema-tools/dereferencer" ;
1314import "./MyApp.css" ;
1415import Editor from "@etclabscore/react-monaco-editor" ;
1516import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics" ;
@@ -34,7 +35,13 @@ const defaultSchema = {
3435 title : "foo" ,
3536 type : "number"
3637 }
38+ } ,
39+ baz : {
40+ "$ref" : "#/definitions/baz"
3741 }
42+ } ,
43+ definitions : {
44+ baz : { type : "number" , title : "baz" }
3845 }
3946} ;
4047
@@ -55,8 +62,11 @@ const MyApp: React.FC = () => {
5562 function handleTranspile ( ) {
5663 try {
5764 const result = JSON . parse ( value ) ;
58- const tr = new Transpiler ( result ) ;
59- setResults ( tr . to ( selectedLanguage ) ) ;
65+ const dereffer = new Dereferencer ( result ) ;
66+ dereffer . resolve ( ) . then ( ( schema ) => {
67+ const tr = new Transpiler ( schema ) ;
68+ setResults ( tr . to ( selectedLanguage ) ) ;
69+ } ) ;
6070 } catch ( e ) {
6171 console . error ( e ) ;
6272 }
@@ -100,9 +110,9 @@ const MyApp: React.FC = () => {
100110 < AppBar position = "static" color = "default" elevation = { 0 } >
101111 < Toolbar >
102112 < Grid container alignContent = "center" alignItems = "center" justify = "flex-start" >
103- < Typography variant = "h6" style = { { paddingRight : "20px" } } > { t ( "json-schema.tools" ) } </ Typography >
113+ < Typography variant = "h6" style = { { paddingRight : "20px" } } > { t ( "json-schema.tools" ) as string } </ Typography >
104114 < Typography variant = "caption" style = { { paddingRight : "5px" } } >
105- { t ( "playground" ) }
115+ { t ( "playground" ) as string }
106116 </ Typography >
107117 </ Grid >
108118 < Grid container alignContent = "center" alignItems = "center" justify = "flex-end" >
@@ -130,15 +140,15 @@ const MyApp: React.FC = () => {
130140 </ Menu >
131141 </ >
132142 }
133- < Tooltip title = { t ( "json-schema.tools Github" ) } >
143+ < Tooltip title = { t ( "json-schema.tools Github" ) as string } >
134144 < IconButton
135145 onClick = { ( ) =>
136146 window . open ( "https://github.com/json-schema-tools/" )
137147 } >
138148 < CodeIcon />
139149 </ IconButton >
140150 </ Tooltip >
141- < Tooltip title = { t ( "Toggle Dark Mode" ) } >
151+ < Tooltip title = { t ( "Toggle Dark Mode" ) as string } >
142152 < IconButton onClick = { darkMode . toggle } >
143153 { darkMode . value ? < Brightness3Icon /> : < WbSunnyIcon /> }
144154 </ IconButton >
0 commit comments