WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 907d4db

Browse files
committed
Fix online converter
1 parent aa12f0e commit 907d4db

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

online/src/App.bs.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function App(props) {
1818
var match$1 = React.useState(function () {
1919
return "";
2020
});
21-
var setInlineStruct = match$1[1];
22-
var inlinedStruct = match$1[0];
21+
var setInlinedRescriptSchema = match$1[1];
22+
var inlinedRescriptSchema = match$1[0];
2323
var match$2 = React.useState(function () {
2424
return "";
2525
});
@@ -32,8 +32,8 @@ function App(props) {
3232
setErrors(function (param) {
3333
return "";
3434
});
35-
setInlineStruct(function (param) {
36-
return S$RescriptSchema.inline(JSONSchema.toStruct(parsed));
35+
setInlinedRescriptSchema(function (param) {
36+
return S$RescriptSchema.inline(JSONSchema.toRescriptSchema(parsed));
3737
});
3838
return ;
3939
}
@@ -62,7 +62,7 @@ function App(props) {
6262
});
6363
}
6464
};
65-
var tmp = errors === "" ? inlinedStruct : errors;
65+
var tmp = errors === "" ? inlinedRescriptSchema : errors;
6666
return JsxRuntime.jsxs(JsxRuntime.Fragment, {
6767
children: [
6868
JsxRuntime.jsx("h1", {
@@ -126,7 +126,7 @@ function App(props) {
126126
},
127127
disabled: errors !== "",
128128
onClick: (function (param) {
129-
CopyToClipboard(inlinedStruct);
129+
CopyToClipboard(inlinedRescriptSchema);
130130
})
131131
})
132132
],

online/src/App.res

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let make = () => {
3434
"required": ["Id", "Title", "Rating"]
3535
}`
3636
)
37-
let (inlinedStruct, setInlineStruct) = React.useState(() => "")
37+
let (inlinedRescriptSchema, setInlinedRescriptSchema) = React.useState(() => "")
3838
let (errors, setErrors) = React.useState(() => "")
3939

4040
React.useEffect1(() => {
@@ -44,9 +44,9 @@ let make = () => {
4444
let parsed = parseJson5(json)
4545
setErrors(_ => "")
4646
// TODO: Fix refs resolver in the browser environment
47-
// let schema = await parsed->(magic: Js.Json.t => JSONSchema.t)->resolveRefs
48-
let schema = parsed->(magic: Js.Json.t => JSONSchema.t)
49-
setInlineStruct(_ => schema->JSONSchema.toStruct->S.inline)->ignore
47+
// let jsonSchema = await parsed->(magic: Js.Json.t => JSONSchema.t)->resolveRefs
48+
let jsonSchema = parsed->(magic: Js.Json.t => JSONSchema.t)
49+
setInlinedRescriptSchema(_ => jsonSchema->JSONSchema.toRescriptSchema->S.inline)->ignore
5050
} catch {
5151
| exn =>
5252
setErrors(_ =>
@@ -115,12 +115,15 @@ let make = () => {
115115
color: errors === "" ? "black" : "red",
116116
}
117117
value={switch errors {
118-
| "" => inlinedStruct
118+
| "" => inlinedRescriptSchema
119119
| _ => errors
120120
}}
121121
readOnly=true
122122
/>
123-
<button style={{width: "100%"}} disabled={errors !== ""} onClick={_ => copy(inlinedStruct)}>
123+
<button
124+
style={{width: "100%"}}
125+
disabled={errors !== ""}
126+
onClick={_ => copy(inlinedRescriptSchema)}>
124127
{React.string("Copy")}
125128
</button>
126129
</div>

0 commit comments

Comments
 (0)