Skip to content

Commit 9d70502

Browse files
committed
Add fetures to replace logo and add external content
1 parent 19f5ebd commit 9d70502

20 files changed

+429
-242
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,33 @@
1414
Custom Eelement for Open-API spec viewing
1515

1616
## Features
17-
- Supports Swagger V2.0 and OpenAPI 3.0
18-
- Allows Personalization, Branding
19-
- Dark and Light Theme
20-
- Easy to use. No build or framework needed
21-
- Lightweight and Fast (under 125 KB gzipped)
22-
- Works with React, Angular and Vue
17+
- Supports Swagger 2.0 and OpenAPI 3.0
18+
- Works with any framework or with no framework
19+
- Allows to make API calls
20+
- Better Usability,
21+
- all Models and Examples are expanded by default, eliminates the need to click and reveal.
22+
- Request fields are pre-populated with sample data
23+
- Takes only one click to make an API call
24+
- Request and response can be placed side-by-side for easy comparision
25+
- Branding and Personalization features makes it easy to follow any style guide
26+
- Comes with 2 Themes (Dark and Light)
27+
- Replace default logo with yours
28+
- Typography, allows changing fonts
29+
- Allows changing text-color, button-color, header-color and color of other UI elements
30+
- Plenty of customization options
31+
- Add external contents at the top and bottom of the document, you may add images, link, text, forms etc
32+
- Allows disabling API calling feature
33+
- Hide the header so the user cant load any other OpenAPI Spec
34+
- Hide Authentication and provide your own pre-generated api-key
35+
- Embed it inside another HTML document
36+
- Use it inside another framework (react, vue, angular, lit-element)
37+
- Use JavaScript to change its attributes, and it will react to those changes
38+
- Style the element with standard css (change padding, position, border, margin )
39+
- Lightweight and fast (under 125 KB gzipped)
40+
- Load local json spec from the disk
2341
- Supported on Chrome, FireFox and Safari. (Not yet tested on Edge)
2442

