Skip to content

Commit

Permalink
feat: remove type column
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Fedoseev committed Mar 26, 2024
1 parent 3b6aa2c commit a6aef4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/includer/traverse/tables.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import RefsService from '../services/refs';
import stringify from 'json-stringify-safe';

import {anchor, table, tableParameterName} from '../ui';
import {anchor, bold, table, tableParameterName} from '../ui';
import {concatNewLine} from '../utils';
import {EOL} from '../constants';
import {BLOCK, EOL} from '../constants';
import {OpenJSONSchema, OpenJSONSchemaDefinition} from '../models';
import {collectRefs, extractOneOfElements, inferType, typeToText} from './types';

type TableRow = [string, string, string];
type TableRow = [string, string];

export type TableRef = string;

Expand Down Expand Up @@ -40,7 +40,7 @@ export function tableFromSchema(schema: OpenJSONSchema): TableFromSchemaResult {
}

const {rows, refs} = prepareObjectSchemaTable(schema);
const content = rows.length ? table([['Name', 'Type', 'Description'], ...rows]) : '';
const content = rows.length ? table([['Name', 'Description'], ...rows]) : '';

return {content, tableRefs: refs};
}
Expand All @@ -61,7 +61,7 @@ function prepareObjectSchemaTable(schema: OpenJSONSchema): PrepareObjectSchemaTa
const name = tableParameterName(key, isRequired(key, merged));
const {type, description, ref, runtimeRef} = prepareTableRowData(value, key, tableRef);

result.rows.push([name, type, description]);
result.rows.push([name, `${bold('Type: ' + type)}${BLOCK}${BLOCK}${description}`]);

if (ref) {
result.refs.push(...ref);
Expand Down Expand Up @@ -99,7 +99,7 @@ function prepareObjectSchemaTable(schema: OpenJSONSchema): PrepareObjectSchemaTa
return;
}

result.rows.push(['oneOf', anchor(ref), value.description || '']);
result.rows.push([`${bold('oneOf')} ${anchor(ref)}`, value.description || '']);

result.refs.push(ref);
});
Expand Down
5 changes: 3 additions & 2 deletions src/includer/ui/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import stringify from 'json-stringify-safe';
import RefsService from '../services/refs';

import {
BLOCK,
COOKIES_SECTION_NAME,
HEADERS_SECTION_NAME,
INFO_TAB_NAME,
Expand Down Expand Up @@ -182,7 +183,7 @@ function parameters(pagePrintedRefs: Set<string>, params?: Parameters) {
}
}
tables.push(title(3)(heading));
tables.push(table([['Name', 'Type', 'Description'], ...rows]));
tables.push(table([['Name', 'Description'], ...rows]));
tables.push(...printAllTables(pagePrintedRefs, tableRefs));
}
}
Expand All @@ -203,7 +204,7 @@ function parameterRow(param: Parameter): {cells: string[]; ref?: TableRef[]} {
description = concatNewLine(description, `Default: \`${param.default}\``);
}
return {
cells: [tableParameterName(param.name, param.required), row.type, description],
cells: [tableParameterName(param.name, param.required), `${bold('Type: ' + row.type)}${BLOCK}${BLOCK}${description}`],
ref: row.ref,
};
}
Expand Down

0 comments on commit a6aef4e

Please sign in to comment.