Skip to content

Commit 2ae7bdc

Browse files
authored
Merge pull request mrin9#56 from yj-ang/fix-last-page-empty
Fix last page empty
2 parents 6a8055c + 6e8c5af commit 2ae7bdc

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/pdf-gen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default async function createPdf(specUrl, options) {
6969
allContent.push(securityDef);
7070
}
7171
if (options.includeApiDetails) {
72-
apiDef = getApiDef(parsedSpec, '', options.pdfSchemaStyle, options.localize, options.includeExample);
72+
apiDef = getApiDef(parsedSpec, '', options.pdfSchemaStyle, options.localize, options.includeExample, options.includeApiList);
7373
allContent.push(apiDef);
7474
}
7575
if (options.includeApiList) {

src/pdf-parts-gen.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ function getResponseDef(responses, schemaStyle, localize) {
312312
}
313313

314314
// API details def
315-
export function getApiDef(spec, filterPath, schemaStyle, localize, includeExample) {
315+
export function getApiDef(spec, filterPath, schemaStyle, localize, includeExample, includeApiList) {
316316
const content = [{ text: localize.api, style: ['h2', 'b'] }];
317317
let tagSeq = 0;
318318

@@ -406,12 +406,14 @@ export function getApiDef(spec, filterPath, schemaStyle, localize, includeExampl
406406
});
407407
}
408408

409-
// End of Operation - Line
410-
operationContent.push({
411-
canvas: [{
412-
type: 'line', x1: 0, y1: 5, x2: 595 - 2 * 35, y2: 5, lineWidth: 0.5, lineColor: '#cccccc',
413-
}],
414-
});
409+
// End of Operation - Line (Except the last content)
410+
if (j === tag.paths.length - 1) {
411+
operationContent.push({
412+
canvas: [{
413+
type: 'line', x1: 0, y1: 5, x2: 595 - 2 * 35, y2: 5, lineWidth: 0.5, lineColor: '#cccccc',
414+
}],
415+
});
416+
}
415417
}
416418

417419
if (pathSeq > 0) {
@@ -442,6 +444,12 @@ export function getApiDef(spec, filterPath, schemaStyle, localize, includeExampl
442444
);
443445
}
444446
});
447+
448+
// Remove last page break if api list not included
449+
if (!includeApiList) {
450+
content.pop();
451+
}
452+
445453
return content;
446454
}
447455

0 commit comments

Comments
 (0)