|
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
7 | 7 | <meta name="description" content="SwaggerUI" /> |
8 | 8 | <title>SwaggerUI</title> |
9 | | - <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" /> |
| 9 | + <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.15.5/swagger-ui.css" /> |
10 | 10 | </head> |
11 | 11 |
|
12 | 12 | <body> |
13 | 13 | <div id="swagger-ui"></div> |
14 | | - <script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script> |
| 14 | + <script src="https://unpkg.com/swagger-ui-dist@4.15.5/swagger-ui-bundle.js" crossorigin></script> |
15 | 15 | <script> |
16 | 16 | // @see: https://stackoverflow.com/a/68871496 |
17 | 17 | // Examples map |
|
46 | 46 | } |
47 | 47 |
|
48 | 48 | // Custom plugin for the logic that happens before the response element is created |
49 | | - const CustomPlugin = () => { |
| 49 | + const ExtrenalSchemaPopulatePlugin = () => { |
50 | 50 | return { |
51 | 51 | wrapComponents: { |
52 | 52 | RequestBody: (Original, { React, oas3Actions, oas3Selectors }) => (props) => { |
|
62 | 62 | } else { |
63 | 63 | const resolveData = (data) => { |
64 | 64 | // Dirtly parse content |
65 | | - const ref = data.paths[Object.keys(data.paths)[0]].post.requestBody.content[contentType].schema["$ref"]; |
| 65 | + const method = "post"; |
| 66 | + const ref = data.paths[Object.keys(data.paths)[0]][method].requestBody.content[contentType].schema["$ref"]; |
66 | 67 | const component = ref.split("/").pop(); |
67 | 68 | // Put downloaded file content into the examples map |
68 | 69 | examples[externalValueUrlKey] = { |
|
100 | 101 | props.response = parseSchemaObject(props.response, examples[externalValueUrlKey].schema, contentType) |
101 | 102 | } else { |
102 | 103 | const resolveData = (data) => { |
103 | | - const ref = data.paths[Object.keys(data.paths)[0]][props.method].responses[Number(props.code)].content[contentType].schema["$ref"]; |
| 104 | + let method = props.method; |
| 105 | + if (method === "get" && props.path.startsWith("/testbed/productizer")) { |
| 106 | + method = "post"; |
| 107 | + } |
| 108 | + const ref = data.paths[Object.keys(data.paths)[0]][method].responses[Number(props.code)].content[contentType].schema["$ref"]; |
104 | 109 | const component = ref.split("/").pop(); |
105 | 110 | // Put downloaded file content into the examples map |
106 | 111 | examples[externalValueUrlKey] = { |
|
145 | 150 |
|
146 | 151 | window.onload = () => { |
147 | 152 | window.ui = SwaggerUIBundle({ |
148 | | - url: '/openapi.yml', |
| 153 | + url: '/openapi.json', |
149 | 154 | dom_id: '#swagger-ui', |
150 | 155 | plugins: [ |
151 | 156 | SwaggerUIBundle.plugins.DownloadUrl, |
152 | 157 | // Add custom plugin |
153 | | - CustomPlugin |
| 158 | + ExtrenalSchemaPopulatePlugin |
| 159 | + ], |
| 160 | + layout: "BaseLayout", |
| 161 | + deepLinking: true, |
| 162 | + presets: [ |
| 163 | + SwaggerUIBundle.presets.apis, |
| 164 | + SwaggerUIBundle.SwaggerUIStandalonePreset |
154 | 165 | ], |
155 | 166 | }); |
156 | 167 | }; |
|
0 commit comments