mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +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'];
|
||||
|
||||
export class Parameters extends React.PureComponent<ParametersProps> {
|
||||
orderParams(params: FieldModel[]): Dict<FieldModel[]> {
|
||||
orderParams(params: FieldModel[]): Record<string, FieldModel[]> {
|
||||
const res = {};
|
||||
params.forEach(param => {
|
||||
safePush(res, param.in, param);
|
||||
|
|
|
@ -30,7 +30,7 @@ export type ExtendedOpenAPIOperation = {
|
|||
pathServers: Array<OpenAPIServer> | undefined;
|
||||
} & OpenAPIOperation;
|
||||
|
||||
export type TagsInfoMap = Dict<TagInfo>;
|
||||
export type TagsInfoMap = Record<string, TagInfo>;
|
||||
|
||||
export interface TagGroup {
|
||||
name: string;
|
||||
|
|
|
@ -298,8 +298,8 @@ export class OpenAPIParser {
|
|||
* returns map of definition pointer to definition name
|
||||
* @param $refs array of references to find derived from
|
||||
*/
|
||||
findDerived($refs: string[]): Dict<string[] | string> {
|
||||
const res: Dict<string[]> = {};
|
||||
findDerived($refs: string[]): Record<string, string[] | string> {
|
||||
const res: Record<string, string[]> = {};
|
||||
const schemas = (this.spec.components && this.spec.components.schemas) || {};
|
||||
for (const defName in schemas) {
|
||||
const def = this.deref(schemas[defName]);
|
||||
|
|
|
@ -30,7 +30,7 @@ export interface RedocRawOptions {
|
|||
|
||||
unstable_ignoreMimeParameters?: boolean;
|
||||
|
||||
allowedMdComponents?: Dict<MDXComponentMeta>;
|
||||
allowedMdComponents?: Record<string, MDXComponentMeta>;
|
||||
|
||||
labels?: LabelsConfigRaw;
|
||||
|
||||
|
@ -172,7 +172,7 @@ export class RedocNormalizedOptions {
|
|||
|
||||
/* tslint:disable-next-line */
|
||||
unstable_ignoreMimeParameters: boolean;
|
||||
allowedMdComponents: Dict<MDXComponentMeta>;
|
||||
allowedMdComponents: Record<string, MDXComponentMeta>;
|
||||
|
||||
expandDefaultServerVariables: boolean;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export class FieldModel {
|
|||
deprecated: boolean;
|
||||
in?: OpenAPIParameterLocation;
|
||||
kind: string;
|
||||
extensions?: Dict<any>;
|
||||
extensions?: Record<string, any>;
|
||||
explode: boolean;
|
||||
style?: OpenAPIParameterStyle;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ export class MediaContentModel {
|
|||
*/
|
||||
constructor(
|
||||
parser: OpenAPIParser,
|
||||
info: Dict<OpenAPIMediaType>,
|
||||
info: Record<string, OpenAPIMediaType>,
|
||||
public isRequestType: boolean,
|
||||
options: RedocNormalizedOptions,
|
||||
) {
|
||||
|
|
|
@ -73,7 +73,7 @@ export class OperationModel implements IMenuItem {
|
|||
path: string;
|
||||
servers: OpenAPIServer[];
|
||||
security: SecurityRequirementModel[];
|
||||
extensions: Dict<any>;
|
||||
extensions: Record<string, any>;
|
||||
isCallback: boolean;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -59,7 +59,7 @@ export class SchemaModel {
|
|||
|
||||
rawSchema: OpenAPISchema;
|
||||
schema: MergedOpenAPISchema;
|
||||
extensions?: Dict<any>;
|
||||
extensions?: Record<string, any>;
|
||||
|
||||
/**
|
||||
* @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 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: {
|
||||
implicit?: {
|
||||
refreshUrl?: string;
|
||||
scopes: Dict<string>;
|
||||
scopes: Record<string, string>;
|
||||
authorizationUrl: string;
|
||||
};
|
||||
password?: {
|
||||
refreshUrl?: string;
|
||||
scopes: Dict<string>;
|
||||
scopes: Record<string, string>;
|
||||
tokenUrl: string;
|
||||
};
|
||||
clientCredentials?: {
|
||||
refreshUrl?: string;
|
||||
scopes: Dict<string>;
|
||||
scopes: Record<string, string>;
|
||||
tokenUrl: string;
|
||||
};
|
||||
authorizationCode?: {
|
||||
refreshUrl?: string;
|
||||
scopes: Dict<string>;
|
||||
scopes: Record<string, 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.
|
||||
*/
|
||||
export function mapValues<T, P>(
|
||||
object: Dict<T>,
|
||||
iteratee: (val: T, key: string, obj: Dict<T>) => P,
|
||||
): Dict<P> {
|
||||
object: Record<string, T>,
|
||||
iteratee: (val: T, key: string, obj: Record<string, T>) => P,
|
||||
): Record<string, P> {
|
||||
const res: { [key: string]: P } = {};
|
||||
for (const key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
|
|
|
@ -492,7 +492,9 @@ export function mergeParams(
|
|||
return pathParams.concat(operationParams);
|
||||
}
|
||||
|
||||
export function mergeSimilarMediaTypes(types: Dict<OpenAPIMediaType>): Dict<OpenAPIMediaType> {
|
||||
export function mergeSimilarMediaTypes(
|
||||
types: Record<string, OpenAPIMediaType>,
|
||||
): Record<string, OpenAPIMediaType> {
|
||||
const mergedTypes = {};
|
||||
Object.keys(types).forEach(name => {
|
||||
const mime = types[name];
|
||||
|
@ -586,7 +588,10 @@ export function isRedocExtension(key: string): boolean {
|
|||
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)
|
||||
.filter(key => {
|
||||
if (showExtensions === true) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user