vitepress-openapi 0.1.14 → 0.1.15
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/types/src/components/Playground/OAPlaygroundBodyInput.vue.d.ts +3 -0
- package/dist/types/src/components/Playground/OAPlaygroundParameterInput.vue.d.ts +19 -0
- package/dist/types/src/components/Playground/OAPlaygroundParameters.vue.d.ts +19 -0
- package/dist/types/src/components/ui/select-with-custom-option/SelectWithCustomOption.vue.d.ts +1 -1
- package/dist/types/src/composables/useTheme.d.ts +13 -0
- package/dist/types/src/lib/examples/getPropertyExample.d.ts +2 -0
- package/dist/types/src/lib/playground/playgroundExampleBehavior.d.ts +5 -0
- package/dist/{useOpenapi-DEPZ2jCp.cjs → useOpenapi-DHJ6SAsR.cjs} +51 -51
- package/dist/{useOpenapi-DjUt0cr5.js → useOpenapi-DqKJozk7.js} +1507 -1477
- package/dist/vitepress-openapi.client.cjs.js +146 -146
- package/dist/vitepress-openapi.client.es.js +8860 -8801
- package/dist/vitepress-openapi.css +1 -1
- 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/components/Playground/OAPlayground.vue +7 -1
- package/src/components/Playground/OAPlaygroundBodyInput.vue +10 -2
- package/src/components/Playground/OAPlaygroundParameterInput.vue +20 -5
- package/src/components/Playground/OAPlaygroundParameters.vue +23 -8
- package/src/composables/useTheme.ts +41 -0
- package/src/lib/examples/getPropertyExample.ts +9 -1
- package/src/lib/parser/getSchemaUi.ts +9 -6
- package/src/lib/playground/playgroundExampleBehavior.ts +48 -0
|
@@ -234,6 +234,7 @@ class UiPropertyFactory {
|
|
|
234
234
|
schema.items.properties,
|
|
235
235
|
schema.items.required || [],
|
|
236
236
|
schema.items.additionalProperties,
|
|
237
|
+
schema.items['x-additionalPropertiesName'],
|
|
237
238
|
)
|
|
238
239
|
: undefined
|
|
239
240
|
|
|
@@ -334,6 +335,7 @@ class UiPropertyFactory {
|
|
|
334
335
|
schema.properties,
|
|
335
336
|
schema.required || [],
|
|
336
337
|
schema.additionalProperties,
|
|
338
|
+
schema['x-additionalPropertiesName'],
|
|
337
339
|
)
|
|
338
340
|
} else if (schema.type === undefined) {
|
|
339
341
|
if (schema.properties || schema.additionalProperties) {
|
|
@@ -342,6 +344,7 @@ class UiPropertyFactory {
|
|
|
342
344
|
schema.properties,
|
|
343
345
|
schema.required || [],
|
|
344
346
|
schema.additionalProperties,
|
|
347
|
+
schema['x-additionalPropertiesName'],
|
|
345
348
|
)
|
|
346
349
|
}
|
|
347
350
|
}
|
|
@@ -353,6 +356,7 @@ class UiPropertyFactory {
|
|
|
353
356
|
propertiesNode?: Record<string, OpenAPI.SchemaObject>,
|
|
354
357
|
requiredProperties: string[] = [],
|
|
355
358
|
additionalPropertiesNode?: OpenAPI.SchemaObject | boolean,
|
|
359
|
+
additionalPropertiesName?: string,
|
|
356
360
|
): OAProperty[] {
|
|
357
361
|
const properties: OAProperty[] = []
|
|
358
362
|
|
|
@@ -368,12 +372,11 @@ class UiPropertyFactory {
|
|
|
368
372
|
? additionalPropertiesNode
|
|
369
373
|
: { type: 'string' }
|
|
370
374
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
})
|
|
375
|
+
const name = additionalPropertiesName || 'additionalProperties'
|
|
376
|
+
const property = UiPropertyFactory.schemaToUiProperty(name, additionalProps)
|
|
377
|
+
property.required = false
|
|
378
|
+
property.meta = { ...(property.meta || {}), isAdditionalProperties: true }
|
|
379
|
+
properties.push(property)
|
|
377
380
|
}
|
|
378
381
|
|
|
379
382
|
return properties
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PlaygroundExampleBehavior } from '../../composables/useTheme'
|
|
2
|
+
import { getPlaygroundSpecificExample, getStandardExample } from '../examples/getPropertyExample'
|
|
3
|
+
|
|
4
|
+
export function useExampleForPlaceholder(behavior: PlaygroundExampleBehavior): boolean {
|
|
5
|
+
return behavior !== 'ignore'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useExampleForValue(behavior: PlaygroundExampleBehavior): boolean {
|
|
9
|
+
return behavior === 'value'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function resolveExampleForValue(
|
|
13
|
+
property: any,
|
|
14
|
+
behavior: PlaygroundExampleBehavior,
|
|
15
|
+
xExampleBehavior: PlaygroundExampleBehavior = 'value',
|
|
16
|
+
): any {
|
|
17
|
+
if (useExampleForValue(xExampleBehavior)) {
|
|
18
|
+
const specific = getPlaygroundSpecificExample(property)
|
|
19
|
+
if (specific !== null) {
|
|
20
|
+
return specific
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (useExampleForValue(behavior)) {
|
|
25
|
+
return getStandardExample(property)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function resolveExampleForPlaceholder(
|
|
32
|
+
property: any,
|
|
33
|
+
behavior: PlaygroundExampleBehavior,
|
|
34
|
+
xExampleBehavior: PlaygroundExampleBehavior = 'value',
|
|
35
|
+
): any {
|
|
36
|
+
if (useExampleForPlaceholder(xExampleBehavior)) {
|
|
37
|
+
const specific = getPlaygroundSpecificExample(property)
|
|
38
|
+
if (specific !== null) {
|
|
39
|
+
return specific
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (useExampleForPlaceholder(behavior)) {
|
|
44
|
+
return getStandardExample(property)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return null
|
|
48
|
+
}
|