File tree Expand file tree Collapse file tree 2 files changed +50
-25
lines changed
packages/docusaurus-theme-openapi-docs/src/theme Expand file tree Collapse file tree 2 files changed +50
-25
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,24 @@ function ParamsItem({ param, ...rest }: Props) {
76
76
schema = { type : "any" } ;
77
77
}
78
78
79
+ let defaultValue : string | undefined ;
80
+
81
+ if (
82
+ schema && schema . items
83
+ ? schema . items . default
84
+ : schema
85
+ ? schema . default
86
+ : undefined
87
+ ) {
88
+ }
89
+
90
+ if ( schema ) {
91
+ if ( schema . items ) {
92
+ defaultValue = schema . items . default ;
93
+ }
94
+ defaultValue = schema . default ;
95
+ }
96
+
79
97
const renderSchemaName = guard ( schema , ( schema ) => (
80
98
< span className = "openapi-schema__type" > { getSchemaName ( schema ) } </ span >
81
99
) ) ;
@@ -131,18 +149,29 @@ function ParamsItem({ param, ...rest }: Props) {
131
149
}
132
150
) ;
133
151
134
- const renderDefaultValue = guard (
135
- schema && schema . items
136
- ? schema . items . default
137
- : schema
138
- ? schema . default
139
- : undefined ,
140
- ( value ) => (
141
- < div >
142
- < ReactMarkdown children = { `**Default value:** \`${ value } \`` } />
143
- </ div >
144
- )
145
- ) ;
152
+ function renderDefaultValue ( ) {
153
+ if ( defaultValue !== undefined ) {
154
+ if ( typeof defaultValue === "string" ) {
155
+ return (
156
+ < div >
157
+ < strong > Default value: </ strong >
158
+ < span >
159
+ < code > { defaultValue } </ code >
160
+ </ span >
161
+ </ div >
162
+ ) ;
163
+ }
164
+ return (
165
+ < div >
166
+ < strong > Default value: </ strong >
167
+ < span >
168
+ < code > { JSON . stringify ( defaultValue ) } </ code >
169
+ </ span >
170
+ </ div >
171
+ ) ;
172
+ }
173
+ return undefined ;
174
+ }
146
175
147
176
const renderExample = guard ( toString ( example ) , ( example ) => (
148
177
< div >
@@ -196,7 +225,7 @@ function ParamsItem({ param, ...rest }: Props) {
196
225
{ renderDeprecated }
197
226
</ span >
198
227
{ renderSchema }
199
- { renderDefaultValue }
228
+ { renderDefaultValue ( ) }
200
229
{ renderDescription }
201
230
{ renderEnumDescriptions }
202
231
{ renderExample }
Original file line number Diff line number Diff line change @@ -138,23 +138,19 @@ export default function SchemaItem(props: Props) {
138
138
if ( typeof defaultValue === "string" ) {
139
139
return (
140
140
< div >
141
- < strong >
142
- Default value:{ " " }
143
- < span >
144
- < code > { defaultValue } </ code >
145
- </ span >
146
- </ strong >
141
+ < strong > Default value: </ strong >
142
+ < span >
143
+ < code > { defaultValue } </ code >
144
+ </ span >
147
145
</ div >
148
146
) ;
149
147
}
150
148
return (
151
149
< div >
152
- < strong >
153
- Default value:{ " " }
154
- < span >
155
- < code > { JSON . stringify ( defaultValue ) } </ code >
156
- </ span >
157
- </ strong >
150
+ < strong > Default value: </ strong >
151
+ < span >
152
+ < code > { JSON . stringify ( defaultValue ) } </ code >
153
+ </ span >
158
154
</ div >
159
155
) ;
160
156
}
You can’t perform that action at this time.
0 commit comments