Skip to content

Commit

Permalink
fix: try it large responses (stoplightio#2266)
Browse files Browse the repository at this point in the history
* fix: try it large responses

* chore: revert renaming

* fix: move setting undefined before actual response

* chore: comment

* chore: release
  • Loading branch information
Jakub Jankowski authored Oct 25, 2022
1 parent 6ecb29a commit a9475aa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stoplight/elements": "^7.7.2",
"@stoplight/elements": "^7.7.3",
"@stoplight/mosaic": "^1.33.0",
"history": "^5.0.0",
"react": "16.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-core",
"version": "7.7.2",
"version": "7.7.3",
"sideEffects": [
"web-components.min.js",
"src/web-components/**",
Expand Down
8 changes: 6 additions & 2 deletions packages/elements-core/src/components/TryIt/TryIt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,14 @@ export const TryIt: React.FC<TryItProps> = ({
const contentType = response.headers.get('Content-Type');
const type = contentType ? getResponseType(contentType) : undefined;

const bodyText = type !== 'image' ? await response.text() : undefined;
const blob = type === 'image' ? await response.blob() : undefined;

setResponse(undefined); // setting undefined to handle rendering large responses
setResponse({
status: response.status,
bodyText: type !== 'image' ? await response.text() : undefined,
blob: type === 'image' ? await response.blob() : undefined,
bodyText,
blob,
contentType,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/elements-dev-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-dev-portal",
"version": "1.9.2",
"version": "1.9.3",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -64,7 +64,7 @@
]
},
"dependencies": {
"@stoplight/elements-core": "~7.7.2",
"@stoplight/elements-core": "~7.7.3",
"@stoplight/markdown-viewer": "^5.5.0",
"@stoplight/mosaic": "^1.33.0",
"@stoplight/path": "^1.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-dev-portal/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// auto-updated during build
export const appVersion = '1.8.3';
export const appVersion = '1.9.2';
4 changes: 2 additions & 2 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements",
"version": "7.7.2",
"version": "7.7.3",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -62,7 +62,7 @@
]
},
"dependencies": {
"@stoplight/elements-core": "~7.7.2",
"@stoplight/elements-core": "~7.7.3",
"@stoplight/http-spec": "^5.1.4",
"@stoplight/json": "^3.18.1",
"@stoplight/mosaic": "^1.33.0",
Expand Down

0 comments on commit a9475aa

Please sign in to comment.