Skip to content

Commit

Permalink
fixes #769 - response xml formating performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Jun 11, 2022
1 parent 89736ea commit 25271cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"buffer": "^6.0.3",
"lit": "^2.2.5",
"marked": "^4.0.16",
"prismjs": "^1.28.0"
"prismjs": "^1.28.0",
"xml-but-prettier": "^1.0.1"
},
"scripts": {
"build": "NODE_ENV=production webpack --mode=production",
Expand All @@ -58,7 +59,7 @@
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^10.0.0",
"css-loader": "^6.7.1",
"eslint": "^8.16.0",
"eslint": "^8.17.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.26.0",
Expand All @@ -68,12 +69,12 @@
"html-webpack-plugin": "^5.5.0",
"inspectpack": "^4.7.1",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.1",
"terser-webpack-plugin": "^5.3.3",
"unminified-webpack-plugin": "^3.0.0",
"webpack": "^5.72.1",
"webpack": "^5.73.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.0"
"webpack-dev-server": "^4.9.2"
},
"engines": {
"node": ">=10.21.0"
Expand Down
8 changes: 5 additions & 3 deletions src/components/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-li
import { guard } from 'lit/directives/guard.js'; // eslint-disable-line import/extensions
import { live } from 'lit/directives/live.js'; // eslint-disable-line import/extensions
import { marked } from 'marked';
import formatXml from 'xml-but-prettier';
import Prism from 'prismjs';
import TableStyles from '~/styles/table-styles';
import FlexStyles from '~/styles/flex-styles';
Expand All @@ -12,7 +13,7 @@ import BorderStyles from '~/styles/border-styles';
import TabStyles from '~/styles/tab-styles';
import PrismStyles from '~/styles/prism-styles';
import CustomStyles from '~/styles/custom-styles';
import { copyToClipboard, prettyXml, downloadResource, viewResource } from '~/utils/common-utils';
import { copyToClipboard, downloadResource, viewResource } from '~/utils/common-utils';
import { schemaInObjectNotation,
getTypeInfo,
generateExample,
Expand Down Expand Up @@ -1449,9 +1450,10 @@ export default class ApiRequest extends LitElement {
} else {
respText = await fetchResponse.text();
if (contentType.includes('xml')) {
this.responseText = prettyXml(respText);
this.responseText = formatXml(respText, { textNodesOnSameLine: true, indentor: ' ' });
} else {
this.responseText = respText;
}
this.responseText = respText;
}
if (this.responseIsBlob) {
const contentDisposition = fetchResponse.headers.get('content-disposition');
Expand Down
5 changes: 1 addition & 4 deletions src/utils/common-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function advancedSearch(searchVal, allSpecTags, searchOptions = []) {
return pathsMatched;
}

/*
export function prettyXml(sourceXmlString) {
const xmlDoc = new DOMParser().parseFromString(sourceXmlString, 'text/xml');
const xsltDoc = new DOMParser().parseFromString([
Expand All @@ -144,10 +145,6 @@ export function prettyXml(sourceXmlString) {
const resultDoc = xsltProcessor.transformToDocument(xmlDoc);
return new XMLSerializer().serializeToString(resultDoc);
}
/*
export function hasValidPathInUrlHash(tags) {
return tags.find((tag) => tag.paths.find((path) => window.location.hash.substring(1) === path.elementId));
}
*/

export function downloadResource(url, fileName) {
Expand Down

0 comments on commit 25271cf

Please sign in to comment.