Skip to content

Commit 03728e9

Browse files
committed
added localization feature
1 parent 28b18e4 commit 03728e9

12 files changed

+249
-13
lines changed

dist/index.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
6+
<title>RapiPdf</title>
7+
</head>
8+
9+
<body>
10+
<!--
11+
Some sample spec to try
12+
http://10.21.83.83:8080/api/swagger.json
13+
https://api.apis.guru/v2/specs/stripe.com/2019-02-19/swagger.json
14+
https://api.apis.guru/v2/specs/github.com/v3/swagger.json
15+
https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json
16+
https://petstore.swagger.io/v2/swagger.json
17+
https://assets.zuora.com/zuora-documentation/swagger.yaml <<< Large spec with lot of markdown
18+
-->
19+
20+
<rapi-pdf id='rapipdf' style="width:750px; height:40px; font-size:18px"
21+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
22+
pdf-title="New API Reference"
23+
>
24+
<template>
25+
{ "index" : "Translated INDEX"}
26+
</template>
27+
</rapi-pdf>
28+
29+
30+
<button onclick="changeSpec()">Change Spec</button>
31+
<script type="text/javascript">
32+
function changeSpec(){
33+
let el = document.getElementById("rapipdf");
34+
//el.specUrl = 'abcd'
35+
el.setAttribute('spec-url', 'set new attrib');
36+
}
37+
</script>
38+
39+
40+
<script type="text/javascript" src="rapipdf-min.js"></script></body>
41+
42+
</html>

dist/index.html.gz

651 Bytes
Binary file not shown.

dist/rapipdf-min.js

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rapipdf-min.js.gz

1 MB
Binary file not shown.

dist/rapipdf-min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rapipdf-min.js.map.gz

150 Bytes
Binary file not shown.

dist/report.html

Lines changed: 64 additions & 0 deletions
Large diffs are not rendered by default.

docs/index.html

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,44 @@ <h2> Methods</h2>
266266
</tr>
267267
</table>
268268
</div>
269+
270+
<h2> Localization</h2>
271+
<div class="mono-bold" style="text-align: center;">create a &lt;template&gt; inside &lt;rapi-pdf&gt; element and provide the translations</div>
272+
<pre class="shadow code-block"><code class="html" style="border-radius:4px">
273+
&lt;rapi-pdf spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"&gt;
274+
&lt;template&gt;
275+
{
276+
"index" : "INDEX",
277+
"api" : "API",
278+
"apiList" : "API List",
279+
"apiReference" : "API Reference",
280+
"apiVersion" : "API Version",
281+
"contact" : "CONTACT",
282+
"name" : "NAME",
283+
"email" : "EMAIL",
284+
"url" : "URL",
285+
"termsOfService" : "Terms of service",
286+
"securitySchemes": "SECURITY SCHEMES",
287+
"type" : "TYPE",
288+
"description" : "DESCRIPTION",
289+
"request" : "REQUEST",
290+
"requestBody" : "REQUEST BODY",
291+
"response" : "RESPONSE",
292+
"responseModel" : "RESPONSE MODEL",
293+
"statusCode" : "STATUS CODE",
294+
"deprecated" : "DEPRECATED",
295+
"allowed" : "allowed",
296+
"pattern" : "pattern",
297+
"parameters" : "Parameters",
298+
"method" : "METHOD",
299+
"securityAndAuthentication" : "Security and Authentication",
300+
"noRequestParameters" : "No request parameters",
301+
}
302+
&lt;/template&gt;
303+
&lt;/rapi-pdf&gt;
304+
</code>
305+
</pre>
306+
269307
</div>
270308
</div>
271309
<!-- End of API -->
@@ -291,8 +329,6 @@ <h2> Methods</h2>
291329
}
292330
}
293331

294-
295-
296332
</script>
297333
</body>
298334

docs/rapipdf-min.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/welcome.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,44 @@ <h2> Methods</h2>
266266
</tr>
267267
</table>
268268
</div>
269+
270+
<h2> Localization</h2>
271+
<div class="mono-bold" style="text-align: center;">create a &lt;template&gt; inside &lt;rapi-pdf&gt; element and provide the translations</div>
272+
<pre class="shadow code-block"><code class="html" style="border-radius:4px">
273+
&lt;rapi-pdf spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"&gt;
274+
&lt;template&gt;
275+
{
276+
"index" : "INDEX",
277+
"api" : "API",
278+
"apiList" : "API List",
279+
"apiReference" : "API Reference",
280+
"apiVersion" : "API Version",
281+
"contact" : "CONTACT",
282+
"name" : "NAME",
283+
"email" : "EMAIL",
284+
"url" : "URL",
285+
"termsOfService" : "Terms of service",
286+
"securitySchemes": "SECURITY SCHEMES",
287+
"type" : "TYPE",
288+
"description" : "DESCRIPTION",
289+
"request" : "REQUEST",
290+
"requestBody" : "REQUEST BODY",
291+
"response" : "RESPONSE",
292+
"responseModel" : "RESPONSE MODEL",
293+
"statusCode" : "STATUS CODE",
294+
"deprecated" : "DEPRECATED",
295+
"allowed" : "allowed",
296+
"pattern" : "pattern",
297+
"parameters" : "Parameters",
298+
"method" : "METHOD",
299+
"securityAndAuthentication" : "Security and Authentication",
300+
"noRequestParameters" : "No request parameters",
301+
}
302+
&lt;/template&gt;
303+
&lt;/rapi-pdf&gt;
304+
</code>
305+
</pre>
306+
269307
</div>
270308
</div>
271309
<!-- End of API -->

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
pdf-title="New API Reference"
2323
>
2424
<template>
25-
{"index":"Translated INDEX"}
25+
{ "index" : "Translated INDEX"}
2626
</template>
2727
</rapi-pdf>
2828

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rapipdf",
3-
"version": "1.0.5",
3+
"version": "1.1.0",
44
"description": "RapiPdf - Generate PDF from Open API spec",
55
"author": "Mrinmoy Majumdar <mrin9@yahoo.com>",
66
"repository": {

0 commit comments

Comments
 (0)