Skip to content

Commit 344756f

Browse files
committed
Schema fixes
1 parent 547a512 commit 344756f

File tree

3 files changed

+24028
-1091
lines changed

3 files changed

+24028
-1091
lines changed

src/jsonschema.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { InputConfig } from "./types";
22

3+
type Whitespace = " " | "\t" | "\n" | "\r";
4+
35
type With$fn<T> = {
46
[K in keyof T]:
57
| (T[K] extends (infer U)[]
68
? With$fn<U>[] // handle arrays recursively
79
: T[K] extends object
8-
? With$fn<T[K]> // handle objects recursively
9-
: T[K]) // retain original type
10-
| (string & `$ex ${string}`)
11-
| (string & `$fn ${string}`); // allow string starting with $ex or $fn
10+
? With$fn<T[K]> // handle objects recursively
11+
: T[K]) // retain original type
12+
| (string & `${Whitespace | ""}$ex${Whitespace}${string}`)
13+
| (string & `${Whitespace | ""}$fn${Whitespace}${string}`); // allow string starting with $ex or $fn with optional whitespace
1214
};
1315

14-
export type JsonSchemaRoot = With$fn<InputConfig>
16+
export type JsonSchemaRoot = With$fn<InputConfig>;

yaml-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "npm run schema && webpack serve --open --mode development",
88
"build": "npm run schema &&rm -rf dist && webpack --mode production",
9-
"schema": "cd .. && typescript-json-schema --noExtraProps tsconfig.json InputConfig > yaml-editor/src/schema.json",
9+
"schema": "cd .. && typescript-json-schema --required tsconfig.json JsonSchemaRoot > yaml-editor/src/schema.json",
1010
"deploy": "pnpm run build && gh-pages -d dist"
1111
},
1212
"dependencies": {

0 commit comments

Comments
 (0)