File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed
packages/react-openapi/src
src/components/DocumentView/OpenAPI Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ export function OpenAPISchemaProperty(
47
47
? null
48
48
: getSchemaAlternatives ( schema , new Set ( circularRefs . keys ( ) ) ) ;
49
49
50
+ const shouldDisplayExample = ( schema : OpenAPIV3 . SchemaObject ) : boolean => {
51
+ return ( typeof schema . example === 'string' || typeof schema . example === 'number' || typeof schema . example === 'boolean' )
52
+ }
50
53
return (
51
54
< InteractiveSection
52
55
id = { id }
@@ -92,6 +95,9 @@ export function OpenAPISchemaProperty(
92
95
className = "openapi-schema-description"
93
96
/>
94
97
) : null }
98
+ { shouldDisplayExample ( schema ) ? (
99
+ < span className = "openapi-schema-example" > Example: < code > { JSON . stringify ( schema . example ) } </ code > </ span >
100
+ ) : null }
95
101
</ div >
96
102
}
97
103
>
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export function OpenAPISpec(props: { rawData: any; context: OpenAPIClientContext
48
48
// Description of the parameter is defined at the parameter level
49
49
// we use display it if the schema doesn't override it
50
50
description : parameter . description ,
51
+ example : parameter . example ,
51
52
...( noReference ( parameter . schema ) ?? { } ) ,
52
53
} ,
53
54
required : parameter . required ,
Original file line number Diff line number Diff line change 172
172
@apply prose-sm;
173
173
}
174
174
175
+ .openapi-schema-example {
176
+ @apply prose-sm mt-2 text-dark/10 dark:text-light/10;
177
+ }
178
+
175
179
/** Authentication */
176
180
177
181
.openapi-securities {
You can’t perform that action at this time.
0 commit comments