mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-18 00:25:07 +00:00
Fix Python JSON code example (#3159)
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user