mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
chore: minor perf optimizations
This commit is contained in:
parent
5248415791
commit
56ddce1b11
|
@ -101,6 +101,9 @@ export class AppStore {
|
||||||
dispose() {
|
dispose() {
|
||||||
this.scroll.dispose();
|
this.scroll.dispose();
|
||||||
this.menu.dispose();
|
this.menu.dispose();
|
||||||
|
if (this.search) {
|
||||||
|
this.search.dispose();
|
||||||
|
}
|
||||||
if (this.disposer != null) {
|
if (this.disposer != null) {
|
||||||
this.disposer();
|
this.disposer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,10 @@ export class SearchStore<T> {
|
||||||
this.searchWorker.add(title, body, meta);
|
this.searchWorker.add(title, body, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
(this.searchWorker as any).terminate();
|
||||||
|
}
|
||||||
|
|
||||||
search(q: string) {
|
search(q: string) {
|
||||||
return this.searchWorker.search<T>(q);
|
return this.searchWorker.search<T>(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class MediaContentModel {
|
||||||
* @param isRequestType needed to know if skipe RO/RW fields in objects
|
* @param isRequestType needed to know if skipe RO/RW fields in objects
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
public parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
info: Dict<OpenAPIMediaType>,
|
info: Dict<OpenAPIMediaType>,
|
||||||
public isRequestType: boolean,
|
public isRequestType: boolean,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
|
|
|
@ -76,7 +76,6 @@ export class OperationModel implements IMenuItem {
|
||||||
path: string;
|
path: string;
|
||||||
servers: OpenAPIServer[];
|
servers: OpenAPIServer[];
|
||||||
security: SecurityRequirementModel[];
|
security: SecurityRequirementModel[];
|
||||||
codeSamples: Array<OpenAPIXCodeSample | XPayloadSample>;
|
|
||||||
extensions: Dict<any>;
|
extensions: Dict<any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -104,23 +103,6 @@ export class OperationModel implements IMenuItem {
|
||||||
this.deprecated = !!operationSpec.deprecated;
|
this.deprecated = !!operationSpec.deprecated;
|
||||||
this.operationId = operationSpec.operationId;
|
this.operationId = operationSpec.operationId;
|
||||||
this.path = operationSpec.pathName;
|
this.path = operationSpec.pathName;
|
||||||
this.codeSamples = operationSpec['x-code-samples'] || [];
|
|
||||||
|
|
||||||
const requestBodyContent = this.requestBody && this.requestBody.content;
|
|
||||||
if (requestBodyContent && requestBodyContent.hasSample) {
|
|
||||||
const insertInx = Math.min(this.codeSamples.length, options.payloadSampleIdx);
|
|
||||||
|
|
||||||
this.codeSamples = [
|
|
||||||
...this.codeSamples.slice(0, insertInx),
|
|
||||||
{
|
|
||||||
lang: 'payload',
|
|
||||||
label: 'Payload',
|
|
||||||
source: '',
|
|
||||||
requestBodyContent,
|
|
||||||
},
|
|
||||||
...this.codeSamples.slice(insertInx),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const pathInfo = parser.byRef<OpenAPIPath>(
|
const pathInfo = parser.byRef<OpenAPIPath>(
|
||||||
JsonPointer.compile(['paths', operationSpec.pathName]),
|
JsonPointer.compile(['paths', operationSpec.pathName]),
|
||||||
|
@ -174,6 +156,30 @@ export class OperationModel implements IMenuItem {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@memoize
|
||||||
|
get codeSamples() {
|
||||||
|
let samples: Array<OpenAPIXCodeSample | XPayloadSample> =
|
||||||
|
this.operationSpec['x-code-samples'] || [];
|
||||||
|
|
||||||
|
const requestBodyContent = this.requestBody && this.requestBody.content;
|
||||||
|
if (requestBodyContent && requestBodyContent.hasSample) {
|
||||||
|
const insertInx = Math.min(samples.length, this.options.payloadSampleIdx);
|
||||||
|
|
||||||
|
samples = [
|
||||||
|
...samples.slice(0, insertInx),
|
||||||
|
{
|
||||||
|
lang: 'payload',
|
||||||
|
label: 'Payload',
|
||||||
|
source: '',
|
||||||
|
requestBodyContent,
|
||||||
|
},
|
||||||
|
...samples.slice(insertInx),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return samples;
|
||||||
|
}
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
get parameters() {
|
get parameters() {
|
||||||
const _parameters = mergeParams(
|
const _parameters = mergeParams(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user