Skip to content

Commit cd219ae

Browse files
committed
Added attribute "allow-server-selection" to the rapi-doc component
1 parent 4e1ffdd commit cd219ae

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

docs/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ <h2> Attributes</h2>
333333
<td>true</td>
334334
</tr>
335335

336+
<tr>
337+
<td class="mono-bold right">allow-server-selection</td>
338+
<td class="gray">
339+
If set to 'false', user will not be able to select API server.
340+
The URL specified in the server-url attribute will be used if set, else the first server in the API specification file will be used.
341+
</td>
342+
<td>true</td>
343+
</tr>
344+
336345
<tr>
337346
<td class="mono-bold right">show-info</td>
338347
<td class="gray">

docs/rapidoc-min.js

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

docs/welcome.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ <h2> Attributes</h2>
333333
<td>true</td>
334334
</tr>
335335

336+
<tr>
337+
<td class="mono-bold right">allow-server-selection</td>
338+
<td class="gray">
339+
If set to 'false', user will not be able to select API server.
340+
The URL specified in the server-url attribute will be used if set, else the first server in the API specification file will be used.
341+
</td>
342+
<td>true</td>
343+
</tr>
344+
336345
<tr>
337346
<td class="mono-bold right">show-info</td>
338347
<td class="gray">

src/rapidoc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export default class RapiDoc extends LitElement {
198198
</div>`
199199
}
200200
201-
${(this.allowTry === 'false' || !this.resolvedSpec) ? '' : this.apiServerListTemplate()}
201+
${(this.allowTry === 'false' || this.allowServerSelection === 'false' || !this.resolvedSpec) ? '' : this.apiServerListTemplate()}
202202
${(this.allowAuthentication === 'false' || !this.resolvedSpec || !this.resolvedSpec.securitySchemes) ? '' : this.securitySchemeTemplate()}
203203
${this.resolvedSpec && this.resolvedSpec.tags ? this.endpointsGroupedByTagTemplate() : ''}
204204
@@ -340,6 +340,7 @@ export default class RapiDoc extends LitElement {
340340
showInfo: { type: String, attribute: 'show-info' },
341341
allowAuthentication: { type: String, attribute: 'allow-authentication' },
342342
allowTry: { type: String, attribute: 'allow-try' },
343+
allowServerSelection: { type: String, attribute: 'allow-server-selection' },
343344
allowSpecUrlLoad: { type: String, attribute: 'allow-spec-url-load' },
344345
allowSpecFileLoad: { type: String, attribute: 'allow-spec-file-load' },
345346
allowSearch: { type: String, attribute: 'allow-search' },
@@ -436,6 +437,13 @@ export default class RapiDoc extends LitElement {
436437

437438
afterSpecParsedAndValidated(spec) {
438439
this.resolvedSpec = spec;
440+
if (this.allowServerSelection === 'false') {
441+
if (this.serverUrl) {
442+
this.selectedServer = this.serverUrl;
443+
} else if (this.resolvedSpec && this.resolvedSpec.servers && this.resolvedSpec.servers.length > 0) {
444+
this.selectedServer = this.resolvedSpec.servers[0].url;
445+
}
446+
}
439447
this.requestUpdate();
440448
window.setTimeout(() => {
441449
this.onApiServerChange();

0 commit comments

Comments
 (0)