vitepress-openapi 0.0.3-alpha.76 → 0.0.3-alpha.77
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/dist/{OpenApi-JZDy_oqC.cjs → OpenApi-BGTpYde8.cjs} +27 -27
- package/dist/{OpenApi-CDzPw3Gb.js → OpenApi-D8C8EsDs.js} +445 -449
- package/dist/types/src/lib/parser/getSchemaUi.d.ts +1 -1
- package/dist/vitepress-openapi.client.cjs.js +1 -1
- package/dist/vitepress-openapi.client.es.js +2 -2
- package/dist/vitepress-openapi.node.cjs.js +1 -1
- package/dist/vitepress-openapi.node.es.js +1 -1
- package/package.json +1 -1
- package/src/lib/examples/getSchemaUiJson.ts +6 -2
- package/src/lib/parser/getSchemaUi.ts +45 -51
|
@@ -10,8 +10,8 @@ var hr = (t, e, n) => (u1(t, e, "read from private field"), n ? n.call(t) : e.ge
|
|
|
10
10
|
var p1 = (t, e, n) => EM(SM(t), n, e);
|
|
11
11
|
import * as Co from "vue";
|
|
12
12
|
import { ref as it, computed as De, inject as Td, openBlock as I, createElementBlock as ye, createStaticVNode as OM, provide as I0, renderSlot as Ye, defineComponent as lt, withAsyncContext as EA, createBlock as Ee, unref as N, withCtx as de, Suspense as TM, createVNode as Ne, createElementVNode as Re, useSlots as Il, resolveDynamicComponent as Lk, normalizeClass as Pr, createTextVNode as kn, toDisplayString as Ke, createCommentVNode as ze, Fragment as Zt, renderList as An, shallowRef as PM, watch as Kr, getCurrentScope as FM, onScopeDispose as RM, shallowReadonly as cp, Comment as MM, mergeProps as cr, cloneVNode as IM, h as Fo, getCurrentInstance as tm, toRefs as Bc, nextTick as Ja, onUnmounted as D0, onMounted as us, toHandlerKey as DM, camelize as tO, toRef as LM, Teleport as nO, watchEffect as Ui, reactive as rO, normalizeStyle as L0, markRaw as zM, withKeys as od, withModifiers as Cu, watchPostEffect as aO, mergeDefaults as qM, normalizeProps as Dr, guardReactiveProps as Lr, onBeforeUnmount as zk, withDirectives as BM, isRef as iO, vModelDynamic as UM, resolveComponent as VM, createSlots as Ku } from "vue";
|
|
13
|
-
import { u as Zr, O as Ob, p as lw, a as Zu, b as Ro, d as HM, i as Pd, c as sO, e as WM, o as GM, f as KM, t as ZM, g as YM, h as NA, j as XM, r as JM, k as QM, l as oO, m as eI, n as tI, q as qf, s as OA, v as lO, w as cw, x as nI } from "./OpenApi-
|
|
14
|
-
import { D as kke, z as Cke, y as Ake, A as jke } from "./OpenApi-
|
|
13
|
+
import { u as Zr, O as Ob, p as lw, a as Zu, b as Ro, d as HM, i as Pd, c as sO, e as WM, o as GM, f as KM, t as ZM, g as YM, h as NA, j as XM, r as JM, k as QM, l as oO, m as eI, n as tI, q as qf, s as OA, v as lO, w as cw, x as nI } from "./OpenApi-D8C8EsDs.js";
|
|
14
|
+
import { D as kke, z as Cke, y as Ake, A as jke } from "./OpenApi-D8C8EsDs.js";
|
|
15
15
|
function uw({
|
|
16
16
|
chain: t,
|
|
17
17
|
messages: e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./OpenApi-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./OpenApi-BGTpYde8.cjs");exports.OpenApi=e.OpenApi;exports.httpVerbs=e.httpVerbs;exports.literalTypes=e.literalTypes;exports.usePaths=e.usePaths;exports.useSidebar=e.useSidebar;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OAProperty } from '../parser/getSchemaUi'
|
|
1
|
+
import type { JSONSchemaType, OAProperty } from '../parser/getSchemaUi'
|
|
2
2
|
import { literalTypes } from '../../index'
|
|
3
3
|
import { getPropertyExample } from './getPropertyExample'
|
|
4
4
|
|
|
@@ -38,7 +38,7 @@ function uiPropertyToJson(property: OAProperty, useExample: boolean): any {
|
|
|
38
38
|
}, useExample)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (
|
|
41
|
+
if (containsType(property, 'object')) {
|
|
42
42
|
if (isOneOfProperty(property)) {
|
|
43
43
|
return resolveOneOfProperty(property, useExample)
|
|
44
44
|
}
|
|
@@ -141,6 +141,10 @@ function hasAllLiteralTypes(property: OAProperty): boolean {
|
|
|
141
141
|
return property.types?.every(type => type && literalTypes.includes(type))
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
function containsType(property: OAProperty, type: JSONSchemaType): boolean {
|
|
145
|
+
return property.types?.includes(type) ?? false
|
|
146
|
+
}
|
|
147
|
+
|
|
144
148
|
function isOneOfProperty(property: OAProperty): boolean {
|
|
145
149
|
return !!property.meta?.isOneOf && Array.isArray(property.properties)
|
|
146
150
|
}
|
|
@@ -4,7 +4,7 @@ import { getPropertyExamples } from '../examples/getPropertyExamples'
|
|
|
4
4
|
import { getConstraints, hasConstraints } from './constraintsParser'
|
|
5
5
|
import { resolveCircularRef } from './resolveCircularRef'
|
|
6
6
|
|
|
7
|
-
type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null'
|
|
7
|
+
export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null'
|
|
8
8
|
|
|
9
9
|
interface Metadata {
|
|
10
10
|
isCircularReference?: boolean
|
|
@@ -149,63 +149,57 @@ class UiPropertyFactory {
|
|
|
149
149
|
|
|
150
150
|
const property = UiPropertyFactory.createBaseProperty(name, schema, required)
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
property.meta = { ...(property.meta || {}), isConstant: true }
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (schema.items.oneOf) {
|
|
179
|
-
property.meta = { ...(property.meta || {}), isOneOf: true }
|
|
180
|
-
property.properties = schema.items.oneOf.map((prop: any) => {
|
|
181
|
-
const propSchema = { ...prop, type: schema.items.type }
|
|
182
|
-
return {
|
|
183
|
-
...UiPropertyFactory.schemaToUiProperty('', propSchema),
|
|
184
|
-
meta: { ...(prop.meta || {}), isOneOfItem: true },
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
}
|
|
152
|
+
if (Array.isArray(schema.type) ? schema.type.includes('array') : schema.type === 'array') {
|
|
153
|
+
if (schema.items) {
|
|
154
|
+
const schemaType = determineSchemaType(schema.items)
|
|
155
|
+
|
|
156
|
+
property.properties = schemaType === 'object'
|
|
157
|
+
? UiPropertyFactory.extractProperties(
|
|
158
|
+
schema.items.properties,
|
|
159
|
+
schema.items.required || [],
|
|
160
|
+
schema.items.additionalProperties,
|
|
161
|
+
)
|
|
162
|
+
: undefined
|
|
163
|
+
|
|
164
|
+
if (schemaType !== undefined) {
|
|
165
|
+
property.subtype = schemaType as JSONSchemaType
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const itemsExamples = getPropertyExamples(schema.items)
|
|
169
|
+
if (itemsExamples) {
|
|
170
|
+
property.subexamples = itemsExamples
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (schema.items.const !== undefined) {
|
|
174
|
+
property.meta = { ...(property.meta || {}), isConstant: true }
|
|
188
175
|
}
|
|
189
|
-
break
|
|
190
176
|
|
|
191
|
-
|
|
177
|
+
if (schema.items.oneOf) {
|
|
178
|
+
property.meta = { ...(property.meta || {}), isOneOf: true }
|
|
179
|
+
property.properties = schema.items.oneOf.map((prop: any) => {
|
|
180
|
+
const propSchema = { ...prop, type: schema.items.type }
|
|
181
|
+
return {
|
|
182
|
+
...UiPropertyFactory.schemaToUiProperty('', propSchema),
|
|
183
|
+
meta: { ...(prop.meta || {}), isOneOfItem: true },
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else if (Array.isArray(schema.type) ? schema.type.includes('object') : schema.type === 'object') {
|
|
189
|
+
property.properties = UiPropertyFactory.extractProperties(
|
|
190
|
+
schema.properties,
|
|
191
|
+
schema.required || [],
|
|
192
|
+
schema.additionalProperties,
|
|
193
|
+
)
|
|
194
|
+
} else if (schema.type === undefined) {
|
|
195
|
+
if (schema.properties || schema.additionalProperties) {
|
|
196
|
+
property.types = ['object']
|
|
192
197
|
property.properties = UiPropertyFactory.extractProperties(
|
|
193
198
|
schema.properties,
|
|
194
199
|
schema.required || [],
|
|
195
200
|
schema.additionalProperties,
|
|
196
201
|
)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
case undefined:
|
|
200
|
-
if (schema.properties || schema.additionalProperties) {
|
|
201
|
-
property.types = ['object']
|
|
202
|
-
property.properties = UiPropertyFactory.extractProperties(
|
|
203
|
-
schema.properties,
|
|
204
|
-
schema.required || [],
|
|
205
|
-
schema.additionalProperties,
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
break
|
|
202
|
+
}
|
|
209
203
|
}
|
|
210
204
|
|
|
211
205
|
return property
|