Skip to content
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

fix(spec): render response body for non-200 responses #9555

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/core/plugins/spec/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,19 @@ export const executeRequest = (req) =>
err.name = ""
err.message = "**Failed to fetch.** \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be \"http\" or \"https\" for CORS request."
}
specActions.setResponse(req.pathName, req.method, {
error: true, err: serializeError(err)
})
if (err.response.data !== undefined && err.response.data !== null) {
const res = serializeError(err)
res.response.data = err.response.data
char0n marked this conversation as resolved.
Show resolved Hide resolved
res.response.text = err.response.text
specActions.setResponse(req.pathName, req.method, {
error: true, err: res
})
}
else {
specActions.setResponse(req.pathName, req.method, {
error: true, err: serializeError(err),
})
}
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/plugins/spec/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default {
let newState = state.setIn( [ "responses", path, method ], fromJSOrdered(result) )

// ImmutableJS messes up Blob. Needs to reset its value.
if (win.Blob && res.data instanceof win.Blob) {
if (win.Blob && (res.data instanceof win.Blob || res.err?.response?.data instanceof win.Blob)) {
char0n marked this conversation as resolved.
Show resolved Hide resolved
newState = newState.setIn( [ "responses", path, method, "text" ], res.data)
}
return newState
Expand Down
Loading