Skip to content

Commit a378f85

Browse files
committed
HDDS-10684.Fix configurable server URL, remove unused code, update broken link
1 parent 89b2032 commit a378f85

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

docs/03-core-concepts/01-architecture/06-recon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Recon can integrate with any Prometheus instance configured to collected metrics
5252

5353
## API Reference
5454

55-
[Link to complete API Reference](../../05-administrator-guide/03-operations/09-observability/02-recon/02-recon-rest-api.md)
55+
[Link to complete API Reference](../../05-administrator-guide/03-operations/09-observability/02-recon/02-recon-rest-api.mdx)
5656

5757
## Persisted state
5858

docs/05-administrator-guide/03-operations/09-observability/02-recon/02-recon-rest-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Ozone Recon's public **REST API** follows the [OpenAPI specification](https://ww
1010
You can test these APIs directly from this page using the "Try it out" button on each endpoint.
1111

1212
- **Default server**: `http://localhost:9888` (matches the [Docker quick start guide](/docs/quick-start/installation/docker))
13-
- **Custom server**: Update the "Recon Server URL" field above to point to your own Recon instance
13+
- **Custom server**: Update the "Recon Server URL" field below to point to your own Recon instance
1414
- **Local instance**: If you're running Recon locally, you can also access the interactive Swagger UI at `http://localhost:9888/api/v1/`
1515
:::
1616

src/components/SwaggerUI/index.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import React, { useState, useEffect } from 'react';
20+
import React, { useState, useRef, useEffect } from 'react';
2121
import SwaggerUI from 'swagger-ui-react';
2222
import 'swagger-ui-react/swagger-ui.css';
2323
import useBaseUrl from '@docusaurus/useBaseUrl';
@@ -26,23 +26,20 @@ import styles from './styles.module.css';
2626
export default function SwaggerUIComponent({ spec, defaultServer }) {
2727
const specUrl = useBaseUrl(spec);
2828
const [serverUrl, setServerUrl] = useState(defaultServer || 'http://localhost:9888');
29-
const [specData, setSpecData] = useState(null);
29+
const swaggerSystemRef = useRef(null);
3030

31+
// Update the server URL in Swagger whenever serverUrl changes
3132
useEffect(() => {
32-
// Fetch the spec and modify the servers array
33-
fetch(specUrl)
34-
.then(response => response.text())
35-
.then(text => {
36-
// Parse YAML to JSON (simple approach for this case)
37-
// Since swagger-ui-react can handle YAML, we'll pass the URL
38-
// but configure servers via the spec modification
39-
return fetch(specUrl).then(r => r.json().catch(() => {
40-
// If JSON parsing fails, it's YAML, use the URL directly
41-
return null;
42-
}));
43-
})
44-
.catch(() => null);
45-
}, [specUrl]);
33+
if (swaggerSystemRef.current) {
34+
const spec = swaggerSystemRef.current.getState().getIn(['spec', 'json']);
35+
if (spec) {
36+
swaggerSystemRef.current.specActions.updateJsonSpec({
37+
...spec.toJS(),
38+
servers: [{ url: serverUrl, description: 'Configured Recon Server' }]
39+
});
40+
}
41+
}
42+
}, [serverUrl]);
4643

4744
return (
4845
<div className={styles.swaggerWrapper}>
@@ -68,7 +65,9 @@ export default function SwaggerUIComponent({ spec, defaultServer }) {
6865
defaultModelsExpandDepth={1}
6966
defaultModelExpandDepth={1}
7067
onComplete={(system) => {
71-
// Override the servers in the spec with the user-configured URL
68+
// Store the system reference for later updates
69+
swaggerSystemRef.current = system;
70+
// Set initial server URL
7271
const spec = system.getState().getIn(['spec', 'json']);
7372
if (spec) {
7473
system.specActions.updateJsonSpec({

0 commit comments

Comments
 (0)