Files
gitbook/packages/react-openapi/src/stringifyOpenAPI.ts
T
2025-04-14 19:50:40 +00:00

26 lines
576 B
TypeScript

/**
* Stringify an OpenAPI object. Same API as JSON.stringify.
*/
export function stringifyOpenAPI(
value: any,
replacer?: ((this: any, key: string, value: any) => any) | null,
space?: string | number
): string {
return JSON.stringify(
value,
(key, value) => {
// Ignore internal keys
if (key.startsWith('x-gitbook-')) {
return undefined;
}
if (replacer) {
return replacer(key, value);
}
return value;
},
space
);
}