Files
gitbook/packages/react-openapi/src/utils.ts
T
2025-02-19 10:29:33 +01:00

22 lines
712 B
TypeScript

import type { AnyObject, OpenAPIV3 } from '@gitbook/openapi-parser';
export function checkIsReference(input: unknown): input is OpenAPIV3.ReferenceObject {
return typeof input === 'object' && !!input && '$ref' in input;
}
export function createStateKey(key: string, scope?: string) {
return scope ? `${scope}_${key}` : key;
}
/**
* Resolve the description of an object.
*/
export function resolveDescription(object: AnyObject) {
return 'x-gitbook-description-html' in object &&
typeof object['x-gitbook-description-html'] === 'string'
? object['x-gitbook-description-html']
: typeof object.description === 'string'
? object.description
: undefined;
}