Fix internal properties appearing in OpenAPI docs. (#2774)

This commit is contained in:
Steven H
2025-01-23 21:35:06 +00:00
committed by GitHub
parent 1a8cfd2a8b
commit 1823101b03
7 changed files with 44 additions and 11 deletions
@@ -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,
);
}