@scalar/api-reference 1.31.0 → 1.31.1
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/CHANGELOG.md +8 -0
- package/dist/browser/standalone.js +2030 -1927
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/Content/Models/Models.vue.d.ts.map +1 -1
- package/dist/components/Content/Models/Models.vue.js +1 -1
- package/dist/components/Content/Models/Models.vue2.js +2 -1
- package/dist/components/Content/Schema/Schema.preview.d.ts +252 -84
- package/dist/components/Content/Schema/Schema.preview.d.ts.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.d.ts +17 -3
- package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.js +2 -2
- package/dist/components/Content/Schema/Schema.vue2.js +146 -128
- package/dist/components/Content/Schema/SchemaComposition.vue.d.ts +2 -2
- package/dist/components/Content/Schema/SchemaComposition.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaDiscriminator.vue.d.ts +2 -3
- package/dist/components/Content/Schema/SchemaDiscriminator.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaDiscriminator.vue.js +29 -29
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts +10 -3
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.js +2 -2
- package/dist/components/Content/Schema/SchemaProperty.vue2.js +129 -101
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts +2 -2
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue.js +1 -1
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue2.js +122 -115
- package/dist/components/Layouts/ClassicLayout.vue.d.ts.map +1 -1
- package/dist/components/Layouts/ClassicLayout.vue.js +11 -11
- package/dist/components/Section/SectionAccordion.vue.d.ts.map +1 -1
- package/dist/components/Section/SectionAccordion.vue.js +2 -2
- package/dist/components/Section/SectionAccordion.vue2.js +1 -1
- package/dist/components/Section/SectionContainerAccordion.vue.d.ts.map +1 -1
- package/dist/components/Section/SectionContainerAccordion.vue.js +2 -2
- package/dist/components/Section/SectionContainerAccordion.vue2.js +4 -4
- package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts +2 -0
- package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
- package/dist/features/ExampleRequest/ExampleRequest.vue.js +2 -2
- package/dist/features/ExampleRequest/ExampleRequest.vue2.js +178 -127
- package/dist/features/Operation/Operation.vue.d.ts.map +1 -1
- package/dist/features/Operation/Operation.vue.js +29 -23
- package/dist/features/Operation/components/OperationParameters.vue.d.ts +7 -3
- package/dist/features/Operation/components/OperationParameters.vue.d.ts.map +1 -1
- package/dist/features/Operation/components/OperationParameters.vue.js +28 -24
- package/dist/features/Operation/components/RequestBody.vue.d.ts +5 -1
- package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.js +2 -2
- package/dist/features/Operation/components/RequestBody.vue2.js +41 -36
- package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts +5 -1
- package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts.map +1 -1
- package/dist/features/Operation/layouts/ClassicLayout.vue.js +2 -2
- package/dist/features/Operation/layouts/ClassicLayout.vue2.js +79 -74
- package/dist/features/Operation/layouts/ModernLayout.vue.d.ts +5 -1
- package/dist/features/Operation/layouts/ModernLayout.vue.d.ts.map +1 -1
- package/dist/features/Operation/layouts/ModernLayout.vue.js +2 -2
- package/dist/features/Operation/layouts/ModernLayout.vue2.js +63 -57
- package/dist/hooks/useDiscriminator.d.ts +53 -0
- package/dist/hooks/useDiscriminator.d.ts.map +1 -0
- package/dist/hooks/useDiscriminator.js +149 -0
- package/dist/hooks/useOperationDiscriminator.d.ts +8 -0
- package/dist/hooks/useOperationDiscriminator.d.ts.map +1 -0
- package/dist/hooks/useOperationDiscriminator.js +57 -0
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +6 -6
- package/dist/components/Content/Schema/helpers/schema-discriminator.d.ts +0 -12
- package/dist/components/Content/Schema/helpers/schema-discriminator.d.ts.map +0 -1
- package/dist/components/Content/Schema/helpers/schema-discriminator.js +0 -45
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ScalarMarkdown as
|
|
3
|
-
import
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { getOperationStability as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
const
|
|
1
|
+
import { defineComponent as k, useId as C, computed as V, createBlock as t, openBlock as n, unref as o, withCtx as r, createVNode as a, createCommentVNode as u, createElementVNode as i, normalizeClass as f, createTextVNode as h, toDisplayString as b } from "vue";
|
|
2
|
+
import { ScalarMarkdown as B, ScalarErrorBoundary as l } from "@scalar/components";
|
|
3
|
+
import w from "../../../components/OperationPath.vue.js";
|
|
4
|
+
import { useConfig as E } from "../../../hooks/useConfig.js";
|
|
5
|
+
import { getOperationStability as g, getOperationStabilityColor as N, isOperationDeprecated as T } from "../../../libs/openapi.js";
|
|
6
|
+
import D from "../components/callbacks/Callbacks.vue.js";
|
|
7
|
+
import I from "../components/OperationParameters.vue.js";
|
|
8
|
+
import P from "../components/OperationResponses.vue.js";
|
|
9
|
+
import R from "../../../components/Section/Section.vue.js";
|
|
10
|
+
import $ from "../../../components/Section/SectionContent.vue.js";
|
|
11
|
+
import q from "../../../components/Badge/Badge.vue.js";
|
|
12
|
+
import A from "../../../components/Section/SectionHeader.vue.js";
|
|
13
|
+
import H from "../../../components/Anchor/Anchor.vue.js";
|
|
14
|
+
import L from "../../../components/Section/SectionHeaderTag.vue.js";
|
|
15
|
+
import M from "../../../components/Section/SectionColumns.vue.js";
|
|
16
|
+
import v from "../../../components/Section/SectionColumn.vue.js";
|
|
17
|
+
import U from "../../ExampleRequest/ExampleRequest.vue.js";
|
|
18
|
+
import _ from "../../TestRequestButton/TestRequestButton.vue.js";
|
|
19
|
+
import z from "../../ExampleResponses/ExampleResponses.vue.js";
|
|
20
|
+
const j = { class: "operation-details" }, F = { class: "examples" }, de = /* @__PURE__ */ k({
|
|
21
21
|
__name: "ModernLayout",
|
|
22
22
|
props: {
|
|
23
23
|
id: {},
|
|
@@ -27,43 +27,46 @@ const M = { class: "operation-details" }, z = { class: "examples" }, se = /* @__
|
|
|
27
27
|
transformedOperation: {},
|
|
28
28
|
schemas: {}
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
emits: ["update:modelValue"],
|
|
31
|
+
setup(s, { emit: y }) {
|
|
32
|
+
const O = y, m = C(), S = E(), p = V(() => s.operation.summary || s.operation.path), d = (e) => {
|
|
33
|
+
O("update:modelValue", e);
|
|
34
|
+
};
|
|
35
|
+
return (e, G) => (n(), t(o(R), {
|
|
33
36
|
id: e.id,
|
|
34
|
-
"aria-labelledby": o(
|
|
35
|
-
label:
|
|
37
|
+
"aria-labelledby": o(m),
|
|
38
|
+
label: p.value,
|
|
36
39
|
tabindex: "-1"
|
|
37
40
|
}, {
|
|
38
41
|
default: r(() => [
|
|
39
|
-
a(o(
|
|
40
|
-
loading: o(
|
|
42
|
+
a(o($), {
|
|
43
|
+
loading: o(S).isLoading
|
|
41
44
|
}, {
|
|
42
45
|
default: r(() => [
|
|
43
|
-
o(
|
|
46
|
+
o(g)(e.operation) ? (n(), t(o(q), {
|
|
44
47
|
key: 0,
|
|
45
|
-
class: f(o(
|
|
48
|
+
class: f(o(N)(e.operation))
|
|
46
49
|
}, {
|
|
47
50
|
default: r(() => [
|
|
48
|
-
|
|
51
|
+
h(b(o(g)(e.operation)), 1)
|
|
49
52
|
]),
|
|
50
53
|
_: 1
|
|
51
|
-
}, 8, ["class"])) :
|
|
54
|
+
}, 8, ["class"])) : u("", !0),
|
|
52
55
|
i("div", {
|
|
53
|
-
class: f(o(
|
|
56
|
+
class: f(o(T)(e.operation) ? "deprecated" : "")
|
|
54
57
|
}, [
|
|
55
|
-
a(o(
|
|
58
|
+
a(o(A), null, {
|
|
56
59
|
default: r(() => [
|
|
57
|
-
a(o(
|
|
60
|
+
a(o(H), {
|
|
58
61
|
id: e.id ?? ""
|
|
59
62
|
}, {
|
|
60
63
|
default: r(() => [
|
|
61
|
-
a(o(
|
|
62
|
-
id: o(
|
|
64
|
+
a(o(L), {
|
|
65
|
+
id: o(m),
|
|
63
66
|
level: 3
|
|
64
67
|
}, {
|
|
65
68
|
default: r(() => [
|
|
66
|
-
|
|
69
|
+
h(b(p.value), 1)
|
|
67
70
|
]),
|
|
68
71
|
_: 1
|
|
69
72
|
}, 8, ["id"])
|
|
@@ -74,34 +77,35 @@ const M = { class: "operation-details" }, z = { class: "examples" }, se = /* @__
|
|
|
74
77
|
_: 1
|
|
75
78
|
})
|
|
76
79
|
], 2),
|
|
77
|
-
a(o(
|
|
80
|
+
a(o(M), null, {
|
|
78
81
|
default: r(() => [
|
|
79
|
-
a(o(
|
|
82
|
+
a(o(v), null, {
|
|
80
83
|
default: r(() => [
|
|
81
|
-
i("div",
|
|
82
|
-
a(o(
|
|
84
|
+
i("div", j, [
|
|
85
|
+
a(o(B), {
|
|
83
86
|
value: e.operation.description,
|
|
84
87
|
withImages: "",
|
|
85
88
|
withAnchors: "",
|
|
86
89
|
transformType: "heading",
|
|
87
90
|
anchorPrefix: e.id
|
|
88
91
|
}, null, 8, ["value", "anchorPrefix"]),
|
|
89
|
-
a(
|
|
92
|
+
a(I, {
|
|
90
93
|
operation: e.operation,
|
|
91
|
-
schemas: e.schemas
|
|
94
|
+
schemas: e.schemas,
|
|
95
|
+
"onUpdate:modelValue": d
|
|
92
96
|
}, null, 8, ["operation", "schemas"]),
|
|
93
|
-
a(
|
|
97
|
+
a(P, {
|
|
94
98
|
operation: e.transformedOperation,
|
|
95
99
|
schemas: e.schemas
|
|
96
100
|
}, null, 8, ["operation", "schemas"]),
|
|
97
101
|
a(o(l), null, {
|
|
98
102
|
default: r(() => [
|
|
99
|
-
e.operation.callbacks ? (n(), t(
|
|
103
|
+
e.operation.callbacks ? (n(), t(D, {
|
|
100
104
|
key: 0,
|
|
101
105
|
callbacks: e.operation.callbacks,
|
|
102
106
|
collection: e.collection,
|
|
103
107
|
schemas: e.schemas
|
|
104
|
-
}, null, 8, ["callbacks", "collection", "schemas"])) :
|
|
108
|
+
}, null, 8, ["callbacks", "collection", "schemas"])) : u("", !0)
|
|
105
109
|
]),
|
|
106
110
|
_: 1
|
|
107
111
|
})
|
|
@@ -109,39 +113,41 @@ const M = { class: "operation-details" }, z = { class: "examples" }, se = /* @__
|
|
|
109
113
|
]),
|
|
110
114
|
_: 1
|
|
111
115
|
}),
|
|
112
|
-
a(o(
|
|
116
|
+
a(o(v), null, {
|
|
113
117
|
default: r(() => [
|
|
114
|
-
i("div",
|
|
118
|
+
i("div", F, [
|
|
115
119
|
a(o(l), null, {
|
|
116
120
|
default: r(() => [
|
|
117
|
-
a(o(
|
|
121
|
+
a(o(U), {
|
|
118
122
|
collection: e.collection,
|
|
119
123
|
fallback: "",
|
|
120
124
|
operation: e.operation,
|
|
121
125
|
server: e.server,
|
|
122
|
-
transformedOperation: e.transformedOperation
|
|
126
|
+
transformedOperation: e.transformedOperation,
|
|
127
|
+
schemas: e.schemas,
|
|
128
|
+
"onUpdate:modelValue": d
|
|
123
129
|
}, {
|
|
124
130
|
header: r(() => {
|
|
125
|
-
var
|
|
131
|
+
var c;
|
|
126
132
|
return [
|
|
127
|
-
a(
|
|
133
|
+
a(w, {
|
|
128
134
|
class: "example-path",
|
|
129
|
-
deprecated: (
|
|
135
|
+
deprecated: (c = e.transformedOperation.information) == null ? void 0 : c.deprecated,
|
|
130
136
|
path: e.transformedOperation.path
|
|
131
137
|
}, null, 8, ["deprecated", "path"])
|
|
132
138
|
];
|
|
133
139
|
}),
|
|
134
140
|
footer: r(() => [
|
|
135
|
-
a(o(
|
|
141
|
+
a(o(_), { operation: e.operation }, null, 8, ["operation"])
|
|
136
142
|
]),
|
|
137
143
|
_: 1
|
|
138
|
-
}, 8, ["collection", "operation", "server", "transformedOperation"])
|
|
144
|
+
}, 8, ["collection", "operation", "server", "transformedOperation", "schemas"])
|
|
139
145
|
]),
|
|
140
146
|
_: 1
|
|
141
147
|
}),
|
|
142
148
|
a(o(l), null, {
|
|
143
149
|
default: r(() => [
|
|
144
|
-
a(o(
|
|
150
|
+
a(o(z), {
|
|
145
151
|
responses: e.operation.responses,
|
|
146
152
|
style: { "margin-top": "12px" }
|
|
147
153
|
}, null, 8, ["responses"])
|
|
@@ -164,5 +170,5 @@ const M = { class: "operation-details" }, z = { class: "examples" }, se = /* @__
|
|
|
164
170
|
}
|
|
165
171
|
});
|
|
166
172
|
export {
|
|
167
|
-
|
|
173
|
+
de as default
|
|
168
174
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Schemas } from '../features/Operation/types/schemas';
|
|
2
|
+
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
3
|
+
import { type InjectionKey, type ComputedRef } from 'vue';
|
|
4
|
+
/** Discriminator context type */
|
|
5
|
+
export type DiscriminatorContext = {
|
|
6
|
+
selectedType: string | undefined;
|
|
7
|
+
discriminatorMapping: Record<string, string>;
|
|
8
|
+
discriminatorPropertyName: string;
|
|
9
|
+
hasDiscriminator: boolean;
|
|
10
|
+
mergedSchema: OpenAPIV3_1.SchemaObject | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** Example context type */
|
|
13
|
+
export type ExampleContext = {
|
|
14
|
+
generateExampleValue: (isArray?: boolean) => any;
|
|
15
|
+
};
|
|
16
|
+
/** Injection keys */
|
|
17
|
+
export declare const DISCRIMINATOR_CONTEXT: InjectionKey<ComputedRef<DiscriminatorContext | null>>;
|
|
18
|
+
export declare const EXAMPLE_CONTEXT: InjectionKey<ExampleContext>;
|
|
19
|
+
/** Discriminator mapping */
|
|
20
|
+
export type DiscriminatorMapping = NonNullable<OpenAPIV3_1.DiscriminatorObject['mapping']>;
|
|
21
|
+
/** Discriminator property name */
|
|
22
|
+
export type DiscriminatorPropertyName = OpenAPIV3_1.DiscriminatorObject['propertyName'];
|
|
23
|
+
/** Use discriminator options */
|
|
24
|
+
export type UseDiscriminatorOptions = {
|
|
25
|
+
schema: OpenAPIV3_1.SchemaObject | undefined;
|
|
26
|
+
schemas?: Schemas;
|
|
27
|
+
onSchemaChange?: (newSchema: OpenAPIV3_1.SchemaObject) => void;
|
|
28
|
+
};
|
|
29
|
+
/** Get discriminator mapping from schema */
|
|
30
|
+
export declare function getDiscriminatorMapping(schema: OpenAPIV3_1.SchemaObject | undefined): DiscriminatorMapping | undefined;
|
|
31
|
+
/** Get discriminator property name from schema */
|
|
32
|
+
export declare function getDiscriminatorPropertyName(schema: OpenAPIV3_1.SchemaObject | undefined): DiscriminatorPropertyName | undefined;
|
|
33
|
+
/** Check if schema has a discriminator */
|
|
34
|
+
export declare function hasDiscriminator(schema: OpenAPIV3_1.SchemaObject | undefined): boolean;
|
|
35
|
+
/** Get base discriminator schema name by matching discriminator property */
|
|
36
|
+
export declare function getBaseDiscriminatorSchemaName(discriminatorPropertyName: string, schemas?: Schemas): string | null;
|
|
37
|
+
/** Get base discriminator schema name for array items that might reference a discriminator schema */
|
|
38
|
+
export declare function getDiscriminatorSchemaName(itemsSchema: OpenAPIV3_1.SchemaObject | undefined, schemas?: Schemas): string | null;
|
|
39
|
+
/** Merge discriminator schemas */
|
|
40
|
+
export declare function mergeDiscriminatorSchemas(baseSchema: OpenAPIV3_1.SchemaObject, selectedType: string, schemas: Record<string, OpenAPIV3_1.SchemaObject>): OpenAPIV3_1.SchemaObject | undefined;
|
|
41
|
+
/** Use discriminator hook */
|
|
42
|
+
export declare function useDiscriminator({ schema, schemas, onSchemaChange }: UseDiscriminatorOptions): {
|
|
43
|
+
selectedType: import("vue").Ref<string, string>;
|
|
44
|
+
discriminatorMapping: ComputedRef<{
|
|
45
|
+
[value: string]: string;
|
|
46
|
+
} | undefined>;
|
|
47
|
+
defaultType: ComputedRef<string>;
|
|
48
|
+
discriminatorPropertyName: ComputedRef<string | undefined>;
|
|
49
|
+
hasDiscriminator: ComputedRef<boolean>;
|
|
50
|
+
mergedSchema: ComputedRef<OpenAPIV3_1.SchemaObject | undefined>;
|
|
51
|
+
generateExampleValue: (isArray?: boolean) => any;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=useDiscriminator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDiscriminator.d.ts","sourceRoot":"","sources":["../../src/hooks/useDiscriminator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAA;AAE/E,iCAAiC;AACjC,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5C,yBAAyB,EAAE,MAAM,CAAA;IACjC,gBAAgB,EAAE,OAAO,CAAA;IACzB,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,CAAA;CACnD,CAAA;AAED,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oBAAoB,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,GAAG,CAAA;CACjD,CAAA;AAED,qBAAqB;AACrB,eAAO,MAAM,qBAAqB,EAAsC,YAAY,CAClF,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC,CACzC,CAAA;AACD,eAAO,MAAM,eAAe,EAAgC,YAAY,CAAC,cAAc,CAAC,CAAA;AAExF,4BAA4B;AAC5B,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAA;AAE1F,kCAAkC;AAClC,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAA;AAEvF,gCAAgC;AAChC,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,CAAA;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,YAAY,KAAK,IAAI,CAAA;CAC/D,CAAA;AAED,4CAA4C;AAC5C,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,GAC3C,oBAAoB,GAAG,SAAS,CAKlC;AAED,kDAAkD;AAClD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,GAC3C,yBAAyB,GAAG,SAAS,CAEvC;AAED,0CAA0C;AAC1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,GAAG,OAAO,CAEtF;AAED,4EAA4E;AAC5E,wBAAgB,8BAA8B,CAAC,yBAAyB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiBlH;AAED,qGAAqG;AACrG,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,EACjD,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,GAAG,IAAI,CAsBf;AAgBD,kCAAkC;AAClC,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,WAAW,CAAC,YAAY,EACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,GAChD,WAAW,CAAC,YAAY,GAAG,SAAS,CA6EtC;AAED,6BAA6B;AAC7B,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,uBAAuB;;;;;;;;;;EAuI5F"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { computed as c, ref as q, watch as O } from "vue";
|
|
2
|
+
const V = Symbol("discriminator-context"), w = Symbol("example-context");
|
|
3
|
+
function j(r) {
|
|
4
|
+
var e;
|
|
5
|
+
if ((e = r == null ? void 0 : r.discriminator) != null && e.mapping)
|
|
6
|
+
return r.discriminator.mapping;
|
|
7
|
+
}
|
|
8
|
+
function E(r) {
|
|
9
|
+
var e;
|
|
10
|
+
return (e = r == null ? void 0 : r.discriminator) == null ? void 0 : e.propertyName;
|
|
11
|
+
}
|
|
12
|
+
function D(r) {
|
|
13
|
+
return (r == null ? void 0 : r.discriminator) !== void 0;
|
|
14
|
+
}
|
|
15
|
+
function I(r, e) {
|
|
16
|
+
var o;
|
|
17
|
+
if (!r || !e || r.type !== "object" || !r.properties)
|
|
18
|
+
return null;
|
|
19
|
+
for (const [p, i] of Object.entries(e))
|
|
20
|
+
if (typeof i == "object" && i !== null && "discriminator" in i && ((o = i.discriminator) != null && o.propertyName)) {
|
|
21
|
+
const n = i.discriminator.propertyName;
|
|
22
|
+
if (r.properties[n])
|
|
23
|
+
return p;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
function x(r) {
|
|
28
|
+
if (r)
|
|
29
|
+
return r.type === "array" && r.items && typeof r.items == "object" && !("$ref" in r.items) ? r.items : r;
|
|
30
|
+
}
|
|
31
|
+
function T(r, e, o) {
|
|
32
|
+
var l;
|
|
33
|
+
if (!((l = r.discriminator) != null && l.mapping) || !e)
|
|
34
|
+
return;
|
|
35
|
+
const p = r.discriminator.mapping[e];
|
|
36
|
+
if (!p)
|
|
37
|
+
return;
|
|
38
|
+
const i = p.split("/").pop();
|
|
39
|
+
if (!i || !o[i])
|
|
40
|
+
return;
|
|
41
|
+
const n = o[i];
|
|
42
|
+
if (n.allOf) {
|
|
43
|
+
const d = {
|
|
44
|
+
type: n.type || "object",
|
|
45
|
+
properties: {},
|
|
46
|
+
required: [],
|
|
47
|
+
...r.title ? { title: r.title } : {},
|
|
48
|
+
...r.name ? { name: r.name } : {}
|
|
49
|
+
}, y = {}, a = /* @__PURE__ */ new Set();
|
|
50
|
+
r.required && r.required.forEach((u) => a.add(u));
|
|
51
|
+
for (const u of n.allOf)
|
|
52
|
+
if ("$ref" in u) {
|
|
53
|
+
const s = u.$ref.split("/").pop();
|
|
54
|
+
if (s && o[s]) {
|
|
55
|
+
const t = o[s];
|
|
56
|
+
t.properties && Object.assign(y, t.properties), t.required && t.required.forEach((f) => a.add(f));
|
|
57
|
+
}
|
|
58
|
+
} else "properties" in u && (Object.assign(y, u.properties), "required" in u && Array.isArray(u.required) && u.required.forEach((s) => a.add(s)));
|
|
59
|
+
return d.properties = y, d.required = Array.from(a), d;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
type: n.type || r.type,
|
|
63
|
+
properties: {
|
|
64
|
+
...r.properties || {},
|
|
65
|
+
...n.properties || {}
|
|
66
|
+
},
|
|
67
|
+
required: [...r.required || [], ...n.required || []],
|
|
68
|
+
// Preserve discriminator
|
|
69
|
+
discriminator: r.discriminator,
|
|
70
|
+
// Preserve title and name from base schema
|
|
71
|
+
...r.title ? { title: r.title } : {},
|
|
72
|
+
...r.name ? { name: r.name } : {}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function X({ schema: r, schemas: e, onSchemaChange: o }) {
|
|
76
|
+
const p = c(() => x(r)), i = c(() => j(p.value)), n = c(() => i.value && Object.keys(i.value)[0] || ""), l = q(n.value);
|
|
77
|
+
O(
|
|
78
|
+
n,
|
|
79
|
+
(t) => {
|
|
80
|
+
t && !l.value && (l.value = t);
|
|
81
|
+
},
|
|
82
|
+
{ immediate: !0 }
|
|
83
|
+
);
|
|
84
|
+
const d = c(() => E(p.value)), y = c(() => D(p.value)), a = c(() => {
|
|
85
|
+
if (!p.value || !e || !l.value)
|
|
86
|
+
return r;
|
|
87
|
+
const t = T(
|
|
88
|
+
p.value,
|
|
89
|
+
l.value,
|
|
90
|
+
e
|
|
91
|
+
);
|
|
92
|
+
if (!t)
|
|
93
|
+
return r;
|
|
94
|
+
const f = (r == null ? void 0 : r.type) === "array" ? {
|
|
95
|
+
type: "array",
|
|
96
|
+
items: t,
|
|
97
|
+
...r.title ? { title: r.title } : {},
|
|
98
|
+
...r.name ? { name: r.name } : {}
|
|
99
|
+
} : t;
|
|
100
|
+
return o == null || o(f), f;
|
|
101
|
+
}), u = (t) => {
|
|
102
|
+
if ("default" in t)
|
|
103
|
+
return t.default;
|
|
104
|
+
if ("example" in t)
|
|
105
|
+
return t.example;
|
|
106
|
+
switch (t.type) {
|
|
107
|
+
case "string":
|
|
108
|
+
return "";
|
|
109
|
+
case "integer":
|
|
110
|
+
case "number":
|
|
111
|
+
return t.nullable ? null : 0;
|
|
112
|
+
case "boolean":
|
|
113
|
+
return !1;
|
|
114
|
+
case "array":
|
|
115
|
+
return [];
|
|
116
|
+
case "object":
|
|
117
|
+
return {};
|
|
118
|
+
default:
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
selectedType: l,
|
|
124
|
+
discriminatorMapping: i,
|
|
125
|
+
defaultType: n,
|
|
126
|
+
discriminatorPropertyName: d,
|
|
127
|
+
hasDiscriminator: y,
|
|
128
|
+
mergedSchema: a,
|
|
129
|
+
generateExampleValue: (t = !1) => {
|
|
130
|
+
if (!a.value)
|
|
131
|
+
return t ? [] : {};
|
|
132
|
+
const f = {}, v = a.value.type === "array" ? a.value.items : a.value;
|
|
133
|
+
return "properties" in v && v.properties && Object.entries(v.properties).forEach(([g, N]) => {
|
|
134
|
+
const m = N;
|
|
135
|
+
m !== null && (f[g] = u(m));
|
|
136
|
+
}), d.value && l.value && (f[d.value] = l.value), JSON.parse(JSON.stringify(t ? [f] : f));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
V as DISCRIMINATOR_CONTEXT,
|
|
142
|
+
w as EXAMPLE_CONTEXT,
|
|
143
|
+
j as getDiscriminatorMapping,
|
|
144
|
+
E as getDiscriminatorPropertyName,
|
|
145
|
+
I as getDiscriminatorSchemaName,
|
|
146
|
+
D as hasDiscriminator,
|
|
147
|
+
T as mergeDiscriminatorSchemas,
|
|
148
|
+
X as useDiscriminator
|
|
149
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TransformedOperation } from '@scalar/types/legacy';
|
|
2
|
+
import type { Schemas } from '../features/Operation/types/schemas';
|
|
3
|
+
/** Handling discriminator logic in operations */
|
|
4
|
+
export declare function useOperationDiscriminator(transformedOperation: TransformedOperation, schemas?: Schemas): {
|
|
5
|
+
hasSchemaDiscriminator: import("vue").ComputedRef<boolean>;
|
|
6
|
+
handleDiscriminatorChange: (type: string) => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useOperationDiscriminator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationDiscriminator.d.ts","sourceRoot":"","sources":["../../src/hooks/useOperationDiscriminator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAsBjE,iDAAiD;AACjD,wBAAgB,yBAAyB,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,OAAO;;sCA6D5D,MAAM;EAahD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { computed as i, ref as E, provide as t } from "vue";
|
|
2
|
+
import { useDiscriminator as N, DISCRIMINATOR_CONTEXT as f, EXAMPLE_CONTEXT as h } from "./useDiscriminator.js";
|
|
3
|
+
function x(e) {
|
|
4
|
+
return e ? !!(e.discriminator || e.type === "array" && e.items && typeof e.items == "object" && "discriminator" in e.items) : !1;
|
|
5
|
+
}
|
|
6
|
+
function B(e, y) {
|
|
7
|
+
var s, c, m, u;
|
|
8
|
+
const n = (u = (m = (c = (s = e.information) == null ? void 0 : s.requestBody) == null ? void 0 : c.content) == null ? void 0 : m["application/json"]) == null ? void 0 : u.schema, a = i(() => x(n)), g = a.value ? N({
|
|
9
|
+
schema: n,
|
|
10
|
+
schemas: y,
|
|
11
|
+
onSchemaChange: (r) => {
|
|
12
|
+
var l, p, d;
|
|
13
|
+
(d = (p = (l = e.information) == null ? void 0 : l.requestBody) == null ? void 0 : p.content) != null && d["application/json"] && (e.information.requestBody.content["application/json"].schema = r);
|
|
14
|
+
}
|
|
15
|
+
}) : {
|
|
16
|
+
selectedType: E(""),
|
|
17
|
+
discriminatorMapping: i(() => ({})),
|
|
18
|
+
discriminatorPropertyName: i(() => ""),
|
|
19
|
+
hasDiscriminator: i(() => !1),
|
|
20
|
+
mergedSchema: i(() => n),
|
|
21
|
+
generateExampleValue: () => ({})
|
|
22
|
+
}, {
|
|
23
|
+
selectedType: o,
|
|
24
|
+
discriminatorMapping: v,
|
|
25
|
+
discriminatorPropertyName: D,
|
|
26
|
+
hasDiscriminator: S,
|
|
27
|
+
mergedSchema: T,
|
|
28
|
+
generateExampleValue: C
|
|
29
|
+
} = g;
|
|
30
|
+
if (a.value) {
|
|
31
|
+
const r = i(() => ({
|
|
32
|
+
selectedType: o.value || void 0,
|
|
33
|
+
discriminatorMapping: v.value || {},
|
|
34
|
+
discriminatorPropertyName: D.value || "",
|
|
35
|
+
hasDiscriminator: S.value,
|
|
36
|
+
mergedSchema: T.value
|
|
37
|
+
}));
|
|
38
|
+
t(f, r), t(h, {
|
|
39
|
+
generateExampleValue: C
|
|
40
|
+
});
|
|
41
|
+
} else
|
|
42
|
+
t(
|
|
43
|
+
f,
|
|
44
|
+
i(() => null)
|
|
45
|
+
), t(h, {
|
|
46
|
+
generateExampleValue: () => ({})
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
hasSchemaDiscriminator: a,
|
|
50
|
+
handleDiscriminatorChange: (r) => {
|
|
51
|
+
a.value && (o.value = r);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
B as useOperationDiscriminator
|
|
57
|
+
};
|