-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not resolve reference: JSON Pointer evaluation failed while evaluating token "components" against an unexpected Element #10191
Comments
Update: This seems to be the same issue as: #9304 which was maked as fixed. I guess swagger-ui-react is still using the old version api-dom? The issue: when the BROWSER url (not any url in the spec) contains an escape sequence, swagger-ui stopps being able to resolve the pointers. |
Here's how I got around the issue. I'm now rendering import { ContentHeightContainer } from "@/components/layout-right-drawer";
import { EditorInputProps } from "@/components/module-api-editor/types";
import { useEffect, useRef } from "react";
export function VisualPreviewOpenAPI(props: EditorInputProps) {
const iframeRef = useRef<HTMLIFrameElement>(null);
useEffect(() => {
const iframe = iframeRef.current;
if (!iframe) return;
// Create the HTML content
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.17.14/swagger-ui.css">
<base href="${window.location.origin}" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.11.0/swagger-ui-bundle.js"></script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
spec: ${JSON.stringify(props.value.data)},
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
layout: "BaseLayout",
deepLinking: false,
});
}
</script>
</body>
</html>
`;
// Create a blob URL from the HTML content
const blob = new Blob([html], { type: "text/html" });
const blobUrl = URL.createObjectURL(blob);
// Set the iframe src to the blob URL
iframe.src = blobUrl;
// Clean up the blob URL when the component unmounts
return () => {
URL.revokeObjectURL(blobUrl);
};
}, [props.value.data]);
return (
<ContentHeightContainer>
<iframe
ref={iframeRef}
style={{
width: "100%",
height: "100%",
border: "none",
minHeight: "500px",
}}
sandbox="allow-scripts"
/>
</ContentHeightContainer>
);
} |
General:
Content & configuration
Whenever I try to resolve a component schema:
Describe the bug you're encountering
In my current app, swagger-ui it not able to resolve references whenever an escape sequence is present in my apps query parameters (not in the spec).
This is a dublicate of #9304 . The fix in the issue does not seem to work. Api-dom is locked on version
1.0.0-alpha.10
(after the supposed fix)To reproduce...
?activeElement=%7B"type"%3A"create_client"%7D
What I have tried
The text was updated successfully, but these errors were encountered: