Skip to content

Refactor theme types #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import clsx from "clsx";
import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
import { guard, toString } from "../../markdown/utils";

interface Map<T> {
[key: string]: T;
}

export interface ExampleObject {
summary?: string;
description?: string;
Expand All @@ -32,7 +28,7 @@ export interface Props {
param: {
description: string;
example: any;
examples: Map<ExampleObject>;
examples: Record<string, ExampleObject>;
name: string;
required: boolean;
deprecated: boolean;
Expand Down
120 changes: 5 additions & 115 deletions packages/docusaurus-theme-openapi-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -15,10 +15,6 @@ export interface ThemeConfig {
};
}

interface Map<T> {
[key: string]: T;
}

export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
export type SchemaObject = Omit<
JSONSchema,
Expand All @@ -38,7 +34,7 @@ export type SchemaObject = Omit<
anyOf?: SchemaObject[];
not?: SchemaObject;
items?: SchemaObject;
properties?: Map<SchemaObject>;
properties?: Record<string, SchemaObject>;
additionalProperties?: boolean | SchemaObject;

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

export interface DiscriminatorObject {
propertyName: string;
mapping?: Map<string>;
mapping?: Record<string, string>;
}

export interface XMLObject {
Expand All @@ -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 /<baseUrl>/<routeBasePath>/<versionPath>
* @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;
};
}