File tree 3 files changed +42
-437
lines changed
3 files changed +42
-437
lines changed Original file line number Diff line number Diff line change 30
30
"dependencies" : {
31
31
"@umijs/openapi" : " ^1.2.0" ,
32
32
"serve-static" : " ^1.14.1" ,
33
- "swagger-ui-react " : " ^3.41.1 "
33
+ "swagger-ui-dist " : " ^4.12.0 "
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -51,12 +51,22 @@ export default (api: IApi) => {
51
51
api . writeTmpFile ( {
52
52
path : join ( 'plugin-openapi' , 'openapi.tsx' ) ,
53
53
content : `
54
- import { useState } from "react";
55
- import SwaggerUI from "swagger-ui-react";
56
- import "swagger-ui-react/swagger-ui.css";
54
+ // This file is generated by Umi automatically
55
+ // DO NOT CHANGE IT MANUALLY!
56
+ import { useEffect, useState } from 'react';
57
+ import { SwaggerUIBundle } from 'swagger-ui-dist';
58
+ import 'swagger-ui-dist/swagger-ui.css';
57
59
58
60
const App = () => {
59
- const [value, setValue] = useState("${ config } " || "openapi");
61
+ const [value, setValue] = useState("${ config || 'openapi' } " );
62
+
63
+ useEffect(() => {
64
+ SwaggerUIBundle({
65
+ url: \`/umi-plugins_$\{value}.json\`,
66
+ dom_id: '#swagger-ui',
67
+ });
68
+ }, [value]);
69
+
60
70
return (
61
71
<div
62
72
style={{
@@ -79,10 +89,11 @@ const App = () => {
79
89
} )
80
90
. join ( '\n' ) }
81
91
</select>
82
- <SwaggerUI url={\`/umi-plugins_$\{value}.json\`} />
92
+ <div id="swagger-ui" />
83
93
</div>
84
94
);
85
95
};
96
+
86
97
export default App;
87
98
` ,
88
99
} ) ;
You can’t perform that action at this time.
0 commit comments