Skip to content

Commit

Permalink
added more example in product home-page
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Oct 5, 2019
1 parent c70b9e5 commit d4e6760
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 39 deletions.
1 change: 1 addition & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<rapi-pdf id='rapipdf' spec-url="./examples/specs/test.json" include-info="false" include-security="false" include-toc="false"> </rapi-pdf>
-->
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="table"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="object"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/bitbucket.json"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/data-types.yaml"> </rapi-pdf>

Expand Down
Binary file modified dist/index.html.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/rapipdf-min.js

Large diffs are not rendered by default.

Binary file modified dist/rapipdf-min.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/report.html

Large diffs are not rendered by default.

45 changes: 30 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,33 @@ <h2> Quickstart & Demo</h2>
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>
Go ahead, provide your Open API spec and click <span style="font-weight:bold">GENERATE PDF
</span> !!!
</p>

<div> Go ahead, provide your Open API spec and click GENERATE PDF !!! </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
button-bg="#b44646"
pdf-title="My API Reference"
pdf-title="API Reference"
> </rapi-pdf>

<div style="margin-top:16px;"> With different Color scheme </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
pdf-schema-style="table"
button-bg="#b44646"
pdf-primary-color="teal",
pdf-alternate-color="darkred"
pdf-title="API Reference"
> </rapi-pdf>

<div style="margin-top:16px;"> With an alternate request/response model represnation style </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
pdf-schema-style="table"
button-bg="#b44646"
pdf-title="API Reference"
> </rapi-pdf>


</div>
</div>

Expand Down Expand Up @@ -197,12 +214,6 @@ <h2> Attributes</h2>
<td>false</td>
</tr>

<tr>
<td class="mono-bold">pdf-sort-tags</td>
<td class="gray"> true to sort tags in the generated PDF</td>
<td>true</td>
</tr>

<tr>
<td class="mono-bold">pdf-primary-color</td>
<td class="gray">Color used for headings of main sections in PDF</td>
Expand All @@ -227,6 +238,12 @@ <h2> Attributes</h2>
<td>(empty)</td>
</tr>

<tr>
<td class="mono-bold">pdf-schema-style</td>
<td class="gray">style to display request and response schemas<br/>can be 'table' or 'object'</td>
<td>object</td>
</tr>

<tr>
<td class="mono-bold">include-info</td>
<td class="gray"> true to include info section in the generated PDF</td>
Expand All @@ -252,7 +269,7 @@ <h2> Attributes</h2>
</tr>

<tr>
<td class="mono-bold">include-api-list </td>
<td class="mono-bold">include-api-list</td>
<td class="gray">true to include list of all the APIs and their summary at the end in the generated PDF </td>
<td>false</td>
</tr>
Expand Down Expand Up @@ -302,7 +319,6 @@ <h2> Localization</h2>
"url" : "URL",
"termsOfService" : "Terms of service",
"securitySchemes": "SECURITY SCHEMES",
"key" : "KEY",
"type" : "TYPE",
"description" : "DESCRIPTION",
"request" : "REQUEST",
Expand All @@ -311,8 +327,7 @@ <h2> Localization</h2>
"responseModel" : "RESPONSE MODEL",
"statusCode" : "STATUS CODE",
"deprecated" : "DEPRECATED",
"allowed" : "ALLOWED",
"enumValues" : "ENUM",
"allowed" : "allowed",
"pattern" : "pattern",
"parameters" : "Parameters",
"method" : "METHOD",
Expand Down
4 changes: 2 additions & 2 deletions docs/rapipdf-min.js

Large diffs are not rendered by default.

35 changes: 29 additions & 6 deletions docs/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,33 @@ <h2> Quickstart & Demo</h2>
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>
Go ahead, provide your Open API spec and click <span style="font-weight:bold">GENERATE PDF
</span> !!!
</p>

<div> Go ahead, provide your Open API spec and click GENERATE PDF !!! </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
button-bg="#b44646"
pdf-title="My API Reference"
pdf-title="API Reference"
> </rapi-pdf>

<div style="margin-top:16px;"> With different Color scheme </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
pdf-schema-style="table"
button-bg="#b44646"
pdf-primary-color="teal",
pdf-alternate-color="darkred"
pdf-title="API Reference"
> </rapi-pdf>

<div style="margin-top:16px;"> With an alternate request/response model represnation style </div>
<rapi-pdf id='rapipdf' style="width:730px; height:40px; font-size:18px;"
spec-url="https://mrin9.github.io/RapiPdf/specs/petstore.json"
pdf-schema-style="table"
button-bg="#b44646"
pdf-title="API Reference"
> </rapi-pdf>


</div>
</div>

Expand Down Expand Up @@ -221,6 +238,12 @@ <h2> Attributes</h2>
<td>(empty)</td>
</tr>

<tr>
<td class="mono-bold">pdf-schema-style</td>
<td class="gray">style to display request and response schemas<br/>can be 'table' or 'object'</td>
<td>object</td>
</tr>

<tr>
<td class="mono-bold">include-info</td>
<td class="gray"> true to include info section in the generated PDF</td>
Expand All @@ -246,7 +269,7 @@ <h2> Attributes</h2>
</tr>

