File tree Expand file tree Collapse file tree 3 files changed +11
-14
lines changed
javascripts/discourse/api-initializers Expand file tree Collapse file tree 3 files changed +11
-14
lines changed Original file line number Diff line number Diff line change
1
+ rapidoc-9.3.4.min.js
Original file line number Diff line number Diff line change @@ -6,17 +6,15 @@ Based off the nice official [Discourse mermaid component](https://github.com/dis
6
6
7
7
To use it ...
8
8
9
- * [ install it] ( https://meta.discourse.org/t/install-a-theme-or-theme-component/63682 ) into your Discourse instance
10
- * in a topic, create a code block and use ` apidoc ` as language tag and the URL of an OpenAPI specification url as the block's content.
9
+ - [ install it] ( https://meta.discourse.org/t/install-a-theme-or-theme-component/63682 ) into your Discourse instance
10
+ - in a topic, create a code block and use ` apidoc ` as language tag and the URL of an OpenAPI specification url as the block's content.
11
11
12
- ```
12
+ ````
13
13
```apidoc
14
14
https://petstore.swagger.io/v2/swagger.json
15
- ```
16
-
15
+ ````
17
16
18
17
If specification is not publicly accessible, you can attach the specification file to your post and copy the URL after the file has been uploaded.
19
18
20
-
21
19
Here's how it could look like
22
- ![ rapidoc in discourse] ( image.png )
20
+ ![ rapidoc in discourse] ( image.png )
Original file line number Diff line number Diff line change 1
1
import { apiInitializer } from "discourse/lib/api" ;
2
2
import loadScript from "discourse/lib/load-script" ;
3
- import discourseDebounce from "discourse-common/lib/debounce" ;
4
3
5
4
async function applyRapidoc ( element ) {
6
5
const apidocs = element . querySelectorAll ( "pre[data-code-wrap=apidoc]" ) ;
@@ -12,11 +11,10 @@ async function applyRapidoc(element) {
12
11
await loadScript ( settings . theme_uploads_local . rapidoc_js ) ;
13
12
14
13
const theme =
15
- getComputedStyle ( document . body )
16
- . getPropertyValue ( "--scheme-type" )
17
- . trim ( ) === "dark"
14
+ getComputedStyle ( document . body ) . getPropertyValue ( "--scheme-type" ) . trim ( ) ===
15
+ "dark"
18
16
? "dark"
19
- : "default"
17
+ : "default" ;
20
18
21
19
apidocs . forEach ( ( apidoc ) => {
22
20
if ( apidoc . dataset . processed ) {
@@ -31,7 +29,7 @@ async function applyRapidoc(element) {
31
29
return ;
32
30
}
33
31
34
- const promise = new Promise ( resolve => resolve ( codeBlock . textContent ) )
32
+ const promise = new Promise ( ( resolve ) => resolve ( codeBlock . textContent ) ) ;
35
33
promise
36
34
. then ( ( spec ) => {
37
35
apidoc . outerHTML = `
@@ -45,7 +43,7 @@ async function applyRapidoc(element) {
45
43
allow-api-list-style-selection="false"
46
44
allow-spec-file-download="true"
47
45
allow-authentication="true"
48
- theme="${ theme === ' dark' ? ' dark' : ' light' } "
46
+ theme="${ theme === " dark" ? " dark" : " light" } "
49
47
>
50
48
</rapi-doc>
51
49
<br/>
You can’t perform that action at this time.
0 commit comments