File tree 3 files changed +21
-11
lines changed
packages/react-openapi/src
3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @gitbook/react-openapi ' : patch
3
+ ---
4
+
5
+ Update resolveDescription and add minItems/maxItems
Original file line number Diff line number Diff line change @@ -40,12 +40,12 @@ export function OpenAPISchemaName(props: OpenAPISchemaNameProps) {
40
40
function getAdditionalItems ( schema : OpenAPIV3 . SchemaObject ) : string {
41
41
let additionalItems = '' ;
42
42
43
- if ( schema . minimum || schema . minLength ) {
44
- additionalItems += ` · min: ${ schema . minimum || schema . minLength } ` ;
43
+ if ( schema . minimum || schema . minLength || schema . minItems ) {
44
+ additionalItems += ` · min: ${ schema . minimum || schema . minLength || schema . minItems } ` ;
45
45
}
46
46
47
- if ( schema . maximum || schema . maxLength ) {
48
- additionalItems += ` · max: ${ schema . maximum || schema . maxLength } ` ;
47
+ if ( schema . maximum || schema . maxLength || schema . maxItems ) {
48
+ additionalItems += ` · max: ${ schema . maximum || schema . maxLength || schema . maxItems } ` ;
49
49
}
50
50
51
51
// If the schema has a default value, we display it
Original file line number Diff line number Diff line change @@ -22,17 +22,22 @@ function hasDescription(object: AnyObject) {
22
22
* Resolve the description of an object.
23
23
*/
24
24
export function resolveDescription ( object : OpenAPIV3 . SchemaObject | AnyObject ) {
25
- // If the object has items and has a description, we resolve the description from items
25
+ // Resolve description from the object first
26
+ if ( hasDescription ( object ) ) {
27
+ return 'x-gitbook-description-html' in object &&
28
+ typeof object [ 'x-gitbook-description-html' ] === 'string'
29
+ ? object [ 'x-gitbook-description-html' ] . trim ( )
30
+ : typeof object . description === 'string'
31
+ ? object . description . trim ( )
32
+ : undefined ;
33
+ }
34
+
35
+ // If the object has no description, try to resolve it from the items
26
36
if ( 'items' in object && typeof object . items === 'object' && hasDescription ( object . items ) ) {
27
37
return resolveDescription ( object . items ) ;
28
38
}
29
39
30
- return 'x-gitbook-description-html' in object &&
31
- typeof object [ 'x-gitbook-description-html' ] === 'string'
32
- ? object [ 'x-gitbook-description-html' ] . trim ( )
33
- : typeof object . description === 'string'
34
- ? object . description . trim ( )
35
- : undefined ;
40
+ return undefined ;
36
41
}
37
42
38
43
/**
You can’t perform that action at this time.
0 commit comments