Skip to content

Commit

Permalink
fix(includers/openapi): appropriate leading page title
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Jan 21, 2023
1 parent 111dc02 commit f112c1b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/services/includers/batteries/openapi/generators/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {page, block, title, body, mono, link, list, cut, code} from './common';
import {
CONTACTS_SECTION_NAME,
TAGS_SECTION_NAME,
ENDPOINTS_SECTION_NAME,
SPEC_RENDER_MODE_DEFAULT,
SPEC_SECTION_NAME,
SPEC_SECTION_TYPE,
Expand Down Expand Up @@ -58,12 +59,26 @@ function description(text?: string) {
}

function sections({tags, endpoints}: Specification) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
const links = Array.from(tags).map(([_, {name, id}]: [any, Tag]) => link(name, id + sep + 'index.md'));

links.push(...endpoints.map((e) => link(sectionName(e), mdPath(e))));
const content = [];

return links.length && block([title(2)(TAGS_SECTION_NAME), list(links)]);
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
const taggedLinks = Array.from(tags).map(([_, {name, id}]: [any, Tag]) => link(name, id + sep + 'index.md'));
if (taggedLinks.length) {
content.push(
title(2)(TAGS_SECTION_NAME),
list(taggedLinks),
);
}

const untaggedLinks = endpoints.map((endpoint) => link(sectionName(endpoint), mdPath(endpoint)));
if (untaggedLinks.length) {
content.push(
title(2)(ENDPOINTS_SECTION_NAME),
list(untaggedLinks),
);
}

return content.length && block(content);
}

function specification(data: any, renderMode: LeadingPageSpecRenderMode) {
Expand Down

0 comments on commit f112c1b

Please sign in to comment.