Files
gitbook/packages/react-openapi/src/utils.ts
T
2025-01-30 08:44:08 +01:00

18 lines
492 B
TypeScript

import { OpenAPIV3 } from '@scalar/openapi-types';
export function noReference<T>(input: T | OpenAPIV3.ReferenceObject): T {
if (checkIsReference(input)) {
throw new Error('Reference found');
}
return input;
}
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;
}