Skip to content
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

[Bug] Reproduces Type Errors Observed in 2.0.0-beta.20 (Variant #1) #81

Closed
wants to merge 8 commits into from
Closed
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
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"clean-api-docs": "docusaurus clean-api-docs"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.18",
"@docusaurus/preset-classic": "2.0.0-beta.18",
"@docusaurus/core": "2.0.0-beta.21",
"@docusaurus/preset-classic": "2.0.0-beta.21",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.1.1",
Expand Down
14 changes: 7 additions & 7 deletions demo/src/components/HomepageFeatures.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import React from "react";
import clsx from "clsx";
import React from "react";
import styles from "./HomepageFeatures.module.css";

const FeatureList = [
{
title: "Easy to Use",
Svg: require("../../static/img/undraw_docusaurus_mountain.svg").default,
description: (
<>
<React.Fragment>
Docusaurus was designed from the ground up to be easily installed and
used to get your website up and running quickly.
</>
</React.Fragment>
),
},
{
title: "Focus on What Matters",
Svg: require("../../static/img/undraw_docusaurus_tree.svg").default,
description: (
<>
<React.Fragment>
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go
ahead and move your docs into the <code>docs</code> directory.
</>
</React.Fragment>
),
},
{
title: "Powered by React",
Svg: require("../../static/img/undraw_docusaurus_react.svg").default,
description: (
<>
<React.Fragment>
Extend or customize your website layout by reusing React. Docusaurus can
be extended while reusing the same header and footer.
</>
</React.Fragment>
),
},
];
Expand Down
12 changes: 6 additions & 6 deletions packages/docusaurus-plugin-openapi-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.18",
"@docusaurus/types": "2.0.0-beta.18",
"@docusaurus/module-type-aliases": "2.0.0-beta.21",
"@docusaurus/types": "2.0.0-beta.21",
"@types/fs-extra": "^9.0.13",
"@types/json-schema": "^7.0.9",
"@types/lodash": "^4.14.176",
"utility-types": "^3.10.0"
},
"dependencies": {
"@docusaurus/mdx-loader": "2.0.0-beta.18",
"@docusaurus/plugin-content-docs": "2.0.0-beta.18",
"@docusaurus/utils": "2.0.0-beta.18",
"@docusaurus/utils-validation": "2.0.0-beta.18",
"@docusaurus/mdx-loader": "2.0.0-beta.21",
"@docusaurus/plugin-content-docs": "2.0.0-beta.21",
"@docusaurus/utils": "2.0.0-beta.21",
"@docusaurus/utils-validation": "2.0.0-beta.21",
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
"@paloaltonetworks/postman-collection": "^4.1.0",
"@types/js-yaml": "^4.0.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-theme-openapi-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.18",
"@docusaurus/types": "2.0.0-beta.18",
"@docusaurus/module-type-aliases": "2.0.0-beta.21",
"@docusaurus/types": "2.0.0-beta.21",
"@types/concurrently": "^6.3.0",
"@types/crypto-js": "^4.1.0",
"@types/fs-extra": "^9.0.13",
Expand All @@ -42,7 +42,7 @@
"concurrently": "^5.2.0"
},
"dependencies": {
"@docusaurus/theme-common": "2.0.0-beta.18",
"@docusaurus/theme-common": "2.0.0-beta.21",
"@mdx-js/react": "^1.6.21",
"@monaco-editor/react": "^4.3.1",
"@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function BodyWrap({ requestBodyMetadata, jsonRequestBodyExample }: Props) {
}

return (
<>
<React.Fragment>
<ContentType />
<Body
requestBodyMetadata={requestBodyMetadata}
jsonRequestBodyExample={jsonRequestBodyExample}
/>
</>
</React.Fragment>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function Curl({ postman, codeSamples }: Props) {
}

return (
<>
<React.Fragment>
<div className={clsx(styles.buttonGroup, "api-code-tab-group")}>
{langs.map((lang) => {
return (
Expand Down Expand Up @@ -271,7 +271,7 @@ function Curl({ postman, codeSamples }: Props) {
</FloatingButton>
)}
</Highlight>
</>
</React.Fragment>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function FormFileUpload({ placeholder, onChange }: Props) {
style={{ marginTop: "calc(var(--ifm-pre-padding) / 2)" }}
>
{file ? (
<>
<React.Fragment>
<button
style={{ marginTop: "calc(var(--ifm-pre-padding) / 2)" }}
onClick={(e) => {
Expand All @@ -103,7 +103,7 @@ function FormFileUpload({ placeholder, onChange }: Props) {
Clear
</button>
<RenderPreview file={file} />
</>
</React.Fragment>
) : (
<div className={styles.dropzoneContent}>{placeholder}</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ function ParamOptions() {
const optionalParams = allParams.filter((p) => !p.required);

return (
<>
<React.Fragment>
{/* Required Parameters */}
{requiredParams.map((param) => (
<ParamOptionWrapper key={`${param.in}-${param.name}`} param={param} />
))}

{/* Optional Parameters */}
{optionalParams.length > 0 && (
<>
<React.Fragment>
<button
className={styles.showMoreButton}
onClick={() => setShowOptional((prev) => !prev)}
Expand Down Expand Up @@ -128,9 +128,9 @@ function ParamOptions() {
/>
))}
</div>
</>
</React.Fragment>
)}
</>
</React.Fragment>
);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ function ParamArrayFormItem({ param }: ParamProps) {
}

return (
<>
<React.Fragment>
{items.map((item) => (
<div key={item.id} style={{ display: "flex" }}>
<ArrayItem param={param} onChange={handleChangeItem(item)} />
Expand All @@ -234,7 +234,7 @@ function ParamArrayFormItem({ param }: ParamProps) {
<button className={styles.buttonThin} onClick={handleAddItem}>
Add item
</button>
</>
</React.Fragment>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
useWindowSize,
} from "@docusaurus/theme-common";
import DocBreadcrumbs from "@theme/DocBreadcrumbs";
import type { Props, FrontMatter } from "@theme/DocItem";
import type { Props } from "@theme/DocItem";
import DocItemFooter from "@theme/DocItemFooter";
import DocPaginator from "@theme/DocPaginator";
import DocVersionBadge from "@theme/DocVersionBadge";
Expand All @@ -25,16 +25,17 @@ import MDXContent from "@theme/MDXContent";
import TOC from "@theme/TOC";
import TOCCollapsible from "@theme/TOCCollapsible";
import clsx from "clsx";
import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/lib/types";
import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/src/types";

import { DocFrontMatter } from "../../types";
import styles from "./styles.module.css";

let ApiDemoPanel = (_: { item: any }) => <div style={{ marginTop: "3.5em" }} />;
if (ExecutionEnvironment.canUseDOM) {
ApiDemoPanel = require("@theme/ApiDemoPanel").default;
}

interface ApiFrontMatter extends FrontMatter {
interface ApiFrontMatter extends DocFrontMatter {
readonly api?: ApiItemType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ function ParamsItem({
const renderExamples = guard(examples, (examples) => {
const exampleEntries = Object.entries(examples);
return (
<>
<React.Fragment>
{exampleEntries.map(([k, v]) => (
<div>{`Example (${k}): ${v.value}`}</div>
))}
</>
</React.Fragment>
);
});

Expand Down
100 changes: 100 additions & 0 deletions packages/docusaurus-theme-openapi-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import type { FrontMatterTag } from "@docusaurus/utils";
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";

export interface ThemeConfig {
Expand Down Expand Up @@ -68,3 +69,102 @@ export interface ExternalDocumentationObject {
description?: string;
url: 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;
};
Loading