File tree Expand file tree Collapse file tree 2 files changed +54
-5
lines changed
packages/docusaurus-plugin-openapi-docs/src/openapi Expand file tree Collapse file tree 2 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -453,3 +453,39 @@ paths:
453453 examples :
454454 - true
455455 - false
456+
457+ /response/schema/properties/multipleTypes/examples :
458+ get :
459+ tags :
460+ - examples
461+ summary : examples of schema properties with multiple types in response
462+ description : " description of response schema properties with multiple types examples"
463+ responses :
464+ " 200 " :
465+ description : successful response
466+ content :
467+ application/json :
468+ schema :
469+ type : object
470+ properties :
471+ name :
472+ type :
473+ - string
474+ - " null"
475+ examples :
476+ - " John Doe"
477+ - " Jane Smith"
478+ age :
479+ type :
480+ - number
481+ - " null"
482+ examples :
483+ - 25
484+ - 30
485+ isStudent :
486+ type :
487+ - boolean
488+ - " null"
489+ examples :
490+ - true
491+ - false
Original file line number Diff line number Diff line change @@ -234,14 +234,27 @@ function primitive(schema: SchemaObject = {}) {
234234 return ;
235235 }
236236
237- let fn = schema . default ? ( ) => schema . default : primitives [ type ] . default ;
237+ // If type is an array, use the first type
238+ if ( Array . isArray ( type ) ) {
239+ type = type [ 0 ] ;
240+ if ( type === undefined ) {
241+ return ;
242+ }
243+ }
238244
239- if ( format !== undefined ) {
240- fn = primitives [ type ] [ format ] || fn ;
245+ // Use schema default if available, otherwise use type default
246+ if ( schema . default !== undefined ) {
247+ return schema . default ;
241248 }
242249
243- if ( fn ) {
244- return fn ( schema ) ;
250+ const typeConfig = primitives [ type ] ;
251+ if ( typeConfig ) {
252+ if ( format !== undefined && typeConfig [ format ] !== undefined ) {
253+ return typeConfig [ format ] ( schema ) ;
254+ }
255+ if ( typeConfig . default !== undefined ) {
256+ return typeConfig . default ( schema ) ;
257+ }
245258 }
246259
247260 return "Unknown Type: " + schema . type ;
You can’t perform that action at this time.
0 commit comments