Skip to content

Commit ce73b05

Browse files
committed
updated examples and test cases
1 parent 505ae96 commit ce73b05

File tree

3 files changed

+57
-39
lines changed

3 files changed

+57
-39
lines changed

docs/examples/auth.html

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
6-
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
7-
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;600&family=Roboto+Mono&display=swap" rel="stylesheet">
8-
<style>
9-
.size { width: 100px; height: 30px; font-size:13px; margin: 0 2px; padding: 0 8px; border-radius: 2px; outline:none; color: #fff;}
10-
.txt {background-color: #2e2e2e; border: 1px solid #2069e0;}
11-
.table{ border:1px solid #444; border-collapse: collapse;}
12-
.table td{ font-size:12px; font-family: 'Roboto Mono'; border: 1px solid #444; padding:8px;}
13-
.table th{ font-size:11px; font-family: 'Open Sans'; border: 1px solid #444; padding:8px; background: #222;}
14-
datalist {
15-
background-color: #222;
16-
border: 1px solid #2069e0;
17-
}
18-
</style>
6+
<script src="./load-rapidoc-and-other-common-scripts.js"></script>
197
</head>
8+
<style>
9+
table {
10+
padding: 8px;
11+
}
12+
th {
13+
height: 36px;
14+
background-color: rgba(0, 0, 0, 0.2);
15+
text-align: left
16+
}
17+
tr {
18+
height: 28px;
19+
}
20+
21+
</style>
2022
<body>
2123
<rapi-doc id="thedoc"
2224
spec-url="../specs/auth.yaml"
@@ -36,23 +38,26 @@ <h3>Programmatically Applying Security and Setting a API Server</h3>
3638
<div style="margin:24px 0 8px 0">
3739
RapiDoc provides you with two helper methods which you can use to supply security keys programatically. You can use one of these method based on the security scheme type
3840
</div>
39-
<table class="table" style="border:1px solid #444; font-family:'Roboto Mono';">
40-
<tr> <th>SCHEME-TYPE</th><th>METHOD USED TO UPDATE</th></tr>
41-
<tr> <td>basic</td><td>setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</td></tr>
42-
<tr> <td>other than basic</td><td style="border-bottom: 1px dashed #383838;" rowspan="3">setApiKey('api_key1', 'newApiToken')</td></tr>
41+
<table class="table" style="border:1px solid #444;width:100%">
42+
<tr> <th style="width:180px; height: 36px;
43+
background-color: rgba(0, 0, 0, 0.2);
44+
text-align: left;">SCHEME-TYPE</th><th>METHOD USED TO UPDATE</th></tr>
45+
<tr> <td>basic</td><td class="mono">setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</td></tr>
46+
<tr> <td>other than basic</td><td class="mono" rowspan="3">setApiKey('api_key1', 'newApiToken')</td></tr>
4347
</table>
4448

4549
<div style="margin:24px 0 8px 0">
4650
The table below list all the scurity schemes included in this spec. Check the corrosponding method that can be used to supply an access-token
4751
</div>
48-
<table class="table" style="border:1px solid #444; font-family:'Roboto Mono'">
49-
<tr><th>SECURITY SCHEME</th><th>SCHEME TYPE</th><th>METHOD USED TO UPDATE</th></tr>
50-
<tr> <td>http-basic</td><td>basic</td> <td>setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</td></tr>
51-
<tr> <td>http-bearer</td><td>bearer</td> <td>setApiKey('http-bearer', 'newToken')</td></tr>
52-
<tr> <td>api_key1</td><td> <span style="color:#777"> (not-specified)</span></td> <td>setApiKey('api_key1', 'newToken')</td></tr>
53-
<tr> <td>api_key2</td><td> <span style="color:#777"> (not-specified)</span></td> <td>setApiKey('api_key2', 'newToken')</td></tr>
54-
<tr> <td>ms-oauth</td><td> <span style="color:#777"> (not-specified)</span></td> <td>setApiKey('ms-oauth', 'newToken')</td></tr>
55-
<tr> <td>api_key_cookie</td><td> <span style="color:#777"> (not-specified)</span></td>
52+
<table class="table" style="border:1px solid #444; width:100%">
53+
<tr> <th style="width:180px">SECURITY SCHEME</th><th>SCHEME TYPE</th><th>METHOD USED TO UPDATE</th></tr>
54+
<tr> <td>http-basic</td> <td>basic</td> <td class="mono">setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</td></tr>
55+
<tr> <td>http-bearer</td> <td> <span style="color:#777"> (not-specified)</span></td> <td class="mono">setApiKey('http-bearer-a', 'newToken')</td></tr>
56+
<tr> <td>http-bearer</td> <td> <span style="color:#777"> (not-specified)</span></td> <td class="mono">setApiKey('http-bearer-b', 'newToken')</td></tr>
57+
<tr> <td>api_key1 </td> <td> <span style="color:#777"> (not-specified)</span></td> <td class="mono">setApiKey('api_key1', 'newToken')</td></tr>
58+
<tr> <td>api_key2 </td> <td> <span style="color:#777"> (not-specified)</span></td> <td class="mono">setApiKey('api_key2', 'newToken')</td></tr>
59+
<tr> <td>ms-oauth </td> <td> <span style="color:#777"> (not-specified)</span></td> <td class="mono">setApiKey('ms-oauth', 'newToken')</td></tr>
60+
<tr> <td>api_key_cookie</td> <td> <span style="color:#777"> (not-specified)</span></td>
5661
<td> <span style="color:#777"> (wont work as this scheme sends api-key in a cookie, and rapidoc dont create/read cookies)</span></td>
5762
</tr>
5863
</table>
@@ -71,22 +76,23 @@ <h3>Programmatically Applying Security and Setting a API Server</h3>
7176
</td>
7277
</tr>
7378
<tr>
74-
<td> API Key</td>
79+
<td>HTTP Bearer / API Key</td>
7580
<td>
7681
<select class='size txt' style="width:138px" id='api-security-scheme-id' placeholder='Security Scheme ID'>
7782
<option value="api_key1">api_key1</option>
7883
<option value="api_key2">api_key2</option>
79-
<option value="http-bearer">http-bearer</option>
84+
<option value="http-bearer-a">Bearer token-a</option>
85+
<option value="http-bearer-b">Bearer token-b</option>
8086
<option value="ms-oauth">ms-oauth</option>
8187
<option value="invalid-key">invalid-key</option>
8288
</select>
8389

84-
<input class='size txt' id='api-key-value' type='text' value="new-token" placeholder='API Key Value' spellcheck='false' >
90+
<input class='txt' style="width:225px" id='api-key-value' type='text' value="new-token" placeholder='API Key Value' spellcheck='false' >
8591
<button class='size btn' style="display: inline;" onclick='setSecurity(event, "apikey")'>Apply</button>
8692
</td>
8793
</tr>
8894
<tr>
89-
<td colspan="2"><button class='size btn' style="width:200px" onclick='clearSecurityKeys(event)'>Clear all Keys</button></td>
95+
<td colspan="2"><button class='size btn' style="width:200px; margin:auto" onclick='clearSecurityKeys(event)'>Clear all Keys</button></td>
9096
</tr>
9197
</table>
9298
<div style="margin:32px 0 16px 0; color:#777; font-weight:bold">

docs/specs/auth.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ paths:
3535
security:
3636
- api_key1: []
3737
- api_key2: []
38-
/fake-api-that-need-basic-and-apikey:
38+
/fake-api-that-need-basic-and-bearer-token-a:
3939
get:
40-
description: API that need API Key and HTTP Basic
40+
description: API that need HTTP Basic and Bearer Token A
4141
security:
4242
- http-basic: []
43-
- http-bearer: []
43+
- http-bearer-a: []
44+
/fake-api-that-need-basic-and-bearer-token-b:
45+
get:
46+
description: API that need HTTP Basic and Bearer Token B
47+
security:
48+
- http-basic: []
49+
- http-bearer-b: []
4450
/fake-api-that-with-complex-security:
4551
get:
4652
description: API with a complex security requirements
@@ -57,9 +63,14 @@ components:
5763
http-basic:
5864
type: http
5965
scheme: basic
60-
http-bearer:
66+
http-bearer-a:
67+
type: http
68+
scheme: bearer
69+
name: token-a
70+
http-bearer-b:
6171
type: http
6272
scheme: bearer
73+
name: token-b
6374
api_key1:
6475
type: apiKey
6576
name: Authorization
@@ -69,8 +80,7 @@ components:
6980
name: specialKey
7081
in: header
7182
api_key_cookie:
72-
description: API Key that should be sent in cookie
73-
authorization filters.
83+
description: API Key that should be sent in cookie authorization filters.
7484
type: apiKey
7585
name: api_key_cookie
7686
in: cookie
@@ -87,7 +97,9 @@ components:
8797
3. Create some users in MS Active Directory
8898
4. Provide permissions to your APP to access MS Graph API which allow you to query the users from MS Active Directory
8999
90-
**OAUTH FLOWS** - There are 4 different OAuth flows. checkout how various oauth flows utilizes `client-id` and `client-secret`
100+
**OAUTH FLOWS**
101+
102+
- There are 4 different OAuth flows. checkout how various oauth flows utilizes `client-id` and `client-secret`
91103
- **Authorization Code** - Requires `client-id` and `client-secret`
92104
- **Client Credentials** - Requires `client-id` and `client-secret`
93105
- **Implicit** - Requires only `client-id`

docs/specs/oauth-demo.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ components:
3131
description: Provides an OAuth token thats valid for long durations
3232
flows:
3333
authorizationCode:
34-
authorizationUrl: https://demo.duendesoftware.com/connect/authorize
35-
tokenUrl: https://demo.duendesoftware.com/connect/token
36-
34+
# using relative url for authorizationCode and token
35+
authorizationUrl: /connect/authorize
36+
tokenUrl: /connect/token
3737
# pre filling client-id, secret and scopes for a specific flow using vendor extension
3838
x-client-id: interactive.confidential
3939
x-client-secret: secret

0 commit comments

Comments
 (0)