Skip to content

Commit 039978c

Browse files
committed
refactor(theme): clean up type definitions
1 parent 02c5c11 commit 039978c

File tree

2 files changed

+6
-120
lines changed

2 files changed

+6
-120
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import clsx from "clsx";
1616
import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
1717
import { guard, toString } from "../../markdown/utils";
1818

19-
interface Map<T> {
20-
[key: string]: T;
21-
}
22-
2319
export interface ExampleObject {
2420
summary?: string;
2521
description?: string;
@@ -32,7 +28,7 @@ export interface Props {
3228
param: {
3329
description: string;
3430
example: any;
35-
examples: Map<ExampleObject>;
31+
examples: Record<string, ExampleObject>;
3632
name: string;
3733
required: boolean;
3834
deprecated: boolean;

packages/docusaurus-theme-openapi-docs/src/types.ts

Lines changed: 5 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
* ========================================================================== */
77

8-
import type { FrontMatterTag } from "@docusaurus/utils";
8+
import type { DocFrontMatter as DocusaurusDocFrontMatter } from "@docusaurus/plugin-content-docs";
99
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
1010

1111
export interface ThemeConfig {
@@ -15,10 +15,6 @@ export interface ThemeConfig {
1515
};
1616
}
1717

18-
interface Map<T> {
19-
[key: string]: T;
20-
}
21-
2218
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
2319
export type SchemaObject = Omit<
2420
JSONSchema,
@@ -38,7 +34,7 @@ export type SchemaObject = Omit<
3834
anyOf?: SchemaObject[];
3935
not?: SchemaObject;
4036
items?: SchemaObject;
41-
properties?: Map<SchemaObject>;
37+
properties?: Record<string, SchemaObject>;
4238
additionalProperties?: boolean | SchemaObject;
4339

4440
// OpenAPI additions
@@ -54,7 +50,7 @@ export type SchemaObject = Omit<
5450

5551
export interface DiscriminatorObject {
5652
propertyName: string;
57-
mapping?: Map<string>;
53+
mapping?: Record<string, string>;
5854
}
5955

6056
export interface XMLObject {
@@ -70,113 +66,7 @@ export interface ExternalDocumentationObject {
7066
url: string;
7167
}
7268

73-
export type FileChange = {
74-
author?: string;
75-
/** Date can be any
76-
* [parsable date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
77-
*/
78-
date?: Date | string;
79-
};
80-
81-
export type DocFrontMatter = {
82-
/**
83-
* The last part of the doc ID (will be refactored in the future to be the
84-
* full ID instead)
85-
* @see {@link DocMetadata.id}
86-
*/
87-
id?: string;
88-
/**
89-
* Will override the default title collected from h1 heading.
90-
* @see {@link DocMetadata.title}
91-
*/
92-
title?: string;
93-
/**
94-
* Front matter tags, unnormalized.
95-
* @see {@link DocMetadata.tags}
96-
*/
97-
tags?: FrontMatterTag[];
98-
/**
99-
* If there isn't a Markdown h1 heading (which, if there is, we don't
100-
* remove), this front matter will cause the front matter title to not be
101-
* displayed in the doc page.
102-
*/
103-
hide_title?: boolean;
104-
/** Hide the TOC on the right. */
105-
hide_table_of_contents?: boolean;
106-
/** Used in the head meta. */
107-
keywords?: string[];
108-
/** Used in the head meta. Should use `assets.image` in priority. */
109-
image?: string;
110-
/**
111-
* Will override the default excerpt.
112-
* @see {@link DocMetadata.description}
113-
*/
114-
description?: string;
115-
/**
116-
* Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
117-
* @see {@link DocMetadata.slug}
118-
*/
119-
slug?: string;
120-
/** Customizes the sidebar label for this doc. Will default to its title. */
121-
sidebar_label?: string;
122-
/**
123-
* Controls the position of a doc inside the generated sidebar slice when
124-
* using autogenerated sidebar items.
125-
*
126-
* @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
127-
*/
128-
sidebar_position?: number;
129-
/**
130-
* Gives the corresponding sidebar label a special class name when using
131-
* autogenerated sidebars.
132-
*/
133-
sidebar_class_name?: string;
134-
/**
135-
* Will be propagated to the final sidebars data structure. Useful if you
136-
* have swizzled sidebar-related code or simply querying doc data through
137-
* sidebars.
138-
*/
139-
sidebar_custom_props?: { [key: string]: unknown };
140-
/**
141-
* Changes the sidebar association of the current doc. Use `null` to make
142-
* the current doc not associated to any sidebar.
143-
*/
144-
displayed_sidebar?: string | null;
145-
/**
146-
* Customizes the pagination label for this doc. Will default to the sidebar
147-
* label.
148-
*/
149-
pagination_label?: string;
150-
/** Overrides the default URL computed for this doc. */
151-
custom_edit_url?: string | null;
152-
/**
153-
* Whether number prefix parsing is disabled on this doc.
154-
* @see https://docusaurus.io/docs/sidebar#using-number-prefixes
155-
*/
156-
parse_number_prefixes?: boolean;
157-
/**
158-
* Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
159-
* the max value.
160-
*/
161-
toc_min_heading_level?: number;
162-
/** Maximum TOC heading level. Must be between 2 and 6. */
163-
toc_max_heading_level?: number;
164-
/**
165-
* The ID of the documentation you want the "Next" pagination to link to.
166-
* Use `null` to disable showing "Next" for this page.
167-
* @see {@link DocMetadata.next}
168-
*/
169-
pagination_next?: string | null;
170-
/**
171-
* The ID of the documentation you want the "Previous" pagination to link
172-
* to. Use `null` to disable showing "Previous" for this page.
173-
* @see {@link DocMetadata.prev}
174-
*/
175-
pagination_prev?: string | null;
176-
/** Should this doc be excluded from production builds? */
177-
draft?: boolean;
178-
/** Allows overriding the last updated author and/or date. */
179-
last_update?: FileChange;
69+
export interface DocFrontMatter extends DocusaurusDocFrontMatter {
18070
/** Provides OpenAPI Docs with a reference path to their respective Info Doc */
18171
info_path?: string;
182-
};
72+
}

0 commit comments

Comments
 (0)