mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-26 10:33:44 +03:00
chore: remove global Dict<T> and replace it with Record<string, T>
This commit is contained in:
parent
9dd129d90b
commit
c69f6de4c9
|
@ -26,7 +26,7 @@ export interface ParametersProps {
|
||||||
const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
|
const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
|
||||||
|
|
||||||
export class Parameters extends React.PureComponent<ParametersProps> {
|
export class Parameters extends React.PureComponent<ParametersProps> {
|
||||||
orderParams(params: FieldModel[]): Dict<FieldModel[]> {
|
orderParams(params: FieldModel[]): Record<string, FieldModel[]> {
|
||||||
const res = {};
|
const res = {};
|
||||||
params.forEach(param => {
|
params.forEach(param => {
|
||||||
safePush(res, param.in, param);
|
safePush(res, param.in, param);
|
||||||
|
|
|
@ -30,7 +30,7 @@ export type ExtendedOpenAPIOperation = {
|
||||||
pathServers: Array<OpenAPIServer> | undefined;
|
pathServers: Array<OpenAPIServer> | undefined;
|
||||||
} & OpenAPIOperation;
|
} & OpenAPIOperation;
|
||||||
|
|
||||||
export type TagsInfoMap = Dict<TagInfo>;
|
export type TagsInfoMap = Record<string, TagInfo>;
|
||||||
|
|
||||||
export interface TagGroup {
|
export interface TagGroup {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -298,8 +298,8 @@ export class OpenAPIParser {
|
||||||
* returns map of definition pointer to definition name
|
* returns map of definition pointer to definition name
|
||||||
* @param $refs array of references to find derived from
|
* @param $refs array of references to find derived from
|
||||||
*/
|
*/
|
||||||
findDerived($refs: string[]): Dict<string[] | string> {
|
findDerived($refs: string[]): Record<string, string[] | string> {
|
||||||
const res: Dict<string[]> = {};
|
const res: Record<string, string[]> = {};
|
||||||
const schemas = (this.spec.components && this.spec.components.schemas) || {};
|
const schemas = (this.spec.components && this.spec.components.schemas) || {};
|
||||||
for (const defName in schemas) {
|
for (const defName in schemas) {
|
||||||
const def = this.deref(schemas[defName]);
|
const def = this.deref(schemas[defName]);
|
||||||
|
|
|
@ -30,7 +30,7 @@ export interface RedocRawOptions {
|
||||||
|
|
||||||
unstable_ignoreMimeParameters?: boolean;
|
unstable_ignoreMimeParameters?: boolean;
|
||||||
|
|
||||||
allowedMdComponents?: Dict<MDXComponentMeta>;
|
allowedMdComponents?: Record<string, MDXComponentMeta>;
|
||||||
|
|
||||||
labels?: LabelsConfigRaw;
|
labels?: LabelsConfigRaw;
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ export class RedocNormalizedOptions {
|
||||||
|
|
||||||
/* tslint:disable-next-line */
|
/* tslint:disable-next-line */
|
||||||
unstable_ignoreMimeParameters: boolean;
|
unstable_ignoreMimeParameters: boolean;
|
||||||
allowedMdComponents: Dict<MDXComponentMeta>;
|
allowedMdComponents: Record<string, MDXComponentMeta>;
|
||||||
|
|
||||||
expandDefaultServerVariables: boolean;
|
expandDefaultServerVariables: boolean;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class FieldModel {
|
||||||
deprecated: boolean;
|
deprecated: boolean;
|
||||||
in?: OpenAPIParameterLocation;
|
in?: OpenAPIParameterLocation;
|
||||||
kind: string;
|
kind: string;
|
||||||
extensions?: Dict<any>;
|
extensions?: Record<string, any>;
|
||||||
explode: boolean;
|
explode: boolean;
|
||||||
style?: OpenAPIParameterStyle;
|
style?: OpenAPIParameterStyle;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class MediaContentModel {
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
info: Dict<OpenAPIMediaType>,
|
info: Record<string, OpenAPIMediaType>,
|
||||||
public isRequestType: boolean,
|
public isRequestType: boolean,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class OperationModel implements IMenuItem {
|
||||||
path: string;
|
path: string;
|
||||||
servers: OpenAPIServer[];
|
servers: OpenAPIServer[];
|
||||||
security: SecurityRequirementModel[];
|
security: SecurityRequirementModel[];
|
||||||
extensions: Dict<any>;
|
extensions: Record<string, any>;
|
||||||
isCallback: boolean;
|
isCallback: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -59,7 +59,7 @@ export class SchemaModel {
|
||||||
|
|
||||||
rawSchema: OpenAPISchema;
|
rawSchema: OpenAPISchema;
|
||||||
schema: MergedOpenAPISchema;
|
schema: MergedOpenAPISchema;
|
||||||
extensions?: Dict<any>;
|
extensions?: Record<string, any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isChild if schema discriminator Child
|
* @param isChild if schema discriminator Child
|
||||||
|
|
5
src/types/index.d.ts
vendored
5
src/types/index.d.ts
vendored
|
@ -1,8 +1,3 @@
|
||||||
export * from './open-api';
|
export * from './open-api';
|
||||||
|
|
||||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||||
declare global {
|
|
||||||
type Dict<T> = {
|
|
||||||
[key: string]: T;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
8
src/types/open-api.d.ts
vendored
8
src/types/open-api.d.ts
vendored
|
@ -226,22 +226,22 @@ export interface OpenAPISecurityScheme {
|
||||||
flows: {
|
flows: {
|
||||||
implicit?: {
|
implicit?: {
|
||||||
refreshUrl?: string;
|
refreshUrl?: string;
|
||||||
scopes: Dict<string>;
|
scopes: Record<string, string>;
|
||||||
authorizationUrl: string;
|
authorizationUrl: string;
|
||||||
};
|
};
|
||||||
password?: {
|
password?: {
|
||||||
refreshUrl?: string;
|
refreshUrl?: string;
|
||||||
scopes: Dict<string>;
|
scopes: Record<string, string>;
|
||||||
tokenUrl: string;
|
tokenUrl: string;
|
||||||
};
|
};
|
||||||
clientCredentials?: {
|
clientCredentials?: {
|
||||||
refreshUrl?: string;
|
refreshUrl?: string;
|
||||||
scopes: Dict<string>;
|
scopes: Record<string, string>;
|
||||||
tokenUrl: string;
|
tokenUrl: string;
|
||||||
};
|
};
|
||||||
authorizationCode?: {
|
authorizationCode?: {
|
||||||
refreshUrl?: string;
|
refreshUrl?: string;
|
||||||
scopes: Dict<string>;
|
scopes: Record<string, string>;
|
||||||
tokenUrl: string;
|
tokenUrl: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,9 +24,9 @@ export function mapWithLast<T, P>(array: T[], iteratee: (item: T, isLast: boolea
|
||||||
* @param iteratee the function invoked per iteration.
|
* @param iteratee the function invoked per iteration.
|
||||||
*/
|
*/
|
||||||
export function mapValues<T, P>(
|
export function mapValues<T, P>(
|
||||||
object: Dict<T>,
|
object: Record<string, T>,
|
||||||
iteratee: (val: T, key: string, obj: Dict<T>) => P,
|
iteratee: (val: T, key: string, obj: Record<string, T>) => P,
|
||||||
): Dict<P> {
|
): Record<string, P> {
|
||||||
const res: { [key: string]: P } = {};
|
const res: { [key: string]: P } = {};
|
||||||
for (const key in object) {
|
for (const key in object) {
|
||||||
if (object.hasOwnProperty(key)) {
|
if (object.hasOwnProperty(key)) {
|
||||||
|
|
|
@ -492,7 +492,9 @@ export function mergeParams(
|
||||||
return pathParams.concat(operationParams);
|
return pathParams.concat(operationParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeSimilarMediaTypes(types: Dict<OpenAPIMediaType>): Dict<OpenAPIMediaType> {
|
export function mergeSimilarMediaTypes(
|
||||||
|
types: Record<string, OpenAPIMediaType>,
|
||||||
|
): Record<string, OpenAPIMediaType> {
|
||||||
const mergedTypes = {};
|
const mergedTypes = {};
|
||||||
Object.keys(types).forEach(name => {
|
Object.keys(types).forEach(name => {
|
||||||
const mime = types[name];
|
const mime = types[name];
|
||||||
|
@ -586,7 +588,10 @@ export function isRedocExtension(key: string): boolean {
|
||||||
return key in redocExtensions;
|
return key in redocExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractExtensions(obj: object, showExtensions: string[] | true): Dict<any> {
|
export function extractExtensions(
|
||||||
|
obj: object,
|
||||||
|
showExtensions: string[] | true,
|
||||||
|
): Record<string, any> {
|
||||||
return Object.keys(obj)
|
return Object.keys(obj)
|
||||||
.filter(key => {
|
.filter(key => {
|
||||||
if (showExtensions === true) {
|
if (showExtensions === true) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user