From 039978c1f1f9306ab1bf13c9341194f6e73d0e8c Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Fri, 27 Jun 2025 12:29:12 -0500 Subject: [PATCH] refactor(theme): clean up type definitions --- .../src/theme/ParamsItem/index.tsx | 6 +- .../src/types.ts | 120 +----------------- 2 files changed, 6 insertions(+), 120 deletions(-) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx index 318ba2311..863508e3e 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx @@ -16,10 +16,6 @@ import clsx from "clsx"; import { getQualifierMessage, getSchemaName } from "../../markdown/schema"; import { guard, toString } from "../../markdown/utils"; -interface Map { - [key: string]: T; -} - export interface ExampleObject { summary?: string; description?: string; @@ -32,7 +28,7 @@ export interface Props { param: { description: string; example: any; - examples: Map; + examples: Record; name: string; required: boolean; deprecated: boolean; diff --git a/packages/docusaurus-theme-openapi-docs/src/types.ts b/packages/docusaurus-theme-openapi-docs/src/types.ts index 06cb254d1..e65019ea5 100644 --- a/packages/docusaurus-theme-openapi-docs/src/types.ts +++ b/packages/docusaurus-theme-openapi-docs/src/types.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * ========================================================================== */ -import type { FrontMatterTag } from "@docusaurus/utils"; +import type { DocFrontMatter as DocusaurusDocFrontMatter } from "@docusaurus/plugin-content-docs"; import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema"; export interface ThemeConfig { @@ -15,10 +15,6 @@ export interface ThemeConfig { }; } -interface Map { - [key: string]: T; -} - export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7; export type SchemaObject = Omit< JSONSchema, @@ -38,7 +34,7 @@ export type SchemaObject = Omit< anyOf?: SchemaObject[]; not?: SchemaObject; items?: SchemaObject; - properties?: Map; + properties?: Record; additionalProperties?: boolean | SchemaObject; // OpenAPI additions @@ -54,7 +50,7 @@ export type SchemaObject = Omit< export interface DiscriminatorObject { propertyName: string; - mapping?: Map; + mapping?: Record; } export interface XMLObject { @@ -70,113 +66,7 @@ export interface ExternalDocumentationObject { url: string; } -export type FileChange = { - author?: string; - /** Date can be any - * [parsable date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse). - */ - date?: Date | string; -}; - -export type DocFrontMatter = { - /** - * The last part of the doc ID (will be refactored in the future to be the - * full ID instead) - * @see {@link DocMetadata.id} - */ - id?: string; - /** - * Will override the default title collected from h1 heading. - * @see {@link DocMetadata.title} - */ - title?: string; - /** - * Front matter tags, unnormalized. - * @see {@link DocMetadata.tags} - */ - tags?: FrontMatterTag[]; - /** - * If there isn't a Markdown h1 heading (which, if there is, we don't - * remove), this front matter will cause the front matter title to not be - * displayed in the doc page. - */ - hide_title?: boolean; - /** Hide the TOC on the right. */ - hide_table_of_contents?: boolean; - /** Used in the head meta. */ - keywords?: string[]; - /** Used in the head meta. Should use `assets.image` in priority. */ - image?: string; - /** - * Will override the default excerpt. - * @see {@link DocMetadata.description} - */ - description?: string; - /** - * Custom slug appended after /// - * @see {@link DocMetadata.slug} - */ - slug?: string; - /** Customizes the sidebar label for this doc. Will default to its title. */ - sidebar_label?: string; - /** - * Controls the position of a doc inside the generated sidebar slice when - * using autogenerated sidebar items. - * - * @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata - */ - sidebar_position?: number; - /** - * Gives the corresponding sidebar label a special class name when using - * autogenerated sidebars. - */ - sidebar_class_name?: string; - /** - * Will be propagated to the final sidebars data structure. Useful if you - * have swizzled sidebar-related code or simply querying doc data through - * sidebars. - */ - sidebar_custom_props?: { [key: string]: unknown }; - /** - * Changes the sidebar association of the current doc. Use `null` to make - * the current doc not associated to any sidebar. - */ - displayed_sidebar?: string | null; - /** - * Customizes the pagination label for this doc. Will default to the sidebar - * label. - */ - pagination_label?: string; - /** Overrides the default URL computed for this doc. */ - custom_edit_url?: string | null; - /** - * Whether number prefix parsing is disabled on this doc. - * @see https://docusaurus.io/docs/sidebar#using-number-prefixes - */ - parse_number_prefixes?: boolean; - /** - * Minimum TOC heading level. Must be between 2 and 6 and lower or equal to - * the max value. - */ - toc_min_heading_level?: number; - /** Maximum TOC heading level. Must be between 2 and 6. */ - toc_max_heading_level?: number; - /** - * The ID of the documentation you want the "Next" pagination to link to. - * Use `null` to disable showing "Next" for this page. - * @see {@link DocMetadata.next} - */ - pagination_next?: string | null; - /** - * The ID of the documentation you want the "Previous" pagination to link - * to. Use `null` to disable showing "Previous" for this page. - * @see {@link DocMetadata.prev} - */ - pagination_prev?: string | null; - /** Should this doc be excluded from production builds? */ - draft?: boolean; - /** Allows overriding the last updated author and/or date. */ - last_update?: FileChange; +export interface DocFrontMatter extends DocusaurusDocFrontMatter { /** Provides OpenAPI Docs with a reference path to their respective Info Doc */ info_path?: string; -}; +}