mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 08:05:19 +00:00
Fix internal properties appearing in OpenAPI docs. (#2774)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { SYMBOL_MARKDOWN_PARSED, SYMBOL_REF_RESOLVED } from './resolveOpenAPIPath';
|
||||
|
||||
/**
|
||||
* Stringify an OpenAPI object. Same API as JSON.stringify.
|
||||
*/
|
||||
export function stringifyOpenAPI(body: unknown, transformer?: null, indent?: number): string {
|
||||
return JSON.stringify(
|
||||
body,
|
||||
(_key, value) => {
|
||||
if (value && !Array.isArray(value) && typeof value === 'object') {
|
||||
// Extract out internal keys used in parsing
|
||||
const { [SYMBOL_MARKDOWN_PARSED]: _, [SYMBOL_REF_RESOLVED]: __, ...rest } = value;
|
||||
return rest;
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
indent,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user