File tree 7 files changed +1582
-1553
lines changed
docusaurus-plugin-redoc/src
docusaurus-theme-redoc/src
7 files changed +1582
-1553
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' docusaurus-plugin-redoc ' : patch
3
+ ' docusaurus-theme-redoc ' : patch
4
+ ---
5
+
6
+ Fix reloads in dev mode
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ export default function redocPlugin(
122
122
const data : SpecProps = {
123
123
url,
124
124
themeId,
125
+ isSpecFile,
125
126
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126
127
spec : content . converted as any ,
127
128
} ;
@@ -133,7 +134,7 @@ export default function redocPlugin(
133
134
: options . route ;
134
135
135
136
const specProps = await createData (
136
- `redocApiSpecV1.1 -${ options . id || '1' } .json` ,
137
+ `redocApiSpecV1.2 -${ options . id || '1' } .json` ,
137
138
JSON . stringify ( data ) ,
138
139
) ;
139
140
const layoutProps = await createData (
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import clsx from 'clsx' ;
3
3
import '../../global' ;
4
- import { Redoc as RedocComponent , RedocRawOptions } from 'redoc' ;
4
+ import {
5
+ Redoc as RedocComponent ,
6
+ RedocStandalone ,
7
+ RedocRawOptions ,
8
+ } from 'redoc' ;
5
9
import { SpecProps } from '../../types/common' ;
6
10
import { useSpec } from '../../utils/useSpec' ;
7
11
import { ServerStyles } from './Styles' ;
@@ -25,6 +29,22 @@ function Redoc(
25
29
optionsOverrides ,
26
30
) ;
27
31
32
+ const isDevMode = process . env . NODE_ENV === 'development' ;
33
+
34
+ if ( isDevMode && specProps . isSpecFile === false ) {
35
+ return (
36
+ < div
37
+ className = { clsx ( [
38
+ 'redocusaurus' ,
39
+ hasLogo && 'redocusaurus-has-logo' ,
40
+ className ,
41
+ ] ) }
42
+ >
43
+ < RedocStandalone specUrl = { specProps . url } options = { store . rawOptions } />
44
+ </ div >
45
+ ) ;
46
+ }
47
+
28
48
return (
29
49
< >
30
50
< ServerStyles
Original file line number Diff line number Diff line change @@ -58,9 +58,9 @@ export function ServerStyles({
58
58
lightThemeOptions,
59
59
darkThemeOptions,
60
60
} : {
61
- specProps : SpecProps ,
62
- lightThemeOptions : RedocRawOptions ,
63
- darkThemeOptions : RedocRawOptions ,
61
+ specProps : SpecProps ;
62
+ lightThemeOptions : RedocRawOptions ;
63
+ darkThemeOptions : RedocRawOptions ;
64
64
} ) {
65
65
const fullUrl = useBaseUrl ( specProps . url , { absolute : true } ) ;
66
66
const css = {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export type ParsedSpec = OpenAPISpec;
7
7
export interface SpecProps {
8
8
spec : ParsedSpec ;
9
9
url ?: string ;
10
+ isSpecFile ?: boolean ;
10
11
themeId ?: string ;
11
12
}
12
13
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ interface SpecProps {
2
2
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3
3
spec : import ( 'redoc/typings/types' ) . OpenAPISpec ;
4
4
url ?: string ;
5
+ isSpecFile ?: boolean ;
5
6
themeId ?: string ;
6
7
}
7
8
You can’t perform that action at this time.
0 commit comments