|
3 | 3 | */ |
4 | 4 | "use client" |
5 | 5 |
|
6 | | -import React, { useEffect, useCallback, useState } from "react" |
| 6 | +import React, { useEffect, useState } from "react" |
7 | 7 | import PropTypes from "prop-types" |
8 | 8 | import SwaggerUIConstructor from "#swagger-ui" |
9 | 9 |
|
@@ -41,46 +41,44 @@ const SwaggerUI = ({ |
41 | 41 | const [system, setSystem] = useState(null) |
42 | 42 | const SwaggerUIComponent = system?.getComponent("App", "root") |
43 | 43 |
|
44 | | - const handleComplete = useCallback(() => { |
45 | | - if (typeof onComplete === "function") { |
46 | | - onComplete() |
47 | | - } |
48 | | - }, [onComplete]) |
49 | | - |
50 | 44 | useEffect(() => { |
51 | | - setSystem( |
52 | | - SwaggerUIConstructor({ |
53 | | - plugins, |
54 | | - spec, |
55 | | - url, |
56 | | - layout, |
57 | | - defaultModelsExpandDepth, |
58 | | - defaultModelRendering, |
59 | | - presets: [SwaggerUIConstructor.presets.apis, ...presets], |
60 | | - requestInterceptor, |
61 | | - responseInterceptor, |
62 | | - onComplete: handleComplete, |
63 | | - docExpansion, |
64 | | - supportedSubmitMethods, |
65 | | - queryConfigEnabled, |
66 | | - defaultModelExpandDepth, |
67 | | - displayOperationId, |
68 | | - tryItOutEnabled, |
69 | | - displayRequestDuration, |
70 | | - requestSnippetsEnabled, |
71 | | - requestSnippets, |
72 | | - showMutatedRequest, |
73 | | - deepLinking, |
74 | | - showExtensions, |
75 | | - showCommonExtensions, |
76 | | - filter, |
77 | | - persistAuthorization, |
78 | | - withCredentials, |
79 | | - ...(typeof oauth2RedirectUrl === "string" |
80 | | - ? { oauth2RedirectUrl: oauth2RedirectUrl } |
81 | | - : {}), |
82 | | - }) |
83 | | - ) |
| 45 | + const systemInstance = SwaggerUIConstructor({ |
| 46 | + plugins, |
| 47 | + spec, |
| 48 | + url, |
| 49 | + layout, |
| 50 | + defaultModelsExpandDepth, |
| 51 | + defaultModelRendering, |
| 52 | + presets: [SwaggerUIConstructor.presets.apis, ...presets], |
| 53 | + requestInterceptor, |
| 54 | + responseInterceptor, |
| 55 | + onComplete: () => { |
| 56 | + if (typeof onComplete === "function") { |
| 57 | + onComplete(systemInstance) |
| 58 | + } |
| 59 | + }, |
| 60 | + docExpansion, |
| 61 | + supportedSubmitMethods, |
| 62 | + queryConfigEnabled, |
| 63 | + defaultModelExpandDepth, |
| 64 | + displayOperationId, |
| 65 | + tryItOutEnabled, |
| 66 | + displayRequestDuration, |
| 67 | + requestSnippetsEnabled, |
| 68 | + requestSnippets, |
| 69 | + showMutatedRequest, |
| 70 | + deepLinking, |
| 71 | + showExtensions, |
| 72 | + showCommonExtensions, |
| 73 | + filter, |
| 74 | + persistAuthorization, |
| 75 | + withCredentials, |
| 76 | + ...(typeof oauth2RedirectUrl === "string" |
| 77 | + ? { oauth2RedirectUrl: oauth2RedirectUrl } |
| 78 | + : {}), |
| 79 | + }) |
| 80 | + |
| 81 | + setSystem(systemInstance) |
84 | 82 | }, []) |
85 | 83 |
|
86 | 84 | useEffect(() => { |
|
0 commit comments