43+
2544
## Documentation
2645
[Check out the usage and examples](https://mrin9.github.io/RapiDoc/)
2746

dist/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@
7070
<rapi-doc spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
7171
theme="light"
7272
show-info="false"
73-
show-header="false"
74-
></rapi-doc>
73+
>
74+
<img slot="logo" src="https://img.icons8.com/color/48/000000/picture.png">
75+
<p slot="top">Hey this content is added from outside</p>
76+
<p slot="bottom">Hey this content is added from outside</p>
77+
78+
</rapi-doc>
7579
<script type="text/javascript" src="rapidoc-min.js"></script></body>
7680

7781
</html>

dist/index.html.gz

77 Bytes
Binary file not shown.

dist/rapidoc-min.js

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

dist/rapidoc-min.js.gz

132 Bytes
Binary file not shown.

dist/rapidoc-min.js.map

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

dist/rapidoc-min.js.map.gz

130 Bytes
Binary file not shown.

dist/report.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/README.md

Lines changed: 125 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
## Easy Usage
2-
No Build steps!, No Frameworks!, Just copy the below script in an html, and open it in a browser !!!
3-
4-
### Use from CDN
1+
## OpenAPI Spec Viewer
2+
3+
### Features
4+
- Supports swagger 2.0 and OpenAPI 3.0
5+
- Works with any framework
6+
- Allows to make API calls
7+
- Better Usability,
8+
- all Models and Examples are expanded by default, eliminates the need to click and reveal.
9+
- Request fields are pre-populated with sample data
10+
- Takes only one click to make an API call
11+
- Request and response can be placed side-by-side for easy comparison
12+
- Branding and Personalization features makes it easy to follow any style guide
13+
- Comes with 2 Themes (Dark and Light)
14+
- Replace default logo with yours
15+
- Typography, allows changing fonts
16+
- Allows changing text-color, button-color, header-color and color of other UI elements
17+
- Plenty of customization options
18+
- Add external contents at the top and bottom of the document, you may add tables, images, link, text, forms etc
19+
- Allows disabling API calling feature
20+
- Hide the header so the user cant load any other OpenAPI Spec
21+
- Hide Authentication and provide your own pre-generated api-key
22+
- Embed it inside another HTML document
23+
- Use it inside another framework (react, vue, angular, lit-element)
24+
- Programmatically control the element using JavaScript - change its attributes, and it will react to those changes
25+
- Style the element with standard css (change padding, position, border, margin )
26+
- Lightweight and fast (under 125 KB gzipped)
27+
- Load local json spec from the disk
28+
29+
### Quickstart (Use from CDN)
30+
Just copy the below script in an html, and open it in a browser !!!
531
```html
632
<html>
733
<head>
@@ -16,6 +42,94 @@ No Build steps!, No Frameworks!, Just copy the below script in an html, and open
1642
</html>
1743
```
1844

45+
### Demo & Examples
46+
47+
- [Basic Example](example1.html)
48+
```html
49+
<rapi-doc
50+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
51+
> </rapi-doc>
52+
```
53+
54+
- [Dark Theme](example2.html)
55+
```html
56+
<rapi-doc
57+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
58+
theme="dark"
59+
> </rapi-doc>
60+
```
61+
62+
- [Change Header Color with Dark Theme](example3.html)
63+
```html
64+
<rapi-doc
65+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
66+
header-color="#2d87e2"
67+
theme="dark"
68+
> </rapi-doc>
69+
```
70+
71+
- [Integrate with any HTML document (Request/Response one below the other)](example4.html)
72+
```html
73+
<rapi-doc
74+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
75+
theme='dark'
76+
show-header='false'
77+
show-info='false'
78+
show-authentication='false'
79+
theme='dark'
80+
layout="column"
81+
> </rapi-doc>
82+
```
83+
84+
- [Change Font (you may use local fonts or define your own font)](example5.html)
85+
```html
86+
<head>
87+
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
88+
</head>
89+
<body>
90+
<rapi-doc
91+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
92+
regular-font="'Varela Round', 'Arial Rounded MT Bold', 'Helvetica Rounded' "
93+
> </rapi-doc>
94+
</body>
95+
```
96+
97+
- [Change Logo](example6.html)
98+
```html
99+
<body>
100+
<rapi-doc spec-url="https://api.apis.guru/v2/specs/googleapis.com/youtube/v3/swagger.json">
101+
<img slot="logo" src="https://img.icons8.com/color/48/000000/youtube-play.png">
102+
</rapi-doc>
103+
</body>
104+
```
105+
106+
- [Add HTML content inside the spec](example7.html)
107+
```html
108+
<body>
109+
<rapi-doc spec-url="https://api.apis.guru/v2/specs/googleapis.com/youtube/v3/swagger.json">
110+
111+
<!-- content at the top -->
112+
<p>This is an example to add external html content </li>
113+
<p>Ypu may add </li>
114+
<ul>
115+
<li> Table </li>
116+
<li> Text </li>
117+
<li> Images </li>
118+
<li> Links </li>
119+
<li> any HTML content </li>
120+
</ul>
121+
122+
<!-- content at the bottom -->
123+
<p slot="footer"> This content will apear at the bottom </p>
124+
</rapi-doc>
125+
</body>
126+
```
127+
128+
129+
130+
- [Change Attributes using JavaScript](example100.html)
131+
use javascript `Element.setAttribute()` to change the elements attributes and see it reacts to those changes
132+
19133
### Use in a HTML/JS based project
20134

21135
- In your project folder, install rapidoc from npm.
@@ -51,10 +165,6 @@ npm install http-server -g
51165

52166
- in your browser visit ```http://localhost:9000/index.html```
53167

54-
55-
## Branding, Styling and Personalization
56-
Style the element using standard `css`. Apply borders, padding, width, height etc in accordance to your brand requierment. You can also use many attributes to effect the interface.
57-
58168
## Attributes
59169
<table>
60170
<tr><th>Attribute</th> <th>Description </th> <th>Default</th></tr>
@@ -104,57 +214,10 @@ Style the element using standard `css`. Apply borders, padding, width, height et
104214
<tr><td>layout </td> <td>request/response placement (row, column)</td> <td>row</td></tr>
105215
</table>
106216

107-
## Examples
108-
109-
- [Basic Example](example1.html)
110-
```html
111-
<rapi-doc
112-
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
113-
> </rapi-doc>
114-
```
115-
116-
- [Dark Theme](example2.html)
117-
```html
118-
<rapi-doc
119-
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
120-
theme="dark"
121-
> </rapi-doc>
122-
```
123-
124-
- [Change Header Color with Dark Theme](example3.html)
125-
```html
126-
<rapi-doc
127-
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
128-
header-color="#2d87e2"
129-
theme="dark"
130-
> </rapi-doc>
131-
```
132-
133-
- [Integrate with any HTML document (Request/Response one below the other)](example4.html)
134-
```html
135-
<rapi-doc
136-
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
137-
theme='dark'
138-
show-header='false'
139-
show-info='false'
140-
show-authentication='false'
141-
theme='dark'
142-
layout="column"
143-
> </rapi-doc>
144-
```
145-
146-
- [Change Font (you may use local fonts or define your own font)](example5.html)
147-
```html
148-
<head>
149-
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
150-
</head>
151-
<body>
152-
<rapi-doc
153-
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
154-
regular-font="'Varela Round', 'Arial Rounded MT Bold', 'Helvetica Rounded' "
155-
> </rapi-doc>
156-
</body>
157-
```
158-
159-
- [Change Attributes using JavaScript](example6.html)
160-
217+
## Slots
218+
<table>
219+
<tr><th>Slot Name</th> <th>Description </th></tr>
220+
<tr><td>(default)</td> <td>any content placed inside `<rapi-doc>` will be shown under the header </td> </tr>
221+
<tr><td>logo</td> <td>use this slot to replace the logo </td> </tr>
222+
<tr><td>footer</td> <td> The conents of this slot will appear at the bottom of the spec</td> </tr>
223+
</table>

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
theme: jekyll-theme-cayman
22
markdown: kramdown
3-
title: RapiDoc Custom Element
3+
title: <rapi-doc/>
44
google_analytics: UA-132775238-1

0 commit comments

Comments
 (0)