Skip to content

Commit d4e6760

Browse files
committed
added more example in product home-page
1 parent c70b9e5 commit d4e6760

14 files changed

+85
-39
lines changed

dist/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<rapi-pdf id='rapipdf' spec-url="./examples/specs/test.json" include-info="false" include-security="false" include-toc="false"> </rapi-pdf>
2828
-->
2929
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="table"> </rapi-pdf>
30+
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="object"> </rapi-pdf>
3031
<rapi-pdf id='rapipdf' spec-url="./specs/bitbucket.json"> </rapi-pdf>
3132
<rapi-pdf id='rapipdf' spec-url="./specs/data-types.yaml"> </rapi-pdf>
3233

dist/index.html.gz

8 Bytes
Binary file not shown.

dist/rapipdf-min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rapipdf-min.js.gz

129 Bytes
Binary file not shown.

dist/report.html

+2-2
Large diffs are not rendered by default.

docs/index.html

+30-15
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,33 @@ <h2> Quickstart & Demo</h2>
130130
&lt;/body&gt;
131131
&lt;/html&gt;
132132
</code></pre>
133-
<p>
134-
Go ahead, provide your Open API spec and click <span style="font-weight:bold">GENERATE PDF
135-
</span> !!!
136-
</p>
137133

134+
<div> Go ahead, provide your Open API spec and click GENERATE PDF !!! </div>
138135
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
139136
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
140137
button-bg="#b44646"
141-
pdf-title="My API Reference"
138+
pdf-title="API Reference"
142139
> </rapi-pdf>
140+
141+
<div style="margin-top:16px;"> With different Color scheme </div>
142+
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
143+
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
144+
pdf-schema-style="table"
145+
button-bg="#b44646"
146+
pdf-primary-color="teal",
147+
pdf-alternate-color="darkred"
148+
pdf-title="API Reference"
149+
> </rapi-pdf>
150+
151+
<div style="margin-top:16px;"> With an alternate request/response model represnation style </div>
152+
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
153+
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
154+
pdf-schema-style="table"
155+
button-bg="#b44646"
156+
pdf-title="API Reference"
157+
> </rapi-pdf>
158+
159+
143160
</div>
144161
</div>
145162

@@ -197,12 +214,6 @@ <h2> Attributes</h2>
197214
<td>false</td>
198215
</tr>
199216

200-
<tr>
201-
<td class="mono-bold">pdf-sort-tags</td>
202-
<td class="gray"> true to sort tags in the generated PDF</td>
203-
<td>true</td>
204-
</tr>
205-
206217
<tr>
207218
<td class="mono-bold">pdf-primary-color</td>
208219
<td class="gray">Color used for headings of main sections in PDF</td>
@@ -227,6 +238,12 @@ <h2> Attributes</h2>
227238
<td>(empty)</td>
228239
</tr>
229240

241+
<tr>
242+
<td class="mono-bold">pdf-schema-style</td>
243+
<td class="gray">style to display request and response schemas<br/>can be 'table' or 'object'</td>
244+
<td>object</td>
245+
</tr>
246+
230247
<tr>
231248
<td class="mono-bold">include-info</td>
232249
<td class="gray"> true to include info section in the generated PDF</td>
@@ -252,7 +269,7 @@ <h2> Attributes</h2>
252269
</tr>
253270

254271
<tr>
255-
<td class="mono-bold">include-api-list </td>
272+
<td class="mono-bold">include-api-list</td>
256273
<td class="gray">true to include list of all the APIs and their summary at the end in the generated PDF </td>
257274
<td>false</td>
258275
</tr>
@@ -302,7 +319,6 @@ <h2> Localization</h2>
302319
"url" : "URL",
303320
"termsOfService" : "Terms of service",
304321
"securitySchemes": "SECURITY SCHEMES",
305-
"key" : "KEY",
306322
"type" : "TYPE",
307323
"description" : "DESCRIPTION",
308324
"request" : "REQUEST",
@@ -311,8 +327,7 @@ <h2> Localization</h2>
311327
"responseModel" : "RESPONSE MODEL",
312328
"statusCode" : "STATUS CODE",
313329
"deprecated" : "DEPRECATED",
314-
"allowed" : "ALLOWED",
315-
"enumValues" : "ENUM",
330+
"allowed" : "allowed",
316331
"pattern" : "pattern",
317332
"parameters" : "Parameters",
318333
"method" : "METHOD",

