@fumadocs/api-docs 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/dist/components/schema/client.d.ts +16 -1
- package/dist/components/schema/client.js +17 -12
- package/dist/components/schema/index.d.ts +13 -20
- package/dist/components/schema/index.js +82 -60
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
- package/dist/ref-parser/bundle.d.ts +10 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/bundle.js +76 -6
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/normalize-args.js +1 -1
- package/dist/ref-parser/options.d.ts +28 -0
- package/dist/ref-parser/options.js +27 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parse.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/json.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/yaml.js +6 -12
- package/dist/ref-parser/pointer.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/pointer.js +24 -53
- package/dist/ref-parser/ref.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/ref.js +6 -48
- package/dist/ref-parser/refs.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/refs.js +4 -41
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolve-external.js +3 -3
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolvers/file.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/types/index.d.ts +8 -40
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/convert-path-to-posix.js +1 -1
- package/dist/ref-parser/util/errors.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/errors.js +16 -34
- package/dist/ref-parser/util/is-windows.js +5 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/maybe.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/next.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/plugins.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/schema-resources.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/url.js +4 -113
- package/dist/schema/bundle.d.ts +1 -1
- package/dist/schema/bundle.js +1 -1
- package/dist/schema/ref.d.ts +3 -1
- package/dist/schema/ref.js +1 -1
- package/dist/schema/sample.js +5 -7
- package/dist/schema/to-string.js +6 -0
- package/dist/utils/cn.js +1 -1
- package/dist/utils/deep-merge.js +8 -0
- package/package.json +18 -17
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts +0 -157
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts +0 -166
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts +0 -96
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts +0 -190
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts +0 -134
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -112
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts +0 -34
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("!isDefined *:data-[collapsible=true]:order-last *:min-w-0 --min-height --radix-popover-content-available-width -mx-3 -translate-x-1/2 -translate-y-1/2 @container @default @fuma-translate/react @fumari/stf @md:grid-cols-2 @param @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-select [&_svg]:size-3.5 a absolute accordion actual additionalProperties again ajv aliasName allOf always an anchor anchorIdStartsWith anchorSegments and animate-spin any anyFields anyOf applicable aria-label array as asSchema autoIds avoid backdrop-blur-sm be behavior bg-black/30 bg-fd-background/50 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-secondary binary block body boolean border border-b border-fd-primary/20 border-t both button buttonVariants catch children class-variance-authority className client clientHeight closed cn code col-span-full collapsible collisionPadding color const content createContext ctx current currentValue cva dark:text-yellow-400 data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[state=closed]:animate-fd-accordion-up data-[state=closed]:animate-fd-dialog-out data-[state=closed]:animate-fd-fade-out data-[state=open]:animate-fd-accordion-down data-[state=open]:animate-fd-dialog-in data-[state=open]:animate-fd-fade-in data-[state=open]:text-fd-accent-foreground data-collapsible data-object-search-input data-placeholder:text-fd-muted-foreground dataEngine decoded default defaultValue deferredValue define delete deprecated depth dereference dereferenceShallow dereferenced description disabled:cursor-not-allowed disabled:opacity-50 display displayName div doc docRoot duplicated duration-200 dynamic element else empty empty:hidden end end-2 engine ensure enum example examples exclusiveMax exclusiveMin export extends fallback false fd-scroll-container field fieldData fieldLabelVariants fieldName fields file files filtered first first:border-t-0 firstItemRef fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring focus-within:[&_svg]:text-fd-primary focus-within:ring-2 focus-within:ring-fd-ring focus:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring focus:text-fd-accent-foreground font-medium font-mono font-semibold for format forwardRef from function gap-0.5 gap-1 gap-1.5 gap-2 gap-4 generate generateDefault generated ghost grid grid-cols-1 group-data-[state=open]/accordion:rotate-90 group/accordion h-10 h-9 h-[240px] h-px hash hidden hiddenProperties highlighted hook hover:bg-fd-accent hover:text-fd-accent-foreground hover:underline htmlFor i icon-sm icon-xs id idx if ignore import in in-popover include index indexItemMatch info infoTags initial inline-flex input inset-0 instanceof integer interface invalid is isDefined isDuplicated isDynamic isLazy isNumber isRequired it item itemId items items-center
|
|
1
|
+
@source inline("!isDefined *:data-[collapsible=true]:order-last *:min-w-0 --min-height --radix-popover-content-available-width -mx-3 -translate-x-1/2 -translate-y-1/2 @container @default @fuma-translate/react @fumari/stf @md:grid-cols-2 @param @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-select [&_svg]:size-3.5 a absolute accordion actual additionalProperties again ajv aliasName allOf always an anchor anchorIdStartsWith anchorSegments and animate-spin any anyFields anyOf applicable aria-label array as asSchema autoIds avoid backdrop-blur-sm be behavior bg-black/30 bg-fd-background/50 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-secondary binary block blocks body boolean border border-b border-fd-primary/20 border-t both button buttonVariants catch children class-variance-authority className client clientHeight closed cn code col-span-full collapsible collisionPadding color const content createContext ctx current currentValue cva dark:text-yellow-400 data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[state=closed]:animate-fd-accordion-up data-[state=closed]:animate-fd-dialog-out data-[state=closed]:animate-fd-fade-out data-[state=open]:animate-fd-accordion-down data-[state=open]:animate-fd-dialog-in data-[state=open]:animate-fd-fade-in data-[state=open]:text-fd-accent-foreground data-collapsible data-object-search-input data-placeholder:text-fd-muted-foreground dataEngine decoded default defaultCode defaultValue deferredValue define delete deprecated depth dereference dereferenceShallow dereferenced description disabled:cursor-not-allowed disabled:opacity-50 display displayName div doc docRoot duplicated duration-200 dynamic element else empty empty:hidden end end-2 engine ensure enum example examples exclusiveMax exclusiveMin export extends fallback false fd-scroll-container field fieldData fieldLabelVariants fieldName fields file files filtered first first:border-t-0 firstItemRef fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring focus-within:[&_svg]:text-fd-primary focus-within:ring-2 focus-within:ring-fd-ring focus:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring focus:text-fd-accent-foreground font-medium font-mono font-semibold for format forwardRef from function gap-0.5 gap-1 gap-1.5 gap-2 gap-4 generate generateDefault generated ghost grid grid-cols-1 group-data-[state=open]/accordion:rotate-90 group/accordion h-10 h-9 h-[240px] h-px hash hidden hiddenProperties highlighted hook hover:bg-fd-accent hover:text-fd-accent-foreground hover:underline htmlFor i icon-sm icon-xs id idx if ignore import in in-popover include index indexItemMatch info infoTags initial inline-flex inlines input inset-0 instanceof integer interface invalid is isDefined isDuplicated isDynamic isLazy isNumber isRequired it item itemId items items-center j json justify-center key kind label labelVariants lang last:border-b-0 lazy leading-none left-1/2 length let line-through list-disc list-inside lucide-react marker:text-fd-muted-foreground matching max max-h-[460px] max-w-(--radix-popover-content-available-width) max-w-full max-w-lg mb-auto md me-auto members merge mergeAllOf mergeRefs min min-h-(--min-height,200px) min-w-0 ms-auto mt-2 multiple must mx-1 my-1 my-2 my-2! name namespace nested never new next node not-prose note null number object objectSearchOverrides objects of omit onChange onClick onKeyDown onOpenAutoFocus onOpenChange onScrollEnd onValueChange oneOf only opacity-80 open opts or order-last out outline outline-none overflow-hidden overflow-x-auto overflow-y-hidden overview p-1 p-1.5 p-2 p-4 param parentItem parentPathIndex part path pathIndex pathName pattern patternProperties pb-0 pe-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-70 placeholder placeholder:text-fd-muted-foreground playground popover popoverRef position prev preventScroll primitive prop properties property props prose-no-margin ps-1 ps-2 ps-3 ps-6 pt-0 px px-2 px-3 px-4 py-0 py-1 py-1.5 py-2 py-4 quiet range raw rawRef rawSearch re-triggering react read readOnly ref refs remove removeItem render renderCodeblock renderMarkdown renderTypeInfoTrigger represents required resize-none resolver return role root rootId rotate-90 rounded-lg rounded-md rounded-sm rounded-xl s-highlight same sample satisfies schema schemaPropKeys schemaToString scroll scroll-m-20 scrollTop search secondary section segments select-none selected selectedType sep setError setInfo setNextName setPath setSearch setShow setValue shadow-lg shadow-md shadow-sm show showExample showSelect shrink-0 simplified single size size-3.5 size-4 skipNonRequired skipReadOnly slotType sm sm:flex-row sm:gap-2 sm:justify-end sm:text-start smooth stable states status step stf sticky store strict string stringifyFieldKey such svg t tab tabDepth tabValues tags target text text-[0.8125rem] text-center text-end text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-secondary-foreground text-lg text-orange-400 text-red-400 text-red-400/80 text-sm text-start text-xs text-yellow-600 that the tiem to toolbar top top-0 top-1/2 top-10 top-2 tracking-tight transition-colors transition-transform translations trigger true truncate try type typeName typeVariants typeof types undefined underline union unionField unknown updateInfo updated url use useAnchorId useCopyButton useFieldValue useMemo useNamespace useObject useRef useState useTranslations validateFormats validateSchema value valueSchema values variant variants w-0 w-[600px] w-fit w-full will with wrap-break-word write writeOnly x-playground-lazy z-20 z-50");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SchemaUIGeneratedData } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/components/schema/client.d.ts
|
|
4
5
|
interface SchemaUIProps {
|
|
@@ -13,5 +14,19 @@ declare function SchemaUI({
|
|
|
13
14
|
as,
|
|
14
15
|
generated
|
|
15
16
|
}: SchemaUIProps): import("react").JSX.Element;
|
|
17
|
+
declare function InlineTag({
|
|
18
|
+
label,
|
|
19
|
+
children
|
|
20
|
+
}: {
|
|
21
|
+
label: ReactNode;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
declare function BlockTag({
|
|
25
|
+
label,
|
|
26
|
+
children
|
|
27
|
+
}: {
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
16
31
|
//#endregion
|
|
17
|
-
export { SchemaUI, SchemaUIProps };
|
|
32
|
+
export { BlockTag, InlineTag, SchemaUI, SchemaUIProps };
|
|
@@ -108,7 +108,7 @@ function SchemaDescription({ schema, ...props }) {
|
|
|
108
108
|
className: cn("prose-no-margin py-2 empty:hidden", props.className),
|
|
109
109
|
children: [schema.description, schema.infoTags && schema.infoTags.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
110
110
|
className: "flex flex-row gap-2 flex-wrap mt-2 not-prose empty:hidden",
|
|
111
|
-
children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(
|
|
111
|
+
children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(Fragment, { children: tag.node }, i))
|
|
112
112
|
})]
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -298,22 +298,27 @@ function ObjectSearchContent({ search: rawSearch, firstItemRef, properties, empt
|
|
|
298
298
|
if (filtered.length === 0) return empty();
|
|
299
299
|
return filtered.map(render);
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
305
|
-
className: "inline-flex text-start items-start gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
|
|
306
|
-
onClick: () => setOpen((prev) => !prev),
|
|
301
|
+
function InlineTag({ label, children }) {
|
|
302
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
303
|
+
className: "inline-flex gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
|
|
307
304
|
children: [/* @__PURE__ */ jsx("span", {
|
|
308
305
|
className: "font-medium",
|
|
309
|
-
children:
|
|
306
|
+
children: label
|
|
310
307
|
}), /* @__PURE__ */ jsx("code", {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
children: tag.value
|
|
308
|
+
className: "min-w-0 flex-1 text-fd-muted-foreground wrap-break-word",
|
|
309
|
+
children
|
|
314
310
|
})]
|
|
315
311
|
});
|
|
316
312
|
}
|
|
313
|
+
function BlockTag({ label, children }) {
|
|
314
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
315
|
+
className: "flex flex-col w-full gap-2 bg-fd-secondary border rounded-lg p-1.5 shadow-md",
|
|
316
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
317
|
+
className: "font-medium text-xs",
|
|
318
|
+
children: label
|
|
319
|
+
}), children]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
317
322
|
function SchemaUIPopover() {
|
|
318
323
|
const states = useStates();
|
|
319
324
|
const { path, setPath } = states;
|
|
@@ -412,4 +417,4 @@ function decodePath(path, highlighted) {
|
|
|
412
417
|
return out;
|
|
413
418
|
}
|
|
414
419
|
//#endregion
|
|
415
|
-
export { SchemaUI };
|
|
420
|
+
export { BlockTag, InlineTag, SchemaUI };
|
|
@@ -3,6 +3,9 @@ import { SchemaUIProps } from "./client.js";
|
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/schema/index.d.ts
|
|
6
|
+
interface InfoTag {
|
|
7
|
+
node: ReactNode;
|
|
8
|
+
}
|
|
6
9
|
interface FieldBase {
|
|
7
10
|
description?: ReactNode;
|
|
8
11
|
infoTags?: InfoTag[];
|
|
@@ -10,10 +13,6 @@ interface FieldBase {
|
|
|
10
13
|
aliasName: string;
|
|
11
14
|
deprecated?: boolean;
|
|
12
15
|
}
|
|
13
|
-
interface InfoTag {
|
|
14
|
-
label: ReactNode;
|
|
15
|
-
value: string;
|
|
16
|
-
}
|
|
17
16
|
interface SchemaDataObjectProperty {
|
|
18
17
|
name: string;
|
|
19
18
|
$type: string;
|
|
@@ -47,6 +46,10 @@ interface SchemaUIOptions {
|
|
|
47
46
|
client: Omit<SchemaUIProps, 'generated'>;
|
|
48
47
|
resolver: SchemaResolver;
|
|
49
48
|
renderMarkdown: (md: string) => ReactNode;
|
|
49
|
+
renderCodeblock: (opts: {
|
|
50
|
+
lang: string;
|
|
51
|
+
code: string;
|
|
52
|
+
}) => ReactNode;
|
|
50
53
|
/**
|
|
51
54
|
* include read only props
|
|
52
55
|
*/
|
|
@@ -66,18 +69,6 @@ interface SchemaUIGeneratedData {
|
|
|
66
69
|
$root: string;
|
|
67
70
|
refs: Record<string, SchemaData>;
|
|
68
71
|
}
|
|
69
|
-
interface SchemaUILabels {
|
|
70
|
-
default: string;
|
|
71
|
-
match: string;
|
|
72
|
-
format: string;
|
|
73
|
-
multipleOf: string;
|
|
74
|
-
range: string;
|
|
75
|
-
length: string;
|
|
76
|
-
properties: string;
|
|
77
|
-
items: string;
|
|
78
|
-
valueIn: string;
|
|
79
|
-
example: string;
|
|
80
|
-
}
|
|
81
72
|
declare function Schema({
|
|
82
73
|
client,
|
|
83
74
|
root,
|
|
@@ -85,18 +76,20 @@ declare function Schema({
|
|
|
85
76
|
writeOnly,
|
|
86
77
|
resolver,
|
|
87
78
|
showExample,
|
|
88
|
-
renderMarkdown
|
|
79
|
+
renderMarkdown,
|
|
80
|
+
renderCodeblock
|
|
89
81
|
}: SchemaUIOptions): import("react").JSX.Element;
|
|
90
82
|
declare function generateSchemaUI({
|
|
91
83
|
root,
|
|
92
84
|
resolver,
|
|
93
85
|
renderMarkdown,
|
|
86
|
+
renderCodeblock,
|
|
94
87
|
readOnly,
|
|
95
88
|
writeOnly,
|
|
96
89
|
showExample,
|
|
97
|
-
|
|
90
|
+
translations
|
|
98
91
|
}: Omit<SchemaUIOptions, 'client'> & {
|
|
99
|
-
|
|
92
|
+
translations?: Partial<Record<string, string>>;
|
|
100
93
|
}): SchemaUIGeneratedData;
|
|
101
94
|
//#endregion
|
|
102
|
-
export { FieldBase,
|
|
95
|
+
export { FieldBase, Schema, SchemaData, SchemaDataObjectProperty, SchemaUIGeneratedData, SchemaUIOptions, generateSchemaUI };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { mergeAllOf } from "../../schema/merge.js";
|
|
3
3
|
import { schemaToString } from "../../schema/to-string.js";
|
|
4
|
-
import { SchemaUI } from "./client.js";
|
|
4
|
+
import { BlockTag, InlineTag, SchemaUI } from "./client.js";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { useTranslations } from "@fuma-translate/react";
|
|
7
|
+
import { fromTranslations, useTranslations } from "@fuma-translate/react";
|
|
8
8
|
//#region src/components/schema/index.tsx
|
|
9
|
-
function Schema({ client, root, readOnly, writeOnly, resolver, showExample, renderMarkdown }) {
|
|
10
|
-
const
|
|
9
|
+
function Schema({ client, root, readOnly, writeOnly, resolver, showExample, renderMarkdown, renderCodeblock }) {
|
|
10
|
+
const translations = useTranslations().translations;
|
|
11
11
|
const generated = useMemo(() => {
|
|
12
12
|
return generateSchemaUI({
|
|
13
13
|
root,
|
|
@@ -16,18 +16,8 @@ function Schema({ client, root, readOnly, writeOnly, resolver, showExample, rend
|
|
|
16
16
|
writeOnly,
|
|
17
17
|
showExample,
|
|
18
18
|
renderMarkdown,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
match: t("Match"),
|
|
22
|
-
format: t("Format"),
|
|
23
|
-
multipleOf: t("Multiple Of"),
|
|
24
|
-
range: t("Range"),
|
|
25
|
-
length: t("Length"),
|
|
26
|
-
properties: t("Properties"),
|
|
27
|
-
items: t("Items"),
|
|
28
|
-
valueIn: t("Value in"),
|
|
29
|
-
example: t("Example")
|
|
30
|
-
}
|
|
19
|
+
renderCodeblock,
|
|
20
|
+
translations
|
|
31
21
|
});
|
|
32
22
|
}, [
|
|
33
23
|
root,
|
|
@@ -36,62 +26,94 @@ function Schema({ client, root, readOnly, writeOnly, resolver, showExample, rend
|
|
|
36
26
|
resolver,
|
|
37
27
|
showExample,
|
|
38
28
|
renderMarkdown,
|
|
39
|
-
|
|
29
|
+
renderCodeblock,
|
|
30
|
+
translations
|
|
40
31
|
]);
|
|
41
32
|
return /* @__PURE__ */ jsx(SchemaUI, {
|
|
42
33
|
...client,
|
|
43
34
|
generated
|
|
44
35
|
});
|
|
45
36
|
}
|
|
46
|
-
function generateSchemaUI({ root, resolver, renderMarkdown, readOnly = false, writeOnly = false, showExample = false,
|
|
37
|
+
function generateSchemaUI({ root, resolver, renderMarkdown, renderCodeblock, readOnly = false, writeOnly = false, showExample = false, translations = {} }) {
|
|
38
|
+
const t = fromTranslations(translations, { note: "schema UI" });
|
|
47
39
|
const refs = {};
|
|
48
40
|
function generateInfoTags(schema) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
label: labels.multipleOf,
|
|
64
|
-
value: schema.multipleOf.toString()
|
|
65
|
-
});
|
|
41
|
+
const inlines = [];
|
|
42
|
+
const blocks = [];
|
|
43
|
+
if (schema.pattern) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
44
|
+
label: t("Match"),
|
|
45
|
+
children: schema.pattern
|
|
46
|
+
}) });
|
|
47
|
+
if (schema.format) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
48
|
+
label: t("Format"),
|
|
49
|
+
children: schema.format
|
|
50
|
+
}) });
|
|
51
|
+
if (schema.multipleOf) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
52
|
+
label: t("Multiple Of"),
|
|
53
|
+
children: schema.multipleOf
|
|
54
|
+
}) });
|
|
66
55
|
let range = formatRange("value", schema.minimum, schema.exclusiveMinimum, schema.maximum, schema.exclusiveMaximum);
|
|
67
|
-
if (range)
|
|
68
|
-
label:
|
|
69
|
-
|
|
70
|
-
});
|
|
56
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
57
|
+
label: t("Range"),
|
|
58
|
+
children: range
|
|
59
|
+
}) });
|
|
71
60
|
range = formatRange("length", schema.minLength, void 0, schema.maxLength, void 0);
|
|
72
|
-
if (range)
|
|
73
|
-
label:
|
|
74
|
-
|
|
75
|
-
});
|
|
61
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
62
|
+
label: t("Length"),
|
|
63
|
+
children: range
|
|
64
|
+
}) });
|
|
76
65
|
range = formatRange("properties", schema.minProperties, void 0, schema.maxProperties, void 0);
|
|
77
|
-
if (range)
|
|
78
|
-
label:
|
|
79
|
-
|
|
80
|
-
});
|
|
66
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
67
|
+
label: t("Properties"),
|
|
68
|
+
children: range
|
|
69
|
+
}) });
|
|
81
70
|
range = formatRange("items", schema.minItems, void 0, schema.maxItems, void 0);
|
|
82
|
-
if (range)
|
|
83
|
-
label:
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
if (schema.enum)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
72
|
+
label: t("Items"),
|
|
73
|
+
children: range
|
|
74
|
+
}) });
|
|
75
|
+
if (schema.enum && schema.enum.length > 0) {
|
|
76
|
+
const members = schema.enum.map((value) => JSON.stringify(value, null, 2));
|
|
77
|
+
blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
78
|
+
label: t("Value in"),
|
|
79
|
+
children: /* @__PURE__ */ jsx("ul", { children: members.map((m, i) => /* @__PURE__ */ jsx("li", {
|
|
80
|
+
className: "font-mono list-disc list-inside ps-1 marker:text-fd-muted-foreground",
|
|
81
|
+
children: m
|
|
82
|
+
}, i)) })
|
|
83
|
+
}) });
|
|
84
|
+
}
|
|
85
|
+
if (schema.default !== void 0) {
|
|
86
|
+
const defaultCode = JSON.stringify(schema.default, null, 2);
|
|
87
|
+
if (defaultCode.includes("\n")) blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
88
|
+
label: t("Default"),
|
|
89
|
+
children: renderCodeblock({
|
|
90
|
+
lang: "json",
|
|
91
|
+
code: defaultCode
|
|
92
|
+
})
|
|
93
|
+
}) });
|
|
94
|
+
else inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
95
|
+
label: t("Default"),
|
|
96
|
+
children: defaultCode
|
|
97
|
+
}) });
|
|
98
|
+
}
|
|
99
|
+
if (showExample && schema.examples) for (const example of schema.examples) {
|
|
100
|
+
const code = JSON.stringify(example, null, 2);
|
|
101
|
+
if (code.includes("\n")) {
|
|
102
|
+
blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
103
|
+
label: t("Example"),
|
|
104
|
+
children: renderCodeblock({
|
|
105
|
+
lang: "json",
|
|
106
|
+
code
|
|
107
|
+
})
|
|
108
|
+
}) });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
112
|
+
label: t("Example"),
|
|
113
|
+
children: code
|
|
114
|
+
}) });
|
|
115
|
+
}
|
|
116
|
+
return [...inlines, ...blocks];
|
|
95
117
|
}
|
|
96
118
|
let _counter = 0;
|
|
97
119
|
const autoIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -185,7 +185,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
185
185
|
return getJsonPointer.call(this, p, schOrRef);
|
|
186
186
|
}
|
|
187
187
|
exports.resolveSchema = resolveSchema;
|
|
188
|
-
const PREVENT_SCOPE_CHANGE = new Set([
|
|
188
|
+
const PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([
|
|
189
189
|
"properties",
|
|
190
190
|
"patternProperties",
|
|
191
191
|
"enum",
|
|
@@ -9,7 +9,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9
9
|
const util_1 = require_util();
|
|
10
10
|
const equal = require_fast_deep_equal();
|
|
11
11
|
const traverse = require_json_schema_traverse();
|
|
12
|
-
const SIMPLE_INLINED = new Set([
|
|
12
|
+
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
13
13
|
"type",
|
|
14
14
|
"format",
|
|
15
15
|
"pattern",
|
|
@@ -34,7 +34,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34
34
|
return countKeys(schema) <= limit;
|
|
35
35
|
}
|
|
36
36
|
exports.inlineRef = inlineRef;
|
|
37
|
-
const REF_KEYWORDS = new Set([
|
|
37
|
+
const REF_KEYWORDS = /* @__PURE__ */ new Set([
|
|
38
38
|
"$ref",
|
|
39
39
|
"$recursiveRef",
|
|
40
40
|
"$recursiveAnchor",
|
|
@@ -3,7 +3,7 @@ import { __commonJSMin } from "../../../../../../../_virtual/_rolldown/runtime.j
|
|
|
3
3
|
var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getRules = exports.isJSONType = void 0;
|
|
6
|
-
const jsonTypes = new Set([
|
|
6
|
+
const jsonTypes = /* @__PURE__ */ new Set([
|
|
7
7
|
"string",
|
|
8
8
|
"number",
|
|
9
9
|
"integer",
|
package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js
CHANGED
|
@@ -49,7 +49,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
49
49
|
return checkTypes;
|
|
50
50
|
}
|
|
51
51
|
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
52
|
-
const COERCIBLE = new Set([
|
|
52
|
+
const COERCIBLE = /* @__PURE__ */ new Set([
|
|
53
53
|
"string",
|
|
54
54
|
"number",
|
|
55
55
|
"integer",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONSchema, SchemaCallback } from "./types/index.js";
|
|
2
|
+
import { BundleOptions, ParserOptions } from "./options.js";
|
|
3
|
+
//#region src/ref-parser/bundle.d.ts
|
|
4
|
+
declare function bundle<S extends object = JSONSchema>(schema: S | string, options?: ParserOptions<S>): Promise<S>;
|
|
5
|
+
declare function bundle<S extends object = JSONSchema>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
6
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
7
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string, options: O): Promise<S>;
|
|
8
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { bundle };
|
|
@@ -1,8 +1,76 @@
|
|
|
1
|
-
import { getHash, resolve, stripHash } from "./util/url.js";
|
|
2
|
-
import {
|
|
1
|
+
import { cwd, fromFileSystemPath, getHash, isFileSystemPath, resolve, stripHash } from "./util/url.js";
|
|
2
|
+
import { JSONParserErrorGroup, isHandledError } from "./util/errors.js";
|
|
3
|
+
import { getSchemaBasePath, registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
3
4
|
import Pointer from "./pointer.js";
|
|
4
5
|
import $Ref from "./ref.js";
|
|
5
|
-
|
|
6
|
+
import $Refs from "./refs.js";
|
|
7
|
+
import parse from "./parse.js";
|
|
8
|
+
import normalizeArgs from "./normalize-args.js";
|
|
9
|
+
import resolveExternal from "./resolve-external.js";
|
|
10
|
+
import maybe from "./util/maybe.js";
|
|
11
|
+
//#region src/ref-parser/bundle.ts
|
|
12
|
+
/**
|
|
13
|
+
* Internal parser state used by the bundle pipeline.
|
|
14
|
+
*/
|
|
15
|
+
var $RefParser = class {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.schema = null;
|
|
18
|
+
this.$refs = new $Refs();
|
|
19
|
+
}
|
|
20
|
+
async parse(path, schema, options) {
|
|
21
|
+
this.schema = null;
|
|
22
|
+
this.$refs = new $Refs();
|
|
23
|
+
if (!path && !schema) throw new Error(`Expected a file path or object. Got ${path || schema}`);
|
|
24
|
+
let pathType = "file";
|
|
25
|
+
if (path && isFileSystemPath(path)) path = fromFileSystemPath(path);
|
|
26
|
+
path = resolve(cwd(), path || "");
|
|
27
|
+
if (schema && typeof schema === "object") {
|
|
28
|
+
const $ref = this.$refs._add(path);
|
|
29
|
+
$ref.value = schema;
|
|
30
|
+
$ref.pathType = pathType;
|
|
31
|
+
$ref.dynamicIdScope = usesDynamicIdScope($ref.value);
|
|
32
|
+
registerSchemaResources(this.$refs, $ref.path, $ref.value, $ref.pathType, $ref.dynamicIdScope);
|
|
33
|
+
this.schema = schema;
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const result = await parse(path, this.$refs, options);
|
|
38
|
+
if (result !== null && typeof result === "object" && !Buffer.isBuffer(result)) {
|
|
39
|
+
this.schema = result;
|
|
40
|
+
return this.schema;
|
|
41
|
+
}
|
|
42
|
+
throw new SyntaxError(`"${this.$refs._root$Ref.path || result}" is not a valid JSON Schema`);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (!options.continueOnError || !isHandledError(err)) throw err;
|
|
45
|
+
if (this.$refs._$refs[stripHash(path)]) this.$refs._$refs[stripHash(path)].addError(err);
|
|
46
|
+
this.schema = null;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async resolve(path, schema, options) {
|
|
51
|
+
await this.parse(path, schema, options);
|
|
52
|
+
await resolveExternal(this, options);
|
|
53
|
+
finalize(this);
|
|
54
|
+
return this.$refs;
|
|
55
|
+
}
|
|
56
|
+
async runBundle(path, schema, options, callback) {
|
|
57
|
+
try {
|
|
58
|
+
await this.resolve(path, schema, options);
|
|
59
|
+
inlineRefs(this, options);
|
|
60
|
+
finalize(this);
|
|
61
|
+
return maybe(callback, Promise.resolve(this.schema));
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return maybe(callback, Promise.reject(err));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function finalize(parser) {
|
|
68
|
+
if (JSONParserErrorGroup.getParserErrors(parser).length > 0) throw new JSONParserErrorGroup(parser);
|
|
69
|
+
}
|
|
70
|
+
async function bundle() {
|
|
71
|
+
const args = normalizeArgs(arguments);
|
|
72
|
+
return new $RefParser().runBundle(args.path, args.schema, args.options, args.callback);
|
|
73
|
+
}
|
|
6
74
|
/**
|
|
7
75
|
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
8
76
|
* only has *internal* references, not any *external* references.
|
|
@@ -11,7 +79,7 @@ import $Ref from "./ref.js";
|
|
|
11
79
|
* @param parser
|
|
12
80
|
* @param options
|
|
13
81
|
*/
|
|
14
|
-
function
|
|
82
|
+
function inlineRefs(parser, options) {
|
|
15
83
|
const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
|
|
16
84
|
const inventory = [];
|
|
17
85
|
crawl(parser, "schema", parser.$refs._root$Ref.path + "#", rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, "#", 0, inventory, parser.$refs, options);
|
|
@@ -79,6 +147,7 @@ function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pat
|
|
|
79
147
|
const file = stripHash(pointer.path);
|
|
80
148
|
const hash = getHash(pointer.path);
|
|
81
149
|
const external = file !== $refs._root$Ref.path && !$refs._aliases[file];
|
|
150
|
+
const nestedResource = Boolean($refs._aliases[file]) && pointer.$ref.value !== $refs._root$Ref.value;
|
|
82
151
|
const extended = $Ref.isExtended$Ref($ref);
|
|
83
152
|
indirections += pointer.indirections;
|
|
84
153
|
const existingEntry = findInInventory(inventory, $refParent, $refKey);
|
|
@@ -96,6 +165,7 @@ function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pat
|
|
|
96
165
|
circular: pointer.circular,
|
|
97
166
|
extended,
|
|
98
167
|
external,
|
|
168
|
+
nestedResource,
|
|
99
169
|
indirections
|
|
100
170
|
});
|
|
101
171
|
if (!existingEntry || external) crawl(pointer.value, null, pointer.path, pointer.$ref.path, pointer.$ref.dynamicIdScope, pathFromRoot, indirections + 1, inventory, $refs, options);
|
|
@@ -141,7 +211,7 @@ function remap(inventory, options, rootId) {
|
|
|
141
211
|
for (const entry of inventory) {
|
|
142
212
|
const bundleOpts = options.bundle || {};
|
|
143
213
|
if (!entry.external) {
|
|
144
|
-
if (bundleOpts.optimizeInternalRefs !== false) entry.$ref.$ref = entry.hash;
|
|
214
|
+
if (bundleOpts.optimizeInternalRefs !== false && !entry.nestedResource) entry.$ref.$ref = entry.hash;
|
|
145
215
|
} else if (entry.file === file && entry.hash === hash) if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + pathFromRoot;
|
|
146
216
|
else entry.$ref.$ref = pathFromRoot;
|
|
147
217
|
else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
|
|
@@ -236,4 +306,4 @@ function isInsideIdScope(inventory, entry) {
|
|
|
236
306
|
return false;
|
|
237
307
|
}
|
|
238
308
|
//#endregion
|
|
239
|
-
export { bundle
|
|
309
|
+
export { bundle };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNewOptions } from "./options.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/normalize-args.ts
|
|
3
3
|
/**
|
|
4
4
|
* Normalizes the given arguments, accounting for optional args.
|
|
5
5
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ref-parser/options.d.ts
|
|
4
|
+
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
5
|
+
interface BundleOptions {
|
|
6
|
+
excludedPathMatcher?(path: string): boolean;
|
|
7
|
+
onBundle?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
|
|
8
|
+
optimizeInternalRefs?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface $RefParserOptions<S extends object = JSONSchema> {
|
|
11
|
+
parse: {
|
|
12
|
+
json?: Plugin | boolean;
|
|
13
|
+
yaml?: Plugin | boolean;
|
|
14
|
+
[key: string]: Plugin | boolean | undefined;
|
|
15
|
+
};
|
|
16
|
+
resolve: {
|
|
17
|
+
external?: boolean;
|
|
18
|
+
file?: Partial<ResolverOptions<S>> | boolean;
|
|
19
|
+
} & {
|
|
20
|
+
[key: string]: Partial<ResolverOptions<S>> | boolean | undefined;
|
|
21
|
+
};
|
|
22
|
+
continueOnError: boolean;
|
|
23
|
+
bundle: BundleOptions;
|
|
24
|
+
mutateInputSchema?: boolean;
|
|
25
|
+
}
|
|
26
|
+
type ParserOptions<S extends object = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { BundleOptions, ParserOptions };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mergeDeep } from "../utils/deep-merge.js";
|
|
2
|
+
import json_default from "./parsers/json.js";
|
|
3
|
+
import yaml_default from "./parsers/yaml.js";
|
|
4
|
+
import file_default from "./resolvers/file.js";
|
|
5
|
+
//#region src/ref-parser/options.ts
|
|
6
|
+
const getJsonSchemaRefParserDefaultOptions = () => {
|
|
7
|
+
return {
|
|
8
|
+
parse: {
|
|
9
|
+
json: { ...json_default },
|
|
10
|
+
yaml: { ...yaml_default }
|
|
11
|
+
},
|
|
12
|
+
resolve: {
|
|
13
|
+
file: { ...file_default },
|
|
14
|
+
external: true
|
|
15
|
+
},
|
|
16
|
+
continueOnError: false,
|
|
17
|
+
bundle: { excludedPathMatcher: () => false },
|
|
18
|
+
mutateInputSchema: true
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const getNewOptions = (options) => {
|
|
22
|
+
const defaults = getJsonSchemaRefParserDefaultOptions();
|
|
23
|
+
if (!options) return defaults;
|
|
24
|
+
return mergeDeep(defaults, options);
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getNewOptions };
|
|
@@ -2,7 +2,7 @@ import { getExtension } from "./util/url.js";
|
|
|
2
2
|
import { ParserError, ResolverError, UnmatchedParserError, UnmatchedResolverError, isHandledError } from "./util/errors.js";
|
|
3
3
|
import { registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
4
4
|
import { all, filter, run, sort } from "./util/plugins.js";
|
|
5
|
-
//#region
|
|
5
|
+
//#region src/ref-parser/parse.ts
|
|
6
6
|
/**
|
|
7
7
|
* Reads and parses the specified file path or URL.
|
|
8
8
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/parsers/json.ts
|
|
3
3
|
var json_default = {
|
|
4
4
|
/**
|
|
5
5
|
* The order that this parser will run, in relation to other parsers.
|