From 75abc89b23eac74b9fdd17129ac41d9a18a71695 Mon Sep 17 00:00:00 2001 From: enzonotario Date: Wed, 11 Dec 2024 22:44:37 -0300 Subject: [PATCH] feat(examples): allows to show them wrapped or in columns --- docs/composables/useTheme.md | 3 ++- src/components/Parameter/OAParameter.vue | 24 +++++++++++++++++++----- src/composables/useTheme.ts | 11 +++++++++++ test/composables/useTheme.test.ts | 6 ++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/composables/useTheme.md b/docs/composables/useTheme.md index 6d7a1bd5..f749454e 100644 --- a/docs/composables/useTheme.md +++ b/docs/composables/useTheme.md @@ -91,6 +91,7 @@ export default { avoidCirculars: false, // Avoid circular references when parsing schemas. lazyRendering: false, // Lazy render Paths and Tags components. defaultTag: 'Default', // Default tag to use when a path has no tags. + wrapExamples: true, // Wrap examples in a row or show them in a column. }, }) } @@ -153,4 +154,4 @@ export default { | Function | Description | Default Value | Allowed Values | |-----------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------| -| `setSpecConfig` | Sets the spec configuration. | `{ groupByTags: true, collapsePaths: false, showPathsSummary: true, avoidCirculars: false, lazyRendering: false, defaultTag: 'Default' }` | `{ groupByTags: boolean, collapsePaths: boolean, showPathsSummary: boolean, avoidCirculars: boolean, lazyRendering: boolean, defaultTag: string }` | +| `setSpecConfig` | Sets the spec configuration. | `{ groupByTags: true, collapsePaths: false, showPathsSummary: true, avoidCirculars: false, lazyRendering: false, defaultTag: 'Default', wrapExamples: true }` | `{ groupByTags: boolean, collapsePaths: boolean, showPathsSummary: boolean, avoidCirculars: boolean, lazyRendering: boolean, defaultTag: string, wrapExamples: boolean }` | diff --git a/src/components/Parameter/OAParameter.vue b/src/components/Parameter/OAParameter.vue index 3b1871d5..a638f3d7 100644 --- a/src/components/Parameter/OAParameter.vue +++ b/src/components/Parameter/OAParameter.vue @@ -2,6 +2,7 @@ import OACodeValue from '../Common/OACodeValue.vue' import { getConstraints } from '../../lib/constraintsParser' import { getExamples } from '../../lib/getExamples' +import { useTheme } from '../../composables/useTheme' const props = defineProps({ parameter: { @@ -13,6 +14,8 @@ const props = defineProps({ const examples = getExamples(props.parameter) const constraints = getConstraints(props.parameter.schema) + +const wrapExamples = useTheme().getWrapExamples()