docs/rapipdf-min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/welcome.html

+29-6
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,33 @@ <h2> Quickstart & Demo</h2>
130130
&lt;/body&gt;
131131
&lt;/html&gt;
132132
</code></pre>
133-
<p>
134-
Go ahead, provide your Open API spec and click <span style="font-weight:bold">GENERATE PDF
135-
</span> !!!
136-
</p>
137133

134+
<div> Go ahead, provide your Open API spec and click GENERATE PDF !!! </div>
138135
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
139136
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
140137
button-bg="#b44646"
141-
pdf-title="My API Reference"
138+
pdf-title="API Reference"
142139
> </rapi-pdf>
140+
141+
<div style="margin-top:16px;"> With different Color scheme </div>
142+
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
143+
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
144+
pdf-schema-style="table"
145+
button-bg="#b44646"
146+
pdf-primary-color="teal",
147+
pdf-alternate-color="darkred"
148+
pdf-title="API Reference"
149+
> </rapi-pdf>
150+
151+
<div style="margin-top:16px;"> With an alternate request/response model represnation style </div>
152+
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
153+
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
154+
pdf-schema-style="table"
155+
button-bg="#b44646"
156+
pdf-title="API Reference"
157+
> </rapi-pdf>
158+
159+
143160
</div>
144161
</div>
145162

@@ -221,6 +238,12 @@ <h2> Attributes</h2>
221238
<td>(empty)</td>
222239
</tr>
223240

241+
<tr>
242+
<td class="mono-bold">pdf-schema-style</td>
243+
<td class="gray">style to display request and response schemas<br/>can be 'table' or 'object'</td>
244+
<td>object</td>
245+
</tr>
246+
224247
<tr>
225248
<td class="mono-bold">include-info</td>
226249
<td class="gray"> true to include info section in the generated PDF</td>
@@ -246,7 +269,7 @@ <h2> Attributes</h2>
246269
</tr>
247270

248271
<tr>
249-
<td class="mono-bold">include-api-list </td>
272+
<td class="mono-bold">include-api-list</td>
250273
<td class="gray">true to include list of all the APIs and their summary at the end in the generated PDF </td>
251274
<td>false</td>
252275
</tr>

