mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
22 lines
712 B
TypeScript
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;
|
|
}
|