mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 23:55:20 +00:00
26 lines
576 B
TypeScript
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
|
|
);
|
|
}
|