index.html

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<rapi-pdf id='rapipdf' spec-url="./examples/specs/test.json" include-info="false" include-security="false" include-toc="false"> </rapi-pdf>
2828
-->
2929
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="table"> </rapi-pdf>
30+
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="object"> </rapi-pdf>
3031
<rapi-pdf id='rapipdf' spec-url="./specs/bitbucket.json"> </rapi-pdf>
3132
<rapi-pdf id='rapipdf' spec-url="./specs/data-types.yaml"> </rapi-pdf>
3233

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"swagger pdf",
2626
"openapi pdf"
2727
],
28-
"main": "src/rapipdf.js",
29-
"module": "src/rapipdf.js",
28+
"main": "./src/rapipdf.js",
29+
"module": "./src/rapipdf.js",
3030
"dependencies": {
3131
"json-refs": "^3.0.13",
3232
"marked": "^0.7.0",

src/object-tree-gen.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ export function objectToTree(obj, localize, prevKeyDataType = 'object', prevKey
225225
const descrStack = generatePropDescription(propDescrArray, localize);
226226

227227
return [
228-
{ text: prevKey, style: ['sub', 'mono'], margin: 0 },
229-
{ text: (propDescrArray[0] ? propDescrArray[0] : ''), style: ['sub', 'mono', 'lightGray'], margin: 0 },
228+
{ text: prevKey, style: ['small', 'mono'], margin: 0 },
229+
{ text: (propDescrArray[0] ? propDescrArray[0] : ''), style: ['small', 'mono', 'lightGray'], margin: 0 },
230230
{ stack: descrStack, margin: 0 },
231231
];
232232
}
@@ -345,8 +345,8 @@ export function objectToTableTree(obj, localize, allRows = [], level = 0) {
345345
objType = 'object';
346346
}
347347
const objRow = [
348-
{ text: key, style: ['sub', 'mono', 'b'], margin: [leftMargin, 0, 0, 0] },
349-
{ text: objType, style: ['sub', 'mono', 'lightGray'], margin: 0 },
348+
{ text: key, style: ['small', 'b'], margin: [leftMargin, 0, 0, 0] },
349+
{ text: objType, style: ['small', 'mono', 'lightGray'], margin: 0 },
350350
{ text: '', margin: 0 },
351351
];
352352
allRows.push(objRow);
@@ -360,8 +360,8 @@ export function objectToTableTree(obj, localize, allRows = [], level = 0) {
360360
const descrStack = generatePropDescription(typeAndDescr, localize);
361361

362362
allRows.push([
363-
{ text: key, style: ['sub', 'mono'], margin: [leftMargin, 0, 0, 0] },
364-
{ text: (typeAndDescr[0] ? typeAndDescr[0] : ''), style: ['sub', 'mono', 'lightGray'], margin: 0 },
363+
{ text: key, style: ['small'], margin: [leftMargin, 0, 0, 0] },
364+
{ text: (typeAndDescr[0] ? typeAndDescr[0] : ''), style: ['small', 'mono', 'lightGray'], margin: 0 },
365365
{ stack: ((descrStack && descrStack.length) > 0 ? descrStack : [{ text: '' }]), margin: 0 },
366366
]);
367367
}

src/pdf-parts-gen.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,29 @@ function getResponseDef(responses, schemaStyle, localize) {
259259
responseDef.push(schemaTreeDef);
260260
}
261261
} else {
262-
// If Schema style is Tree
262+
// If Schema style is Table-Tree
263263
let schemaTableTreeDef;
264+
let rootObjectType;
264265
if (schemaInObjectNotaion['::type'] && schemaInObjectNotaion['::type'] === 'array') {
265-
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion['::prop'], localize, 'array');
266+
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion['::props'], localize);
267+
rootObjectType = [{ text: 'ARRAY OF OBJECT WITH BELOW STRUCTURE', style: ['sub', 'b', 'alternate'], colSpan: 3 }];
266268
} else {
267269
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion, localize);
270+
rootObjectType = [{ text: 'OBJECT WITH BELOW STRUCTURE', style: ['sub', 'b', 'alternate'], colSpan: 3 }];
268271
}
269272
if (schemaTableTreeDef && schemaTableTreeDef.length > 0 && Array.isArray(schemaTableTreeDef[0]) && schemaTableTreeDef[0].length > 0) {
273+
schemaTableTreeDef.unshift(rootObjectType);
270274
schemaTableTreeDef.unshift([
271275
{ text: localize.name, style: ['sub', 'b', 'alternate'] },
272276
{ text: localize.type, style: ['sub', 'b', 'alternate'] },
273277
{ text: localize.description, style: ['sub', 'b', 'alternate'] },
274278
]);
279+
275280
responseDef.push({
276281
table: {
277282
headerRows: 1,
278283
body: schemaTableTreeDef,
284+
dontBreakRows: true,
279285
},
280286
layout: rowLinesTableLayout,
281287
margin: [10, 3, 0, 0],

src/spec-parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function ProcessSpec(specUrl, sortTags) {
1515
resolvedRefSpec = await JsonRefs.resolveRefs(convertedSpec.openapi, resolveOptions);
1616
jsonParsedSpec = resolvedRefSpec.resolved;
1717
} catch (err) {
18-
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err);
18+
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err); // eslint-disable-line no-console
1919
}
2020

2121
const openApiSpec = jsonParsedSpec;

src/table-layouts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const rowLinesTableLayout = {
77
return 0;
88
},
99
hLineColor(i, node) {
10-
return (i === 0 || i === 1 || i === node.table.body.length) ? 'black' : 'lightgray';
10+
return (i === 0 || i === 1 || i === node.table.body.length) ? '#777' : 'lightgray';
1111
},
1212
};
1313

0 commit comments

Comments
 (0)