Open pratikthanki opened 3 years ago
I'm running into a similar issue but I get this error when I pass a json object into a spec
prop:
Ah interesting, I think I have read/come across this. Does your swagger spec reference another spec by any chance?
If so, you will need to consolidate them, you can use speccy (for example) to do this: https://github.com/wework/speccy
@pratikthanki could you share a code snippet on how you pass the loaded spec to RedocStandalone
?
Yeah sure @RomanHotsiy, the getJson
function is in another file (described above).
The swagger spec I am using is here: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/api-with-examples.json
When I pass it to specUrl
it works perfectly.
class App extends Component {
state = {
data: {}
}
componentDidMount() {
getJson(url)
.then(response => {
this.setState({
data: response
});
});
}
render() {
return (
<div className="App">
<RedocStandalone
spec={response}
options={{
nativeScrollbars: true,
disableSearch: false,
hideDownloadButton: true,
sortPropsAlphabetically: true,
pathInMiddlePanel: true,
theme: { colors: { primary: { main: '#61affe' } } },
}}
/>
</div>
);
}
}
export default App;
Hi
When looking to use
RedocStandalone
, passing a json object tospec
results in incorrect behaviour.I am using a spec from: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/api-with-examples.json
ReDoc Version:
2.0.0-rc.45
npm --version:6.14.8
Expected Output
Provide either:
spec
specUrl
Should result in the docs being displayed.
Current Output
I get the following error:
Interestingly, passing the url to either
spec
orspecUrl
it works.The way I am downloading the json:
When I
console.log
the output looks correct:Any thoughts on this are appreciated - thanks!