@gitbook/react-openapi 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,8 +31,8 @@ describe('#resolveOpenAPIOperation', () => {
31
31
  ],
32
32
  operation: {
33
33
  tags: ['pet'],
34
- summary: 'Update an existing pet',
35
- description: 'Update an existing pet by Id',
34
+ summary: 'Update an existing pet.',
35
+ description: 'Update an existing pet by Id.',
36
36
  requestBody: {
37
37
  content: {
38
38
  'application/json': {
@@ -61,8 +61,8 @@ describe('#resolveOpenAPIOperation', () => {
61
61
  ],
62
62
  operation: {
63
63
  tags: ['pet'],
64
- summary: 'Update an existing pet',
65
- description: 'Update an existing pet by Id',
64
+ summary: 'Update an existing pet.',
65
+ description: 'Update an existing pet by Id.',
66
66
  requestBody: {
67
67
  content: {
68
68
  'application/json': {
@@ -159,8 +159,8 @@ describe('#resolveOpenAPIOperation', () => {
159
159
  ],
160
160
  operation: {
161
161
  tags: ['pet'],
162
- summary: 'Update an existing pet',
163
- description: 'Update an existing pet by Id',
162
+ summary: 'Update an existing pet.',
163
+ description: 'Update an existing pet by Id.',
164
164
  requestBody: {
165
165
  content: {
166
166
  'application/json': {
package/src/utils.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { AnyObject, OpenAPIV3, OpenAPIV3_1 } from '@gitbook/openapi-parser';
2
2
  import { stringifyOpenAPI } from './stringifyOpenAPI';
3
3
 
4
- export function checkIsReference(
5
- input: unknown
6
- ): input is OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject {
4
+ export function checkIsReference(input: unknown): input is OpenAPIV3.ReferenceObject {
7
5
  return typeof input === 'object' && !!input && '$ref' in input;
8
6
  }
9
7
 
@@ -22,17 +20,22 @@ function hasDescription(object: AnyObject) {
22
20
  * Resolve the description of an object.
23
21
  */
24
22
  export function resolveDescription(object: OpenAPIV3.SchemaObject | AnyObject) {
25
- // If the object has items and has a description, we resolve the description from items
23
+ // Resolve description from the object first
24
+ if (hasDescription(object)) {
25
+ return 'x-gitbook-description-html' in object &&
26
+ typeof object['x-gitbook-description-html'] === 'string'
27
+ ? object['x-gitbook-description-html'].trim()
28
+ : typeof object.description === 'string'
29
+ ? object.description.trim()
30
+ : undefined;
31
+ }
32
+
33
+ // If the object has no description, try to resolve it from the items
26
34
  if ('items' in object && typeof object.items === 'object' && hasDescription(object.items)) {
27
35
  return resolveDescription(object.items);
28
36
  }
29
37
 
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;
38
+ return undefined;
36
39
  }
37
40
 
38
41
  /**