import MDX from '@mdx-js/runtime';
import * as React from 'react';
import * as components from '~/common/translate-markdown';
import { Cell, HeaderCell, Row, Table, TableHead } from '~/ui/components/Table';
export type Property = {
description?: string[];
name: string;
type?: string | string[];
enum?: string[];
properties?: Property[];
};
type FormattedProperty = {
name: string;
description: string;
nestingLevel: number;
};
export function formatSchema(rawSchema: Property[]) {
const formattedSchema: FormattedProperty[] = [];
rawSchema.map(property => {
appendProperty(formattedSchema, property, 0);
});
return formattedSchema;
}
//appends a property and recursively appends sub-properties
function appendProperty(
formattedSchema: FormattedProperty[],
property: Property,
_nestingLevel: number
) {
let nestingLevel = _nestingLevel;
formattedSchema.push({
name: nestingLevel
? `