Fix Python JSON code example (#3159)

This commit is contained in:
Greg Bergé
2025-04-14 21:50:40 +02:00
committed by GitHub
parent 4b8a62122a
commit eeb977fc03
4 changed files with 40 additions and 12 deletions
+11 -3
View File
@@ -1,17 +1,25 @@
/**
* Stringify an OpenAPI object. Same API as JSON.stringify.
*/
export function stringifyOpenAPI(body: unknown, _?: null, indent?: number): string {
export function stringifyOpenAPI(
value: any,
replacer?: ((this: any, key: string, value: any) => any) | null,
space?: string | number
): string {
return JSON.stringify(
body,
value,
(key, value) => {
// Ignore internal keys
if (key.startsWith('x-gitbook-')) {
return undefined;
}
if (replacer) {
return replacer(key, value);
}
return value;
},
indent
space
);
}