<tr>
<td class="mono-bold">include-api-list </td>
<td class="mono-bold">include-api-list</td>
<td class="gray">true to include list of all the APIs and their summary at the end in the generated PDF </td>
<td>false</td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<rapi-pdf id='rapipdf' spec-url="./examples/specs/test.json" include-info="false" include-security="false" include-toc="false"> </rapi-pdf>
-->
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="table"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/petstore.json" pdf-schema-style="object"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/bitbucket.json"> </rapi-pdf>
<rapi-pdf id='rapipdf' spec-url="./specs/data-types.yaml"> </rapi-pdf>

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"swagger pdf",
"openapi pdf"
],
"main": "src/rapipdf.js",
"module": "src/rapipdf.js",
"main": "./src/rapipdf.js",
"module": "./src/rapipdf.js",
"dependencies": {
"json-refs": "^3.0.13",
"marked": "^0.7.0",
Expand Down
12 changes: 6 additions & 6 deletions src/object-tree-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export function objectToTree(obj, localize, prevKeyDataType = 'object', prevKey
const descrStack = generatePropDescription(propDescrArray, localize);

return [
{ text: prevKey, style: ['sub', 'mono'], margin: 0 },
{ text: (propDescrArray[0] ? propDescrArray[0] : ''), style: ['sub', 'mono', 'lightGray'], margin: 0 },
{ text: prevKey, style: ['small', 'mono'], margin: 0 },
{ text: (propDescrArray[0] ? propDescrArray[0] : ''), style: ['small', 'mono', 'lightGray'], margin: 0 },
{ stack: descrStack, margin: 0 },
];
}
Expand Down Expand Up @@ -345,8 +345,8 @@ export function objectToTableTree(obj, localize, allRows = [], level = 0) {
objType = 'object';
}
const objRow = [
{ text: key, style: ['sub', 'mono', 'b'], margin: [leftMargin, 0, 0, 0] },
{ text: objType, style: ['sub', 'mono', 'lightGray'], margin: 0 },
{ text: key, style: ['small', 'b'], margin: [leftMargin, 0, 0, 0] },
{ text: objType, style: ['small', 'mono', 'lightGray'], margin: 0 },
{ text: '', margin: 0 },
];
allRows.push(objRow);
Expand All @@ -360,8 +360,8 @@ export function objectToTableTree(obj, localize, allRows = [], level = 0) {
const descrStack = generatePropDescription(typeAndDescr, localize);

allRows.push([
{ text: key, style: ['sub', 'mono'], margin: [leftMargin, 0, 0, 0] },
{ text: (typeAndDescr[0] ? typeAndDescr[0] : ''), style: ['sub', 'mono', 'lightGray'], margin: 0 },
{ text: key, style: ['small'], margin: [leftMargin, 0, 0, 0] },
{ text: (typeAndDescr[0] ? typeAndDescr[0] : ''), style: ['small', 'mono', 'lightGray'], margin: 0 },
{ stack: ((descrStack && descrStack.length) > 0 ? descrStack : [{ text: '' }]), margin: 0 },
]);
}
Expand Down
10 changes: 8 additions & 2 deletions src/pdf-parts-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,29 @@ function getResponseDef(responses, schemaStyle, localize) {
responseDef.push(schemaTreeDef);
}
} else {
// If Schema style is Tree
// If Schema style is Table-Tree
let schemaTableTreeDef;
let rootObjectType;
if (schemaInObjectNotaion['::type'] && schemaInObjectNotaion['::type'] === 'array') {
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion['::prop'], localize, 'array');
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion['::props'], localize);
rootObjectType = [{ text: 'ARRAY OF OBJECT WITH BELOW STRUCTURE', style: ['sub', 'b', 'alternate'], colSpan: 3 }];
} else {
schemaTableTreeDef = objectToTableTree(schemaInObjectNotaion, localize);
rootObjectType = [{ text: 'OBJECT WITH BELOW STRUCTURE', style: ['sub', 'b', 'alternate'], colSpan: 3 }];
}
if (schemaTableTreeDef && schemaTableTreeDef.length > 0 && Array.isArray(schemaTableTreeDef[0]) && schemaTableTreeDef[0].length > 0) {
schemaTableTreeDef.unshift(rootObjectType);
schemaTableTreeDef.unshift([
{ text: localize.name, style: ['sub', 'b', 'alternate'] },
{ text: localize.type, style: ['sub', 'b', 'alternate'] },
{ text: localize.description, style: ['sub', 'b', 'alternate'] },
]);

responseDef.push({
table: {
headerRows: 1,
body: schemaTableTreeDef,
dontBreakRows: true,
},
layout: rowLinesTableLayout,
margin: [10, 3, 0, 0],
Expand Down
2 changes: 1 addition & 1 deletion src/spec-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function ProcessSpec(specUrl, sortTags) {
resolvedRefSpec = await JsonRefs.resolveRefs(convertedSpec.openapi, resolveOptions);
jsonParsedSpec = resolvedRefSpec.resolved;
} catch (err) {
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err);
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err); // eslint-disable-line no-console
}

const openApiSpec = jsonParsedSpec;
Expand Down
2 changes: 1 addition & 1 deletion src/table-layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const rowLinesTableLayout = {
return 0;
},
hLineColor(i, node) {
return (i === 0 || i === 1 || i === node.table.body.length) ? 'black' : 'lightgray';
return (i === 0 || i === 1 || i === node.table.body.length) ? '#777' : 'lightgray';
},
};

Expand Down

0 comments on commit d4e6760

Please sign in to comment.