diff --git a/.eslintrc.js b/.eslintrc.js index f854075be..05febb16c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,7 +16,7 @@ module.exports = { "plugin:jest/recommended", "plugin:jest/style", "plugin:testing-library/react", - "plugin:jest-dom/recommended", + "plugin:jest-dom/recommended" ], plugins: ["import", "header"], rules: { @@ -29,9 +29,9 @@ module.exports = { " *", " * This source code is licensed under the MIT license found in the", " * LICENSE file in the root directory of this source tree.", - " * ========================================================================== ", + " * ========================================================================== " ], - 2, + 2 ], "import/newline-after-import": ["warn", { count: 1 }], "import/no-extraneous-dependencies": [ @@ -40,15 +40,15 @@ module.exports = { devDependencies: false, optionalDependencies: false, peerDependencies: true, - bundledDependencies: true, - }, + bundledDependencies: true + } ], "import/order": [ "warn", { alphabetize: { order: "asc", - caseInsensitive: true, + caseInsensitive: true }, "newlines-between": "always", groups: [ @@ -56,18 +56,18 @@ module.exports = { "external", "internal", ["parent", "sibling", "index"], - "object", + "object" ], pathGroups: [ { pattern: "react?(-dom)", group: "external", - position: "before", - }, + position: "before" + } ], - pathGroupsExcludedImportTypes: ["builtin"], - }, - ], + pathGroupsExcludedImportTypes: ["builtin"] + } + ] }, overrides: [ { @@ -80,22 +80,22 @@ module.exports = { devDependencies: true, optionalDependencies: false, peerDependencies: true, - bundledDependencies: true, - }, - ], - }, - }, + bundledDependencies: true + } + ] + } + } ], settings: { "import/extensions": allExtensions, "import/external-module-folders": ["node_modules", "node_modules/@types"], "import/parsers": { - "@typescript-eslint/parser": tsExtensions, + "@typescript-eslint/parser": tsExtensions }, "import/resolver": { node: { - extensions: allExtensions, - }, - }, - }, + extensions: allExtensions + } + } + } }; diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549ea..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfb..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 473415d65..000000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - { - "customColor": "", - "associatedIndex": 3 -} - - - - - - - - - - - - - - 1700657366385 - - - - - - \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json index 0967ef424..36b356317 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1 +1,3 @@ -{} +{ + "trailingComma": "none" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index a12626e86..cb0ac1def 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -952,7 +952,7 @@ High level enhancements // docusaurus.config.js const config = { - plugins: [["docusaurus-plugin-proxy", { "/api": "http://localhost:3001" }]], + plugins: [["docusaurus-plugin-proxy", { "/api": "http://localhost:3001" }]] // ... }; ``` @@ -969,11 +969,11 @@ High level enhancements { "/api": { target: "http://localhost:3001", - pathRewrite: { "^/api": "" }, - }, - }, - ], - ], + pathRewrite: { "^/api": "" } + } + } + ] + ] // ... }; ``` diff --git a/cypress/.eslintrc.js b/cypress/.eslintrc.js index d94ac4416..c97adf128 100644 --- a/cypress/.eslintrc.js +++ b/cypress/.eslintrc.js @@ -8,7 +8,7 @@ module.exports = { plugins: ["cypress"], env: { - "cypress/globals": true, + "cypress/globals": true }, rules: { "testing-library/await-async-query": "off", // Cypress chains don't use promises @@ -18,6 +18,6 @@ module.exports = { "jest/expect-expect": "off", "jest/valid-expect": "off", "jest/valid-expect-in-promise": "off", - "jest/no-conditional-expect": "off", - }, + "jest/no-conditional-expect": "off" + } }; diff --git a/demo/docs/customization/languagetabs.md b/demo/docs/customization/languagetabs.mdx similarity index 100% rename from demo/docs/customization/languagetabs.md rename to demo/docs/customization/languagetabs.mdx diff --git a/demo/docs/customization/styling.md b/demo/docs/customization/styling.mdx similarity index 100% rename from demo/docs/customization/styling.md rename to demo/docs/customization/styling.mdx diff --git a/demo/docs/sidebars.md b/demo/docs/sidebars.mdx similarity index 100% rename from demo/docs/sidebars.md rename to demo/docs/sidebars.mdx diff --git a/demo/docs/versioning.md b/demo/docs/versioning.mdx similarity index 100% rename from demo/docs/versioning.md rename to demo/docs/versioning.mdx diff --git a/demo/docusaurus.config.js b/demo/docusaurus.config.js deleted file mode 100644 index 16a0794c0..000000000 --- a/demo/docusaurus.config.js +++ /dev/null @@ -1,273 +0,0 @@ -// @ts-check -// Note: type annotations allow type checking and IDEs autocompletion - -const { DOCUSAURUS_VERSION } = require("@docusaurus/utils"); - -/** @type {import('@docusaurus/types').Config} */ -const config = { - title: "Docusaurus OpenAPI Docs", - tagline: "OpenAPI plugin for generating API reference docs in Docusaurus v2", - url: "https://docusaurus-openapi.tryingpan.dev", - baseUrl: "/", - onBrokenLinks: "warn", - onBrokenMarkdownLinks: "warn", - favicon: "img/favicon.ico", - organizationName: "PaloAltoNetworks", - projectName: "docusaurus-openapi-docs", - - presets: [ - [ - "classic", - /** @type {import('@docusaurus/preset-classic').Options} */ - ({ - docs: { - routeBasePath: "/", - sidebarPath: "./sidebars.ts", - editUrl: - "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/tree/main/demo", - docItemComponent: "@theme/ApiItem", // Derived from docusaurus-theme-openapi - }, - blog: false, - theme: { - customCss: "./src/css/custom.css", - }, - gtag: { - trackingID: "GTM-THVM29S", - anonymizeIP: false, - }, - }), - ], - ], - - themeConfig: - /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ - ({ - docs: { - sidebar: { - hideable: true, - }, - }, - navbar: { - title: "OpenAPI Docs", - logo: { - alt: "Keytar", - src: "img/docusaurus-openapi-docs-logo.svg", - }, - items: [ - { - type: "doc", - docId: "intro", - position: "left", - label: "Docs", - }, - { - type: "dropdown", - label: "Demos", - position: "left", - items: [ - { - label: "API Zoo", - to: "/category/petstore-api", - }, - { - label: "Petstore (versioned)", - to: "/category/petstore-versioned-api", - }, - ], - }, - { - href: "https://medium.com/palo-alto-networks-developer-blog", - position: "right", - className: "header-medium-link", - "aria-label": "Palo Alto Networks Developer Blog", - }, - { - href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs", - position: "right", - className: "header-github-link", - "aria-label": "GitHub repository", - }, - ], - }, - footer: { - style: "dark", - links: [ - { - title: "Docs", - items: [ - { - label: "OpenAPI Docs", - to: "/", - }, - ], - }, - { - title: "Community", - items: [ - { - label: "Stack Overflow", - href: "https://stackoverflow.com/questions/tagged/docusaurus", - }, - { - label: "Discord", - href: "https://discordapp.com/invite/docusaurus", - }, - { - label: "Twitter", - href: "https://twitter.com/docusaurus", - }, - ], - }, - { - title: "More", - items: [ - { - label: "Blog", - href: "https://medium.com/palo-alto-networks-developer-blog", - }, - { - label: "GitHub", - href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs", - }, - ], - }, - ], - copyright: `Copyright © ${new Date().getFullYear()} Palo Alto Networks, Inc. Built with Docusaurus ${DOCUSAURUS_VERSION}.`, - }, - prism: { - additionalLanguages: ["ruby", "csharp", "php", "java", "powershell"], - }, - languageTabs: [ - { - highlight: "bash", - language: "curl", - logoClass: "bash", - }, - { - highlight: "python", - language: "python", - logoClass: "python", - variant: "requests", - }, - { - highlight: "go", - language: "go", - logoClass: "go", - }, - { - highlight: "javascript", - language: "nodejs", - logoClass: "nodejs", - variant: "axios", - }, - { - highlight: "ruby", - language: "ruby", - logoClass: "ruby", - }, - { - highlight: "csharp", - language: "csharp", - logoClass: "csharp", - variant: "httpclient", - }, - { - highlight: "php", - language: "php", - logoClass: "php", - }, - { - highlight: "java", - language: "java", - logoClass: "java", - variant: "unirest", - }, - { - highlight: "powershell", - language: "powershell", - logoClass: "powershell", - }, - ], - algolia: { - apiKey: "441074cace987cbf4640c039ebed303c", - appId: "J0EABTYI1A", - indexName: "docusaurus-openapi", - }, - announcementBar: { - id: "announcementBar_1", - content: "Beta preview that adds support for Docusaurus v3.0.0", - }, - }), - - plugins: [ - [ - "docusaurus-plugin-openapi-docs", - { - id: "openapi", - docsPluginId: "classic", - config: { - petstore_versioned: { - specPath: "examples/petstore.yaml", - outputDir: "docs/petstore_versioned", // No trailing slash - sidebarOptions: { - groupPathsBy: "tag", - categoryLinkSource: "tag", - }, - version: "2.0.0", // Current version - label: "v2.0.0", // Current version label - baseUrl: "/petstore_versioned/swagger-petstore-yaml", // Leading slash is important - versions: { - "1.0.0": { - specPath: "examples/petstore-1.0.0.yaml", - outputDir: "docs/petstore_versioned/1.0.0", // No trailing slash - label: "v1.0.0", - baseUrl: "/petstore_versioned/1.0.0/swagger-petstore-yaml", // Leading slash is important - }, - }, - }, - petstore: { - specPath: "examples/petstore.yaml", - proxy: "https://cors.pan.dev", - outputDir: "docs/petstore", - sidebarOptions: { - groupPathsBy: "tag", - categoryLinkSource: "tag", - }, - template: "api.mustache", // Customize API MDX with mustache template - downloadUrl: - "https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml", - hideSendButton: false, - }, - cos: { - specPath: "examples/openapi-cos.json", - outputDir: "docs/cos", - sidebarOptions: { - groupPathsBy: "tag", - }, - }, - burgers: { - specPath: "examples/food/burgers/openapi.yaml", - outputDir: "docs/food/burgers", - }, - yogurt: { - specPath: "examples/food/yogurtstore/openapi.yaml", - outputDir: "docs/food/yogurtstore", - }, - }, - }, - ], - ], - themes: ["docusaurus-theme-openapi-docs"], - stylesheets: [ - { - href: "https://use.fontawesome.com/releases/v5.11.0/css/all.css", - type: "text/css", - }, - ], -}; - -async function createConfig() { - return config; -} - -module.exports = createConfig; diff --git a/demo/docusaurus.config.ts b/demo/docusaurus.config.ts new file mode 100644 index 000000000..4f17965e3 --- /dev/null +++ b/demo/docusaurus.config.ts @@ -0,0 +1,269 @@ +import type * as Preset from "@docusaurus/preset-classic"; +import type { Config } from "@docusaurus/types"; +import type * as Plugin from "@docusaurus/types/src/plugin"; +import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs"; + +import { DOCUSAURUS_VERSION } from "@docusaurus/utils"; + +const config: Config = { + title: "Docusaurus OpenAPI Docs", + tagline: "OpenAPI plugin for generating API reference docs in Docusaurus v2", + url: "https://docusaurus-openapi.tryingpan.dev", + baseUrl: "/", + onBrokenLinks: "warn", + onBrokenMarkdownLinks: "warn", + favicon: "img/favicon.ico", + organizationName: "PaloAltoNetworks", + projectName: "docusaurus-openapi-docs", + + presets: [ + [ + "classic", + { + docs: { + routeBasePath: "/", + sidebarPath: "./sidebars.ts", + editUrl: + "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/tree/main/demo", + docItemComponent: "@theme/ApiItem" // Derived from docusaurus-theme-openapi + }, + blog: false, + theme: { + customCss: "./src/css/custom.css" + }, + gtag: { + trackingID: "GTM-THVM29S", + anonymizeIP: false + } + } satisfies Preset.Options + ] + ], + + themeConfig: { + docs: { + sidebar: { + hideable: true + } + }, + navbar: { + title: "OpenAPI Docs", + logo: { + alt: "Keytar", + src: "img/docusaurus-openapi-docs-logo.svg" + }, + items: [ + { + type: "doc", + docId: "intro", + position: "left", + label: "Docs" + }, + { + type: "dropdown", + label: "Demos", + position: "left", + items: [ + { + label: "API Zoo", + to: "/category/petstore-api" + }, + { + label: "Petstore (versioned)", + to: "/category/petstore-versioned-api" + } + ] + }, + { + href: "https://medium.com/palo-alto-networks-developer-blog", + position: "right", + className: "header-medium-link", + "aria-label": "Palo Alto Networks Developer Blog" + }, + { + href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs", + position: "right", + className: "header-github-link", + "aria-label": "GitHub repository" + } + ] + }, + footer: { + style: "dark", + links: [ + { + title: "Docs", + items: [ + { + label: "OpenAPI Docs", + to: "/" + } + ] + }, + { + title: "Community", + items: [ + { + label: "Stack Overflow", + href: "https://stackoverflow.com/questions/tagged/docusaurus" + }, + { + label: "Discord", + href: "https://discordapp.com/invite/docusaurus" + }, + { + label: "Twitter", + href: "https://twitter.com/docusaurus" + } + ] + }, + { + title: "More", + items: [ + { + label: "Blog", + href: "https://medium.com/palo-alto-networks-developer-blog" + }, + { + label: "GitHub", + href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs" + } + ] + } + ], + copyright: `Copyright © ${new Date().getFullYear()} Palo Alto Networks, Inc. Built with Docusaurus ${DOCUSAURUS_VERSION}.` + }, + prism: { + additionalLanguages: ["ruby", "csharp", "php", "java", "powershell"] + }, + languageTabs: [ + { + highlight: "bash", + language: "curl", + logoClass: "bash" + }, + { + highlight: "python", + language: "python", + logoClass: "python", + variant: "requests" + }, + { + highlight: "go", + language: "go", + logoClass: "go" + }, + { + highlight: "javascript", + language: "nodejs", + logoClass: "nodejs", + variant: "axios" + }, + { + highlight: "ruby", + language: "ruby", + logoClass: "ruby" + }, + { + highlight: "csharp", + language: "csharp", + logoClass: "csharp", + variant: "httpclient" + }, + { + highlight: "php", + language: "php", + logoClass: "php" + }, + { + highlight: "java", + language: "java", + logoClass: "java", + variant: "unirest" + }, + { + highlight: "powershell", + language: "powershell", + logoClass: "powershell" + } + ], + algolia: { + apiKey: "441074cace987cbf4640c039ebed303c", + appId: "J0EABTYI1A", + indexName: "docusaurus-openapi" + }, + announcementBar: { + id: "announcementBar_1", + content: "Beta preview that adds support for Docusaurus v3.0.0" + } + } satisfies Preset.ThemeConfig, + + plugins: [ + [ + "docusaurus-plugin-openapi-docs", + { + id: "openapi", + docsPluginId: "classic", + config: { + petstore_versioned: { + specPath: "examples/petstore.yaml", + outputDir: "docs/petstore_versioned", // No trailing slash + sidebarOptions: { + groupPathsBy: "tag", + categoryLinkSource: "tag" + }, + version: "2.0.0", // Current version + label: "v2.0.0", // Current version label + baseUrl: "/petstore_versioned/swagger-petstore-yaml", // Leading slash is important + versions: { + "1.0.0": { + specPath: "examples/petstore-1.0.0.yaml", + outputDir: "docs/petstore_versioned/1.0.0", // No trailing slash + label: "v1.0.0", + baseUrl: "/petstore_versioned/1.0.0/swagger-petstore-yaml" // Leading slash is important + } + } + } satisfies OpenApiPlugin.Options, + petstore: { + specPath: "examples/petstore.yaml", + proxy: "https://cors.pan.dev", + outputDir: "docs/petstore", + sidebarOptions: { + groupPathsBy: "tag", + categoryLinkSource: "tag" + }, + template: "api.mustache", // Customize API MDX with mustache template + downloadUrl: + "https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml", + hideSendButton: false + } satisfies OpenApiPlugin.Options, + cos: { + specPath: "examples/openapi-cos.json", + outputDir: "docs/cos", + sidebarOptions: { + groupPathsBy: "tag" + } + } satisfies OpenApiPlugin.Options, + burgers: { + specPath: "examples/food/burgers/openapi.yaml", + outputDir: "docs/food/burgers" + } satisfies OpenApiPlugin.Options, + yogurt: { + specPath: "examples/food/yogurtstore/openapi.yaml", + outputDir: "docs/food/yogurtstore" + } satisfies OpenApiPlugin.Options + } satisfies Plugin.PluginOptions + } + ] + ], + themes: ["docusaurus-theme-openapi-docs"], + stylesheets: [ + { + href: "https://use.fontawesome.com/releases/v5.11.0/css/all.css", + type: "text/css" + } + ] +}; + +export default async function createConfig() { + return config; +} diff --git a/demo/sidebars.ts b/demo/sidebars.ts index a2faca13f..1df8d638d 100644 --- a/demo/sidebars.ts +++ b/demo/sidebars.ts @@ -13,7 +13,7 @@ import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; import petstoreVersions from "./docs/petstore_versioned/versions.json"; import { versionCrumb, - versionSelector, + versionSelector } from "docusaurus-plugin-openapi-docs/lib/sidebars/utils"; import petstoreSidebar from "./docs/petstore/sidebar"; @@ -27,33 +27,33 @@ const sidebars: SidebarsConfig = { { type: "html", value: `

DOCUMENTATION

`, // The HTML to be rendered - defaultStyle: true, // Use the default menu item styling + defaultStyle: true // Use the default menu item styling }, { type: "doc", - id: "intro", + id: "intro" }, { type: "doc", - id: "sidebars", + id: "sidebars" }, { type: "doc", - id: "versioning", + id: "versioning" }, { type: "category", label: "Customization", link: { - type: "generated-index", + type: "generated-index" }, items: [ { type: "autogenerated", - dirName: "customization", - }, - ], - }, + dirName: "customization" + } + ] + } ], petstore: [ { @@ -64,9 +64,9 @@ const sidebars: SidebarsConfig = { title: "Petstore API", description: "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.", - slug: "/category/petstore-api", + slug: "/category/petstore-api" }, - items: petstoreSidebar, + items: petstoreSidebar }, { type: "category", @@ -74,9 +74,9 @@ const sidebars: SidebarsConfig = { link: { type: "generated-index", title: "Cloud Object Storage API", - slug: "/category/cos-api", + slug: "/category/cos-api" }, - items: cloudObjectStorageSidebar, + items: cloudObjectStorageSidebar }, { type: "category", @@ -84,14 +84,14 @@ const sidebars: SidebarsConfig = { link: { type: "generated-index", title: "Burger API", - slug: "/category/food-api", + slug: "/category/food-api" }, items: [ { type: "autogenerated", - dirName: "food/burgers", // '.' means the current docs folder - }, - ], + dirName: "food/burgers" // '.' means the current docs folder + } + ] }, { type: "category", @@ -99,27 +99,27 @@ const sidebars: SidebarsConfig = { link: { type: "generated-index", title: "Yogurt Store API", - slug: "/category/yogurt-api", + slug: "/category/yogurt-api" }, items: [ { type: "autogenerated", - dirName: "food/yogurtstore", // '.' means the current docs folder - }, - ], - }, + dirName: "food/yogurtstore" // '.' means the current docs folder + } + ] + } ], "petstore-2.0.0": [ { type: "html", defaultStyle: true, value: versionSelector(petstoreVersions), - className: "version-button", + className: "version-button" }, { type: "html", defaultStyle: true, - value: versionCrumb(`v2.0.0`), + value: versionCrumb(`v2.0.0`) }, { type: "category", @@ -129,10 +129,10 @@ const sidebars: SidebarsConfig = { title: "Petstore API (latest)", description: "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.", - slug: "/category/petstore-versioned-api", + slug: "/category/petstore-versioned-api" }, - items: petstoreVersionedSidebar, - }, + items: petstoreVersionedSidebar + } ], "petstore-1.0.0": [ @@ -140,12 +140,12 @@ const sidebars: SidebarsConfig = { type: "html", defaultStyle: true, value: versionSelector(petstoreVersions), - className: "version-button", + className: "version-button" }, { type: "html", defaultStyle: true, - value: versionCrumb(`v1.0.0`), + value: versionCrumb(`v1.0.0`) }, { type: "category", @@ -155,11 +155,11 @@ const sidebars: SidebarsConfig = { title: "Petstore API (v1.0.0)", description: "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.", - slug: "/category/petstore-api-1.0.0", + slug: "/category/petstore-api-1.0.0" }, - items: petstoreVersionSidebar, - }, - ], + items: petstoreVersionSidebar + } + ] }; export default sidebars; diff --git a/demo/src/components/HomepageFeatures/index.js b/demo/src/components/HomepageFeatures/index.tsx similarity index 98% rename from demo/src/components/HomepageFeatures/index.js rename to demo/src/components/HomepageFeatures/index.tsx index d5d56e76f..05c3a1d08 100644 --- a/demo/src/components/HomepageFeatures/index.js +++ b/demo/src/components/HomepageFeatures/index.tsx @@ -11,7 +11,7 @@ const FeatureList = [ Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly. - ), + ) }, { title: "Focus on What Matters", @@ -21,7 +21,7 @@ const FeatureList = [ Docusaurus lets you focus on your docs, and we'll do the chores. Go ahead and move your docs into the docs directory. - ), + ) }, { title: "Powered by React", @@ -31,8 +31,8 @@ const FeatureList = [ Extend or customize your website layout by reusing React. Docusaurus can be extended while reusing the same header and footer. - ), - }, + ) + } ]; function Feature({ Svg, title, description }) { diff --git a/demo/src/utils/prismDark.mjs b/demo/src/utils/prismDark.ts similarity index 63% rename from demo/src/utils/prismDark.mjs rename to demo/src/utils/prismDark.ts index c2164e384..2634116c1 100644 --- a/demo/src/utils/prismDark.mjs +++ b/demo/src/utils/prismDark.ts @@ -4,76 +4,77 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +import prism from "prism-react-renderer"; -import darkTheme from "prism-react-renderer/themes/vsDark/index.cjs.js"; - -export default { +const prismDark = { plain: { color: "#D4D4D4", - backgroundColor: "#212121", + backgroundColor: "#212121" }, styles: [ - ...darkTheme.styles, + ...prism.themes.vsDark.styles, { types: ["title"], style: { color: "#569CD6", - fontWeight: "bold", - }, + fontWeight: "bold" + } }, { types: ["property", "parameter"], style: { - color: "#9CDCFE", - }, + color: "#9CDCFE" + } }, { types: ["script"], style: { - color: "#D4D4D4", - }, + color: "#D4D4D4" + } }, { types: ["boolean", "arrow", "atrule", "tag"], style: { - color: "#569CD6", - }, + color: "#569CD6" + } }, { types: ["number", "color", "unit"], style: { - color: "#B5CEA8", - }, + color: "#B5CEA8" + } }, { types: ["font-matter"], style: { - color: "#CE9178", - }, + color: "#CE9178" + } }, { types: ["keyword", "rule"], style: { - color: "#C586C0", - }, + color: "#C586C0" + } }, { types: ["regex"], style: { - color: "#D16969", - }, + color: "#D16969" + } }, { types: ["maybe-class-name"], style: { - color: "#4EC9B0", - }, + color: "#4EC9B0" + } }, { types: ["constant"], style: { - color: "#4FC1FF", - }, - }, - ], + color: "#4FC1FF" + } + } + ] }; + +export default prismDark; diff --git a/demo/src/utils/prismLight.mjs b/demo/src/utils/prismLight.ts similarity index 63% rename from demo/src/utils/prismLight.mjs rename to demo/src/utils/prismLight.ts index d87a3dd3c..fc972cc33 100644 --- a/demo/src/utils/prismLight.mjs +++ b/demo/src/utils/prismLight.ts @@ -4,97 +4,98 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +import prism from "prism-react-renderer"; -import lightTheme from "prism-react-renderer/themes/github/index.cjs.js"; - -export default { - ...lightTheme, +const prismLight = { + ...prism.themes.github, styles: [ - ...lightTheme.styles, + ...prism.themes.github.styles, { types: ["title"], style: { color: "#0550AE", - fontWeight: "bold", - }, + fontWeight: "bold" + } }, { types: ["parameter"], style: { - color: "#953800", - }, + color: "#953800" + } }, { types: ["boolean", "rule", "color", "number", "constant", "property"], style: { - color: "#005CC5", - }, + color: "#005CC5" + } }, { types: ["atrule", "tag"], style: { - color: "#22863A", - }, + color: "#22863A" + } }, { types: ["script"], style: { - color: "#24292E", - }, + color: "#24292E" + } }, { types: ["operator", "unit", "rule"], style: { - color: "#D73A49", - }, + color: "#D73A49" + } }, { types: ["font-matter", "string", "attr-value"], style: { - color: "#C6105F", - }, + color: "#C6105F" + } }, { types: ["class-name"], style: { - color: "#116329", - }, + color: "#116329" + } }, { types: ["attr-name"], style: { - color: "#0550AE", - }, + color: "#0550AE" + } }, { types: ["keyword"], style: { - color: "#CF222E", - }, + color: "#CF222E" + } }, { types: ["function"], style: { - color: "#8250DF", - }, + color: "#8250DF" + } }, { types: ["selector"], style: { - color: "#6F42C1", - }, + color: "#6F42C1" + } }, { types: ["variable"], style: { - color: "#E36209", - }, + color: "#E36209" + } }, { types: ["comment"], style: { - color: "#6B6B6B", - }, - }, - ], + color: "#6B6B6B" + } + } + ] }; + +export default prismLight; diff --git a/jest.config.js b/jest.config.js index ddb430cc0..9424c9008 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,6 +10,6 @@ module.exports = { testEnvironment: "node", roots: [ "/packages/docusaurus-plugin-openapi-docs/src", - "/packages/docusaurus-theme-openapi-docs/src", - ], + "/packages/docusaurus-theme-openapi-docs/src" + ] }; diff --git a/package.json b/package.json index 0e7c3a1c8..3173e6e68 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "@testing-library/cypress": "^8.0.1", "@types/jest": "^27.0.2", "@types/node": "^17.0.2", - "@typescript-eslint/eslint-plugin": "^4.0.0", - "@typescript-eslint/parser": "^4.0.0", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", "babel-eslint": "^10.0.0", "cypress": "^8.7.0", "eslint": "^7.5.0", @@ -56,20 +56,20 @@ "eslint-plugin-import": "^2.22.0", "eslint-plugin-jest": "^25.0.6", "eslint-plugin-jest-dom": "^3.9.2", - "eslint-plugin-jsx-a11y": "^6.3.1", - "eslint-plugin-react": "^7.20.3", - "eslint-plugin-react-hooks": "^4.0.8", + "eslint-plugin-jsx-a11y": "^6.8.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-testing-library": "^4.12.4", "husky": "^7.0.2", "jest": "^27.3.1", "lerna": "^5.5.2", "lint-staged": "^11.2.3", "nodemon": "^2.0.15", - "prettier": "^2.4.1", + "prettier": "^3.1.0", "semver": "^7.3.5", "start-server-and-test": "^1.14.0", "ts-jest": "^27.0.6", - "typescript": "^4.4.4" + "typescript": "^4.9.5" }, "lint-staged": { "**/*": "prettier --write --ignore-unknown" diff --git a/packages/docusaurus-plugin-openapi-docs/src/index.ts b/packages/docusaurus-plugin-openapi-docs/src/index.ts index e947b1ecc..deb5a4e1d 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/index.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/index.ts @@ -98,7 +98,7 @@ export default function pluginOpenAPIDocs( template, markdownGenerators, downloadUrl, - sidebarOptions, + sidebarOptions } = options; // Remove trailing slash before proceeding @@ -149,7 +149,7 @@ export default function pluginOpenAPIDocs( sidebarSliceTemplate += `export default sidebar;`; const view = render(sidebarSliceTemplate, { - slice: JSON.stringify(sidebarSlice, null, 2), + slice: JSON.stringify(sidebarSlice, null, 2) }); if (!fs.existsSync(`${outputDir}/sidebar.ts`)) { @@ -263,8 +263,8 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; item.type === "api" ? apiPageGenerator(item) : item.type === "info" - ? infoPageGenerator(item) - : tagPageGenerator(item); + ? infoPageGenerator(item) + : tagPageGenerator(item); item.markdown = markdown; if (item.type === "api") { // opportunity to compress JSON @@ -380,11 +380,11 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; const apiDir = posixPath(path.join(siteDir, outputDir)); const apiMdxFiles = await Globby(["*.api.mdx", "*.info.mdx", "*.tag.mdx"], { cwd: path.resolve(apiDir), - deep: 1, + deep: 1 }); const sidebarFile = await Globby(["sidebar.ts"], { cwd: path.resolve(apiDir), - deep: 1, + deep: 1 }); apiMdxFiles.map((mdx) => fs.unlink(`${apiDir}/${mdx}`, (err) => { @@ -421,7 +421,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; versionsArray.push({ version: version, label: metadata.label, - baseUrl: metadata.baseUrl, + baseUrl: metadata.baseUrl }); } @@ -587,7 +587,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; const versionConfig = versions[key]; const mergedConfig = { ...parentConfig, - ...versionConfig, + ...versionConfig }; await generateApiDocs(mergedConfig, targetDocsPluginId); }); @@ -602,7 +602,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; const versionConfig = versions[versionId]; const mergedConfig = { ...parentConfig, - ...versionConfig, + ...versionConfig }; await generateVersions(mergedVersions, parentConfig.outputDir); await generateApiDocs(mergedConfig, targetDocsPluginId); @@ -711,7 +711,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; const versionConfig = versions[key]; const mergedConfig = { ...parentConfig, - ...versionConfig, + ...versionConfig }; await cleanApiDocs(mergedConfig); }); @@ -720,12 +720,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; const versionConfig = versions[versionId]; const mergedConfig = { ...parentConfig, - ...versionConfig, + ...versionConfig }; await cleanApiDocs(mergedConfig); } }); - }, + } }; } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createArrayBracket.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createArrayBracket.ts index 5eb85ffb0..45d0c7caa 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createArrayBracket.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createArrayBracket.ts @@ -14,10 +14,10 @@ export function createOpeningArrayBracket() { fontSize: "var(--ifm-code-font-size)", opacity: "0.6", marginLeft: "-.5rem", - paddingBottom: ".5rem", + paddingBottom: ".5rem" }, - children: ["Array ["], - }), + children: ["Array ["] + }) }); } @@ -27,9 +27,9 @@ export function createClosingArrayBracket() { style: { fontSize: "var(--ifm-code-font-size)", opacity: "0.6", - marginLeft: "-.5rem", + marginLeft: "-.5rem" }, - children: ["]"], - }), + children: ["]"] + }) }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createAuthentication.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createAuthentication.ts index 013764016..c0b61454c 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createAuthentication.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createAuthentication.ts @@ -20,8 +20,8 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("tr", { children: [ create("th", { children: "Security Scheme Type:" }), - create("td", { children: type }), - ], + create("td", { children: type }) + ] }); const createOAuthFlowRows = () => { @@ -39,7 +39,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { ), guard(authorizationUrl, () => create("p", { - children: `Authorization URL: ${authorizationUrl}`, + children: `Authorization URL: ${authorizationUrl}` }) ), guard(refreshUrl, () => @@ -49,11 +49,11 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("ul", { children: Object.entries(scopes).map(([scope, description]) => create("li", { children: `${scope}: ${description}` }) - ), - }), - ], - }), - ], + ) + }) + ] + }) + ] }); }); @@ -71,13 +71,13 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("tr", { children: [ create("th", { children: "Header parameter name:" }), - create("td", { children: name }), - ], - }), - ], - }), - }), - ], + create("td", { children: name }) + ] + }) + ] + }) + }) + ] }); case "http": return create("div", { @@ -89,34 +89,31 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("tr", { children: [ create("th", { children: "HTTP Authorization Scheme:" }), - create("td", { children: scheme }), - ], + create("td", { children: scheme }) + ] }), guard(bearerFormat, () => create("tr", { children: [ create("th", { children: "Bearer format:" }), - create("td", { children: bearerFormat }), - ], + create("td", { children: bearerFormat }) + ] }) - ), - ], - }), - }), - ], + ) + ] + }) + }) + ] }); case "oauth2": return create("div", { children: [ create("table", { children: create("tbody", { - children: [ - createSecuritySchemeTypeRow(), - createOAuthFlowRows(), - ], - }), - }), - ], + children: [createSecuritySchemeTypeRow(), createOAuthFlowRows()] + }) + }) + ] }); case "openIdConnect": return create("div", { @@ -129,14 +126,14 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("tr", { children: [ create("th", { children: "OpenID Connect URL:" }), - create("td", { children: openIdConnectUrl }), - ], + create("td", { children: openIdConnectUrl }) + ] }) - ), - ], - }), - }), - ], + ) + ] + }) + }) + ] }); default: return ""; @@ -170,7 +167,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { create("h2", { children: "Authentication", id: "authentication", - style: { marginBottom: "1rem" }, + style: { marginBottom: "1rem" } }), create("SchemaTabs", { className: "openapi-tabs__security-schemes", @@ -185,12 +182,12 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) { value: `${schemeKey}`, children: [ createDescription(schemeObj.description), - createAuthenticationTable(schemeObj), - ], + createAuthenticationTable(schemeObj) + ] }) - ), - }), + ) + }) ], - style: { marginBottom: "2rem" }, + style: { marginBottom: "2rem" } }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createContactInfo.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createContactInfo.ts index db19e0223..cea77f784 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createContactInfo.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createContactInfo.ts @@ -16,26 +16,26 @@ export function createContactInfo(contact: ContactObject) { style: { display: "flex", flexDirection: "column", - marginBottom: "var(--ifm-paragraph-margin-bottom)", + marginBottom: "var(--ifm-paragraph-margin-bottom)" }, children: [ create("h3", { style: { - marginBottom: "0.25rem", + marginBottom: "0.25rem" }, - children: "Contact", + children: "Contact" }), create("span", { children: [ guard(name, () => `${name}: `), - guard(email, () => `[${email}](mailto:${email})`), - ], + guard(email, () => `[${email}](mailto:${email})`) + ] }), guard(url, () => create("span", { - children: ["URL: ", `[${url}](mailto:${url})`], + children: ["URL: ", `[${url}](mailto:${url})`] }) - ), - ], + ) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDeprecationNotice.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDeprecationNotice.ts index 591fb0f52..2baa1534d 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDeprecationNotice.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDeprecationNotice.ts @@ -18,13 +18,13 @@ interface DeprecationNoticeProps { export function createDeprecationNotice({ deprecated, - description, + description }: DeprecationNoticeProps) { return guard(deprecated, () => createAdmonition({ children: clean(description) ?? - "This endpoint has been deprecated and may be replaced or removed in future versions of the API.", + "This endpoint has been deprecated and may be replaced or removed in future versions of the API." }) ); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetails.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetails.ts index 4c969ce8e..3114f3222 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetails.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetails.ts @@ -11,6 +11,6 @@ export function createDetails({ children, style, ...rest }: Props) { return create("details", { style: { ...style }, ...rest, - children, + children }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetailsSummary.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetailsSummary.ts index 09bc034b9..bffd4405a 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetailsSummary.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDetailsSummary.ts @@ -11,6 +11,6 @@ export function createDetailsSummary({ children, style, ...rest }: Props) { return create("summary", { style: { ...style }, ...rest, - children, + children }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDownload.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDownload.ts index 10bb2ba5a..999041980 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createDownload.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createDownload.ts @@ -10,6 +10,6 @@ import { create, guard } from "./utils"; export function createDownload(url: string | undefined) { return guard(url, (url) => [ create("Export", { url: url, proxy: undefined }), - `\n\n`, + `\n\n` ]); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createHeading.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createHeading.ts index 1ee3455ad..4fdad9c8c 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createHeading.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createHeading.ts @@ -11,8 +11,8 @@ export function createHeading(heading: string) { return [ create("h1", { className: "openapi__heading", - children: clean(heading), + children: clean(heading) }), - `\n\n`, + `\n\n` ]; } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createLicense.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createLicense.ts index c1d981dbc..ac5148b6b 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createLicense.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createLicense.ts @@ -14,21 +14,21 @@ export function createLicense(license: LicenseObject) { return create("div", { style: { - marginBottom: "var(--ifm-paragraph-margin-bottom)", + marginBottom: "var(--ifm-paragraph-margin-bottom)" }, children: [ create("h3", { style: { - marginBottom: "0.25rem", + marginBottom: "0.25rem" }, - children: "License", + children: "License" }), guard(url, () => create("a", { href: url, - children: name ?? url, + children: name ?? url }) - ), - ], + ) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createLogo.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createLogo.ts index 8e9006bb0..5ecbfb930 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createLogo.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createLogo.ts @@ -15,7 +15,7 @@ export function createLogo( return guard(logo || darkLogo, () => [ create("ApiLogo", { logo: logo, - darkLogo: darkLogo, - }), + darkLogo: darkLogo + }) ]); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createParamsDetails.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createParamsDetails.ts index 9c5b1db49..a0c3092e9 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createParamsDetails.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createParamsDetails.ts @@ -36,9 +36,9 @@ export function createParamsDetails({ parameters, type }: Props) { className: "openapi-markdown__details-summary-header-params", children: `${ type.charAt(0).toUpperCase() + type.slice(1) - } Parameters`, - }), - ], + } Parameters` + }) + ] }), create("div", { children: [ @@ -46,12 +46,12 @@ export function createParamsDetails({ parameters, type }: Props) { children: params.map((param) => create("ParamsItem", { className: "paramsItem", - param: param, + param: param }) - ), - }), - ], - }), - ], + ) + }) + ] + }) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createRequestSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createRequestSchema.ts index d22dd2c3f..fbe1bdb7e 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createRequestSchema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createRequestSchema.ts @@ -67,15 +67,15 @@ export function createRequestSchema({ title, body, ...rest }: Props) { create("h3", { className: "openapi-markdown__details-summary-header-body", - children: `${title}`, + children: `${title}` }), guard(body.required && body.required === true, () => [ create("span", { className: "openapi-schema__required", - children: "required", - }), - ]), - ], + children: "required" + }) + ]) + ] }), create("div", { style: { textAlign: "left", marginLeft: "1rem" }, @@ -83,20 +83,20 @@ export function createRequestSchema({ title, body, ...rest }: Props) { guard(body.description, () => [ create("div", { style: { marginTop: "1rem", marginBottom: "1rem" }, - children: createDescription(body.description), - }), - ]), - ], + children: createDescription(body.description) + }) + ]) + ] }), create("ul", { style: { marginLeft: "1rem" }, - children: createNodes(firstBody, "request"), - }), - ], - }), - ], + children: createNodes(firstBody, "request") + }) + ] + }) + ] }); - }), + }) }); } @@ -132,21 +132,21 @@ export function createRequestSchema({ title, body, ...rest }: Props) { children: [ create("h3", { className: "openapi-markdown__details-summary-header-body", - children: `${title}`, + children: `${title}` }), guard(firstBody.type === "array", (format) => create("span", { style: { opacity: "0.6" }, - children: ` array`, + children: ` array` }) ), guard(body.required, () => [ create("strong", { className: "openapi-schema__required", - children: "required", - }), - ]), - ], + children: "required" + }) + ]) + ] }), create("div", { style: { textAlign: "left", marginLeft: "1rem" }, @@ -154,19 +154,19 @@ export function createRequestSchema({ title, body, ...rest }: Props) { guard(body.description, () => [ create("div", { style: { marginTop: "1rem", marginBottom: "1rem" }, - children: createDescription(body.description), - }), - ]), - ], + children: createDescription(body.description) + }) + ]) + ] }), create("ul", { style: { marginLeft: "1rem" }, - children: createNodes(firstBody, "request"), - }), - ], - }), - ], - }), - ], + children: createNodes(firstBody, "request") + }) + ] + }) + ] + }) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createResponseSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createResponseSchema.ts index 7a645c289..1a68bbf08 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createResponseSchema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createResponseSchema.ts @@ -13,7 +13,7 @@ import { createNodes } from "./createSchema"; import { createExampleFromSchema, createResponseExample, - createResponseExamples, + createResponseExamples } from "./createStatusCodes"; import { create, guard } from "./utils"; @@ -96,11 +96,11 @@ export function createResponseSchema({ title, body, ...rest }: Props) { () => [ create("span", { className: "openapi-schema__required", - children: "required", - }), + children: "required" + }) ] - ), - ], + ) + ] }), create("div", { style: { textAlign: "left", marginLeft: "1rem" }, @@ -109,31 +109,31 @@ export function createResponseSchema({ title, body, ...rest }: Props) { create("div", { style: { marginTop: "1rem", - marginBottom: "1rem", + marginBottom: "1rem" }, - children: createDescription(body.description), - }), - ]), - ], + children: createDescription(body.description) + }) + ]) + ] }), create("ul", { style: { marginLeft: "1rem" }, - children: createNodes(firstBody!, "response"), - }), - ], - }), - ], + children: createNodes(firstBody!, "response") + }) + ] + }) + ] }), firstBody && createExampleFromSchema(firstBody, mimeType), responseExamples && createResponseExamples(responseExamples, mimeType), responseExample && - createResponseExample(responseExample, mimeType), - ], - }), - ], + createResponseExample(responseExample, mimeType) + ] + }) + ] }); - }), + }) }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.test.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.test.ts index 711f70776..66f5d07c0 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.test.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.test.ts @@ -21,31 +21,31 @@ describe("createNodes", () => { type: "object", properties: { noseLength: { - type: "number", - }, + type: "number" + } }, required: ["noseLength"], - description: "Clown's nose length", + description: "Clown's nose length" }, { type: "array", items: { - type: "string", + type: "string" }, - description: "Array of strings", + description: "Array of strings" }, { - type: "boolean", + type: "boolean" }, { - type: "number", + type: "number" }, { - type: "string", - }, - ], - }, - }, + type: "string" + } + ] + } + } }; expect( createNodes(schema, "request").map((md: any) => diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts index deb374a03..420257c7a 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts @@ -10,7 +10,7 @@ import clsx from "clsx"; import { SchemaObject } from "../openapi/types"; import { createClosingArrayBracket, - createOpeningArrayBracket, + createOpeningArrayBracket } from "./createArrayBracket"; import { createDescription } from "./createDescription"; import { createDetails } from "./createDetails"; @@ -39,9 +39,9 @@ export function mergeAllOf(allOf: SchemaObject[]) { }, "x-examples": function () { return true; - }, + } }, - ignoreAdditionalProperties: true, + ignoreAdditionalProperties: true }); const required = allOf.reduce((acc, cur) => { @@ -64,7 +64,7 @@ function createAnyOneOf(schema: SchemaObject): any { children: [ create("span", { className: "badge badge--info", - children: type, + children: type }), create("SchemaTabs", { children: schema[type]!.map((anyOneSchema, index) => { @@ -104,23 +104,23 @@ function createAnyOneOf(schema: SchemaObject): any { children: [ createOpeningArrayBracket(), anyOneChildren, - createClosingArrayBracket(), + createClosingArrayBracket() ] .filter(Boolean) - .flat(), + .flat() }); } return create("TabItem", { label: label, value: `${index}-item-properties`, - children: anyOneChildren.filter(Boolean).flat(), + children: anyOneChildren.filter(Boolean).flat() }); } return undefined; - }), - }), - ], + }) + }) + ] }); } @@ -136,7 +136,7 @@ function createProperties(schema: SchemaObject) { required: Array.isArray(schema.required) ? schema.required.includes(key) : false, - discriminator, + discriminator }); }); } @@ -156,7 +156,7 @@ function createAdditionalProperties(schema: SchemaObject) { qualifierMessage: getQualifierMessage(schema.additionalProperties), schema: schema, collapsible: false, - discriminator: false, + discriminator: false }); } if ( @@ -203,7 +203,7 @@ function createAdditionalProperties(schema: SchemaObject) { getQualifierMessage(schema.additionalProperties), schema: schema, collapsible: false, - discriminator: false, + discriminator: false }); } const schemaName = getSchemaName(schema.additionalProperties!); @@ -214,7 +214,7 @@ function createAdditionalProperties(schema: SchemaObject) { qualifierMessage: getQualifierMessage(schema), schema: schema.additionalProperties, collapsible: false, - discriminator: false, + discriminator: false }); } return Object.entries(schema.additionalProperties!).map(([key, val]) => @@ -223,7 +223,7 @@ function createAdditionalProperties(schema: SchemaObject) { schema: val, required: Array.isArray(schema.required) ? schema.required.includes(key) - : false, + : false }) ); } @@ -236,7 +236,7 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createProperties(schema.items), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -244,7 +244,7 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createAdditionalProperties(schema.items), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -252,14 +252,14 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createAnyOneOf(schema.items!), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } if (schema.items?.allOf !== undefined) { // TODO: figure out if and how we should pass merged required array const { - mergedSchemas, + mergedSchemas }: { mergedSchemas: SchemaObject; required: string[] } = mergeAllOf( schema.items?.allOf ); @@ -274,7 +274,7 @@ function createItems(schema: SchemaObject) { createOpeningArrayBracket(), createAnyOneOf(mergedSchemas), createProperties(mergedSchemas), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -286,7 +286,7 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createAnyOneOf(mergedSchemas), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -295,7 +295,7 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createProperties(mergedSchemas), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } } @@ -310,7 +310,7 @@ function createItems(schema: SchemaObject) { return [ createOpeningArrayBracket(), createNodes(schema.items, SCHEMA_TYPE), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -323,10 +323,10 @@ function createItems(schema: SchemaObject) { schema: val, required: Array.isArray(schema.required) ? schema.required.includes(key) - : false, + : false }) ), - createClosingArrayBracket(), + createClosingArrayBracket() ].flat(); } @@ -354,13 +354,13 @@ function createDetailsNode( children: [ create("strong", { className: clsx("openapi-schema__property", { - "openapi-schema__strikethrough": schema.deprecated, + "openapi-schema__strikethrough": schema.deprecated }), - children: name, + children: name }), create("span", { className: "openapi-schema__name", - children: ` ${schemaName}`, + children: ` ${schemaName}` }), guard( (Array.isArray(required) @@ -370,15 +370,15 @@ function createDetailsNode( nullable, () => [ create("span", { - className: "openapi-schema__divider", - }), + className: "openapi-schema__divider" + }) ] ), guard(nullable, () => [ create("span", { className: "openapi-schema__nullable", - children: "nullable", - }), + children: "nullable" + }) ]), guard( Array.isArray(required) @@ -387,19 +387,19 @@ function createDetailsNode( () => [ create("span", { className: "openapi-schema__required", - children: "required", - }), + children: "required" + }) ] ), guard(schema.deprecated, () => [ create("span", { className: "openapi-schema__deprecated", - children: "deprecated", - }), - ]), - ], - }), - ], + children: "deprecated" + }) + ]) + ] + }) + ] }), create("div", { style: { marginLeft: "1rem" }, @@ -407,21 +407,21 @@ function createDetailsNode( guard(getQualifierMessage(schema), (message) => create("div", { style: { marginTop: ".5rem", marginBottom: ".5rem" }, - children: createDescription(message), + children: createDescription(message) }) ), guard(schema.description, (description) => create("div", { style: { marginTop: ".5rem", marginBottom: ".5rem" }, - children: createDescription(description), + children: createDescription(description) }) ), - createNodes(schema, SCHEMA_TYPE), - ], - }), - ], - }), - ], + createNodes(schema, SCHEMA_TYPE) + ] + }) + ] + }) + ] }); } @@ -447,7 +447,7 @@ function createAnyOneOfProperty( create("strong", { children: name }), create("span", { style: { opacity: "0.6" }, - children: ` ${schemaName}`, + children: ` ${schemaName}` }), guard( (schema.nullable && schema.nullable === true) || @@ -456,10 +456,10 @@ function createAnyOneOfProperty( create("strong", { style: { fontSize: "var(--ifm-code-font-size)", - color: "var(--openapi-nullable)", + color: "var(--openapi-nullable)" }, - children: " nullable", - }), + children: " nullable" + }) ] ), guard( @@ -470,13 +470,13 @@ function createAnyOneOfProperty( create("strong", { style: { fontSize: "var(--ifm-code-font-size)", - color: "var(--openapi-required)", + color: "var(--openapi-required)" }, - children: " required", - }), + children: " required" + }) ] - ), - ], + ) + ] }), create("div", { style: { marginLeft: "1rem" }, @@ -484,21 +484,21 @@ function createAnyOneOfProperty( guard(getQualifierMessage(schema), (message) => create("div", { style: { marginTop: ".5rem", marginBottom: ".5rem" }, - children: createDescription(message), + children: createDescription(message) }) ), guard(schema.description, (description) => create("div", { style: { marginTop: ".5rem", marginBottom: ".5rem" }, - children: createDescription(description), + children: createDescription(description) }) - ), - ], + ) + ] }), - createAnyOneOf(schema), - ], - }), - ], + createAnyOneOf(schema) + ] + }) + ] }); } @@ -530,36 +530,36 @@ function createPropertyDiscriminator( children: [ create("strong", { className: "openapi-discriminator__name openapi-schema__property", - children: name, + children: name }), guard(schemaName, (name) => create("span", { className: "openapi-schema__name", - children: ` ${schemaName}`, + children: ` ${schemaName}` }) ), guard(required, () => [ create("span", { className: "openapi-schema__required", - children: "required", - }), - ]), - ], + children: "required" + }) + ]) + ] }), guard(getQualifierMessage(discriminator), (message) => create("div", { style: { - paddingLeft: "1rem", + paddingLeft: "1rem" }, - children: createDescription(message), + children: createDescription(message) }) ), guard(schema.description, (description) => create("div", { style: { - paddingLeft: "1rem", + paddingLeft: "1rem" }, - children: createDescription(description), + children: createDescription(description) }) ), create("DiscriminatorTabs", { @@ -570,12 +570,12 @@ function createPropertyDiscriminator( // className: "openapi-tabs__discriminator-item", label: label, value: `${index}-item-discriminator`, - children: [createNodes(discriminator?.mapping[key], SCHEMA_TYPE)], + children: [createNodes(discriminator?.mapping[key], SCHEMA_TYPE)] }); - }), - }), - ], - }), + }) + }) + ] + }) }); } @@ -593,7 +593,7 @@ function createEdges({ name, schema, required, - discriminator, + discriminator }: EdgeProps): any { const schemaName = getSchemaName(schema); @@ -620,7 +620,7 @@ function createEdges({ if (schema.allOf !== undefined) { const { mergedSchemas, - required, + required }: { mergedSchemas: SchemaObject; required: string[] | boolean } = mergeAllOf(schema.allOf); const mergedSchemaName = getSchemaName(mergedSchemas); @@ -687,7 +687,7 @@ function createEdges({ required: Array.isArray(required) ? required.includes(name) : required, schemaName: schemaName, qualifierMessage: getQualifierMessage(schema), - schema: mergedSchemas, + schema: mergedSchemas }); } @@ -751,7 +751,7 @@ function createEdges({ required: Array.isArray(required) ? required.includes(name) : required, schemaName: schemaName, qualifierMessage: getQualifierMessage(schema), - schema: schema, + schema: schema }); } @@ -807,9 +807,9 @@ export function createNodes( style: { marginTop: ".5rem", marginBottom: ".5rem", - marginLeft: "1rem", + marginLeft: "1rem" }, - children: createDescription(schema.allOf[0]), + children: createDescription(schema.allOf[0]) }); } } @@ -817,9 +817,9 @@ export function createNodes( style: { marginTop: ".5rem", marginBottom: ".5rem", - marginLeft: "1rem", + marginLeft: "1rem" }, - children: createDescription(schema.type), + children: createDescription(schema.type) }); } @@ -829,9 +829,9 @@ export function createNodes( style: { marginTop: ".5rem", marginBottom: ".5rem", - marginLeft: "1rem", + marginLeft: "1rem" }, - children: [createDescription(schema)], + children: [createDescription(schema)] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createStatusCodes.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createStatusCodes.ts index c7376f712..a8016505d 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createStatusCodes.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createStatusCodes.ts @@ -76,10 +76,10 @@ function createResponseHeaders(responseHeaders: any) { guard(type, () => [ create("span", { style: { opacity: "0.6" }, - children: ` ${type}`, - }), - ]), - ], + children: ` ${type}` + }) + ]) + ] }), create("div", { children: [ @@ -87,21 +87,21 @@ function createResponseHeaders(responseHeaders: any) { create("div", { style: { marginTop: ".5rem", - marginBottom: ".5rem", + marginBottom: ".5rem" }, children: [ guard(example, () => `Example: ${example}`), - createDescription(description), - ], + createDescription(description) + ] }) - ), - ], - }), - ], + ) + ] + }) + ] }); } - ), - ], + ) + ] }) ); } @@ -126,14 +126,14 @@ export function createResponseExamples( children: [ guard(exampleValue.summary, (summary) => [ create("p", { - children: ` ${summary}`, - }), + children: ` ${summary}` + }) ]), create("ResponseSamples", { responseExample: JSON.stringify(exampleValue.value, null, 2), - language: language, - }), - ], + language: language + }) + ] }); } return create("TabItem", { @@ -142,14 +142,14 @@ export function createResponseExamples( children: [ guard(exampleValue.summary, (summary) => [ create("p", { - children: ` ${summary}`, - }), + children: ` ${summary}` + }) ]), create("ResponseSamples", { responseExample: exampleValue.value, - language: language, - }), - ], + language: language + }) + ] }); } ); @@ -170,14 +170,14 @@ export function createResponseExample(responseExample: any, mimeType: string) { children: [ guard(responseExample.summary, (summary) => [ create("p", { - children: ` ${summary}`, - }), + children: ` ${summary}` + }) ]), create("ResponseSamples", { responseExample: JSON.stringify(responseExample, null, 2), - language: language, - }), - ], + language: language + }) + ] }); } return create("TabItem", { @@ -186,14 +186,14 @@ export function createResponseExample(responseExample: any, mimeType: string) { children: [ guard(responseExample.summary, (summary) => [ create("p", { - children: ` ${summary}`, - }), + children: ` ${summary}` + }) ]), create("ResponseSamples", { responseExample: responseExample, - language: language, - }), - ], + language: language + }) + ] }); } @@ -213,7 +213,7 @@ export function createExampleFromSchema(schema: any, mimeType: string) { xmlExample = format(json2xml(responseExampleObject, ""), { indentation: " ", lineSeparator: "\n", - collapseContent: true, + collapseContent: true }); } catch { const xmlExampleWithRoot = { root: responseExampleObject }; @@ -221,7 +221,7 @@ export function createExampleFromSchema(schema: any, mimeType: string) { xmlExample = format(json2xml(xmlExampleWithRoot, ""), { indentation: " ", lineSeparator: "\n", - collapseContent: true, + collapseContent: true }); } catch { xmlExample = json2xml(responseExampleObject, ""); @@ -233,9 +233,9 @@ export function createExampleFromSchema(schema: any, mimeType: string) { children: [ create("ResponseSamples", { responseExample: xmlExample, - language: "xml", - }), - ], + language: "xml" + }) + ] }); } } @@ -246,9 +246,9 @@ export function createExampleFromSchema(schema: any, mimeType: string) { children: [ create("ResponseSamples", { responseExample: JSON.stringify(responseExample, null, 2), - language: "json", - }), - ], + language: "json" + }) + ] }); } return undefined; @@ -276,7 +276,7 @@ export function createStatusCodes({ responses }: Props) { value: code, children: [ create("div", { - children: createDescription(responses[code].description), + children: createDescription(responses[code].description) }), responseHeaders && createDetails({ @@ -288,27 +288,27 @@ export function createStatusCodes({ responses }: Props) { createDetailsSummary({ children: [ create("strong", { - children: "Response Headers", - }), - ], + children: "Response Headers" + }) + ] }), - createResponseHeaders(responseHeaders), - ], + createResponseHeaders(responseHeaders) + ] }), create("div", { children: createResponseSchema({ title: "Schema", body: { - content: responses[code].content, - }, - }), - }), - ], + content: responses[code].content + } + }) + }) + ] }); - }), - }), - ], - }), - ], + }) + }) + ] + }) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createTermsOfService.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createTermsOfService.ts index 0f5fdf944..d840fb7dc 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createTermsOfService.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createTermsOfService.ts @@ -12,19 +12,19 @@ export function createTermsOfService(termsOfService: string | undefined) { return create("div", { style: { - marginBottom: "var(--ifm-paragraph-margin-bottom)", + marginBottom: "var(--ifm-paragraph-margin-bottom)" }, children: [ create("h3", { style: { - marginBottom: "0.25rem", + marginBottom: "0.25rem" }, - children: "Terms of Service", + children: "Terms of Service" }), create("a", { href: `${termsOfService}`, - children: termsOfService, - }), - ], + children: termsOfService + }) + ] }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createVersionBadge.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createVersionBadge.ts index 32c95aa65..243c078ee 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createVersionBadge.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createVersionBadge.ts @@ -11,8 +11,8 @@ export function createVersionBadge(version: string | undefined) { return guard(version, (version) => [ create("span", { className: "theme-doc-version-badge badge badge--secondary", - children: `Version: ${escape(version)}`, + children: `Version: ${escape(version)}` }), - `\n\n`, + `\n\n` ]); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/index.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/index.ts index dc294d416..25207277d 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/index.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/index.ts @@ -9,7 +9,7 @@ import { ContactObject, LicenseObject, MediaTypeObject, - SecuritySchemeObject, + SecuritySchemeObject } from "../openapi/types"; import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types"; import { createAuthentication } from "./createAuthentication"; @@ -53,10 +53,10 @@ export function createApiPageMD({ extensions, parameters, requestBody, - responses, + responses }, infoPath, - frontMatter, + frontMatter }: ApiPageMetadata) { return render([ `import ApiTabs from "@theme/ApiTabs";\n`, @@ -82,9 +82,9 @@ export function createApiPageMD({ createParamsDetails({ parameters, type: "cookie" }), createRequestBodyDetails({ title: "Body", - body: requestBody, + body: requestBody } as Props), - createStatusCodes({ responses }), + createStatusCodes({ responses }) ]); } @@ -97,10 +97,10 @@ export function createInfoPageMD({ license, termsOfService, logo, - darkLogo, + darkLogo }, securitySchemes, - downloadUrl, + downloadUrl }: InfoPageMetadata) { return render([ `import ApiLogo from "@theme/ApiLogo";\n`, @@ -116,7 +116,7 @@ export function createInfoPageMD({ createAuthentication(securitySchemes as unknown as SecuritySchemeObject), createContactInfo(contact as ContactObject), createTermsOfService(termsOfService), - createLicense(license as LicenseObject), + createLicense(license as LicenseObject) ]); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts index 47852247e..7f7392cdf 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts @@ -50,7 +50,7 @@ describe("getQualifierMessage", () => { const actual = getQualifierMessage({ minLength: 1, maxLength: 40, - pattern: "^[a-zA-Z0-9_-]*$", + pattern: "^[a-zA-Z0-9_-]*$" }); expect(actual).toBe(expected); }); @@ -113,7 +113,7 @@ describe("getQualifierMessage", () => { const expected = "**Possible values:** `<= 40`"; const actual = getQualifierMessage({ maximum: 40, - exclusiveMaximum: false, + exclusiveMaximum: false }); expect(actual).toBe(expected); }); @@ -129,7 +129,7 @@ describe("getQualifierMessage", () => { const actual = getQualifierMessage({ minimum: 1, maximum: 40, - exclusiveMinimum: true, + exclusiveMinimum: true }); expect(actual).toBe(expected); }); @@ -139,7 +139,7 @@ describe("getQualifierMessage", () => { const actual = getQualifierMessage({ minimum: 1, maximum: 40, - exclusiveMaximum: true, + exclusiveMaximum: true }); expect(actual).toBe(expected); }); @@ -148,7 +148,7 @@ describe("getQualifierMessage", () => { const expected = "**Possible values:** `> 1` and `<= 40`"; const actual = getQualifierMessage({ exclusiveMinimum: 1, - maximum: 40, + maximum: 40 }); expect(actual).toBe(expected); }); @@ -157,7 +157,7 @@ describe("getQualifierMessage", () => { const expected = "**Possible values:** `>= 1` and `< 40`"; const actual = getQualifierMessage({ minimum: 1, - exclusiveMaximum: 40, + exclusiveMaximum: 40 }); expect(actual).toBe(expected); }); @@ -167,21 +167,21 @@ describe("getQualifierMessage", () => { const actual = getQualifierMessage({ exclusiveMinimum: 1, maximum: 40, - exclusiveMaximum: true, + exclusiveMaximum: true }); expect(actual).toBe(expected); }); it("should render nothing with empty boolean exclusiveMinimum", () => { const actual = getQualifierMessage({ - exclusiveMinimum: true, + exclusiveMinimum: true }); expect(actual).toBeUndefined(); }); it("should render nothing with empty boolean exclusiveMaximum", () => { const actual = getQualifierMessage({ - exclusiveMaximum: true, + exclusiveMaximum: true }); expect(actual).toBeUndefined(); }); @@ -189,7 +189,7 @@ describe("getQualifierMessage", () => { it("should render nothing with empty boolean exclusiveMinimum and exclusiveMaximum", () => { const actual = getQualifierMessage({ exclusiveMinimum: true, - exclusiveMaximum: true, + exclusiveMaximum: true }); expect(actual).toBeUndefined(); }); diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/createRequestExample.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/createRequestExample.ts index 8413cb8ea..0bccdfcd3 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/createRequestExample.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/createRequestExample.ts @@ -35,21 +35,21 @@ const primitives: Primitives = { uuid: () => "3fa85f64-5717-4562-b3fc-2c963f66afa6", hostname: () => "example.com", ipv4: () => "198.51.100.42", - ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a", + ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a" }, number: { default: () => 0, - float: () => 0.0, + float: () => 0.0 }, integer: { - default: () => 0, + default: () => 0 }, boolean: { default: (schema) => - typeof schema.default === "boolean" ? schema.default : true, + typeof schema.default === "boolean" ? schema.default : true }, object: {}, - array: {}, + array: {} }; function sampleRequestFromProp(name: string, prop: any, obj: any): any { diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/createResponseExample.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/createResponseExample.ts index 11a287e8b..2c64edbf6 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/createResponseExample.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/createResponseExample.ts @@ -35,21 +35,21 @@ const primitives: Primitives = { uuid: () => "3fa85f64-5717-4562-b3fc-2c963f66afa6", hostname: () => "example.com", ipv4: () => "198.51.100.42", - ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a", + ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a" }, number: { default: () => 0, - float: () => 0.0, + float: () => 0.0 }, integer: { - default: () => 0, + default: () => 0 }, boolean: { default: (schema) => - typeof schema.default === "boolean" ? schema.default : true, + typeof schema.default === "boolean" ? schema.default : true }, object: {}, - array: {}, + array: {} }; function sampleResponseFromProp(name: string, prop: any, obj: any): any { diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts index 8dde3c8d0..ae7b0c496 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts @@ -25,7 +25,7 @@ import { ApiPageMetadata, InfoPageMetadata, SidebarOptions, - TagPageMetadata, + TagPageMetadata } from "../types"; import { sampleRequestFromSchema } from "./createRequestExample"; import { OpenApiObject, TagObject } from "./types"; @@ -113,7 +113,7 @@ function createItems( ? splitDescription[0] .replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'") .replace(/\s+$/, "") - : "", + : "" }, securitySchemes: openapiData.components?.securitySchemes, info: { @@ -121,8 +121,8 @@ function createItems( tags: openapiData.tags, title: openapiData.info.title ?? "Introduction", logo: openapiData.info["x-logo"]! as any, - darkLogo: openapiData.info["x-dark-logo"]! as any, - }, + darkLogo: openapiData.info["x-dark-logo"]! as any + } }; items.push(infoPage); } @@ -242,11 +242,11 @@ function createItems( : "", ...(options?.proxy && { proxy: options.proxy }), ...(options?.hideSendButton && { - hide_send_button: options.hideSendButton, + hide_send_button: options.hideSendButton }), ...(options?.showExtensions && { - show_extensions: options.showExtensions, - }), + show_extensions: options.showExtensions + }) }, api: { ...defaults, @@ -258,8 +258,8 @@ function createItems( security, securitySchemes, jsonRequestBodyExample, - info: openapiData.info, - }, + info: openapiData.info + } }; items.push(apiPage); @@ -386,11 +386,11 @@ function createItems( : "", ...(options?.proxy && { proxy: options.proxy }), ...(options?.hideSendButton && { - hide_send_button: options.hideSendButton, + hide_send_button: options.hideSendButton }), ...(options?.showExtensions && { - show_extensions: options.showExtensions, - }), + show_extensions: options.showExtensions + }) }, api: { ...defaults, @@ -402,8 +402,8 @@ function createItems( security, securitySchemes, jsonRequestBodyExample, - info: openapiData.info, - }, + info: openapiData.info + } }; items.push(apiPage); } @@ -445,11 +445,11 @@ function createItems( ? splitDescription[0] .replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'") .replace(/\s+$/, "") - : "", + : "" }, tag: { - ...tag, - }, + ...tag + } }; items.push(tagPage); }); @@ -499,7 +499,7 @@ export async function readOpenapiFiles( const allFiles = await Globby(["**/*.{json,yaml,yml}"], { cwd: openapiPath, ignore: GlobExcludeDefault, - deep: 1, + deep: 1 }); const sources = allFiles.filter((x) => !x.includes("_category_")); // todo: regex exclude? return Promise.all( @@ -512,7 +512,7 @@ export async function readOpenapiFiles( return { source: fullPath, // This will be aliased in process. sourceDirName: path.dirname(source), - data, + data }; }) ); @@ -525,8 +525,8 @@ export async function readOpenapiFiles( { source: openapiPath, // This will be aliased in process. sourceDirName: ".", - data, - }, + data + } ]; } @@ -543,7 +543,7 @@ export async function processOpenapiFiles( sidebarOptions ); const itemsObjectsArray = processedFile[0].map((item) => ({ - ...item, + ...item })); const tags = processedFile[1]; return [itemsObjectsArray, tags]; @@ -600,7 +600,7 @@ export function getTagDisplayName(tagName: string, tags: TagObject[]): string { // find the very own tagObject const tagObject = tags.find((tagObject) => tagObject.name === tagName) ?? { // if none found, just fake one - name: tagName, + name: tagName }; // return the first found and filled value from the property list diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/loadAndResolveSpec.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/loadAndResolveSpec.ts index ee59054b2..b251c6c4b 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/loadAndResolveSpec.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/loadAndResolveSpec.ts @@ -71,7 +71,7 @@ export function convertSwagger2OpenAPI(spec: object) { warnOnly: true, text: "{}", anchors: true, - resolveInternal: true, + resolveInternal: true }, (err: any, res: any) => { // TODO: log any warnings @@ -92,12 +92,12 @@ async function resolveJsonRefs(specUrlOrObject: object | string) { file: true, external: true, http: { - timeout: 15000, // 15 sec timeout - }, + timeout: 15000 // 15 sec timeout + } }, dereference: { - circular: true, - }, + circular: true + } }); return schema as OpenApiObject; } catch (err: any) { @@ -119,13 +119,13 @@ export async function loadAndResolveSpec(specUrlOrObject: object | string) { const config = new Config({} as ResolvedConfig); const bundleOpts = { config, - base: process.cwd(), + base: process.cwd() } as any; if (typeof specUrlOrObject === "object" && specUrlOrObject !== null) { bundleOpts["doc"] = { source: { absoluteRef: "" } as Source, - parsed: specUrlOrObject, + parsed: specUrlOrObject } as Document; } else { bundleOpts["ref"] = specUrlOrObject; @@ -135,7 +135,7 @@ export async function loadAndResolveSpec(specUrlOrObject: object | string) { // bundleOpts["dereference"] = true; const { - bundle: { parsed }, + bundle: { parsed } } = await bundle(bundleOpts); //Pre-processing before resolving JSON refs diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/OpenAPIParser.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/OpenAPIParser.ts index 8f18c8b30..dcf8a6326 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/OpenAPIParser.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/OpenAPIParser.ts @@ -190,13 +190,13 @@ export class OpenAPIParser { ) ) { return { - allOf: [rest, resolved], + allOf: [rest, resolved] }; } else { // small optimization return { ...resolved, - ...rest, + ...rest }; } } @@ -227,7 +227,7 @@ export class OpenAPIParser { ...schema, allOf: undefined, parentRefs: [], - title: schema.title || getDefinitionName($ref), + title: schema.title || getDefinitionName($ref) }; // avoid mutating inner objects @@ -258,7 +258,7 @@ export class OpenAPIParser { receiver.parentRefs!.push(...(subMerged.parentRefs || [])); return { $ref: subRef, - schema: subMerged, + schema: subMerged }; }) .filter((child) => child !== undefined) as Array<{ @@ -326,8 +326,8 @@ export class OpenAPIParser { const receiverItems = isBoolean(receiver.items) ? { items: receiver.items } : receiver.items - ? (Object.assign({}, receiver.items) as OpenAPISchema) - : {}; + ? (Object.assign({}, receiver.items) as OpenAPISchema) + : {}; const subSchemaItems = isBoolean(items) ? { items } : (Object.assign({}, items) as OpenAPISchema); @@ -355,7 +355,7 @@ export class OpenAPIParser { receiver = { ...receiver, title: receiver.title || title, - ...otherConstraints, + ...otherConstraints }; if (subSchemaRef) { @@ -389,7 +389,7 @@ export class OpenAPIParser { ) ) { res["#/components/schemas/" + defName] = [ - def["x-discriminator-value"] || defName, + def["x-discriminator-value"] || defName ]; } } @@ -416,14 +416,14 @@ export class OpenAPIParser { return { oneOf: sub.oneOf.map((part) => { const merged = this.mergeAllOf({ - allOf: [...beforeAllOf, part, ...afterAllOf], + allOf: [...beforeAllOf, part, ...afterAllOf] }); // each oneOf should be independent so exiting all the parent refs // otherwise it will cause false-positive recursive detection this.exitParents(merged); return merged; - }), + }) }; } } diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/RedocNormalizedOptions.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/RedocNormalizedOptions.ts index 26793aa2f..fd82bbb17 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/RedocNormalizedOptions.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/services/RedocNormalizedOptions.ts @@ -12,7 +12,7 @@ import { isArray } from "../utils/helpers"; export enum SideNavStyleEnum { SummaryOnly = "summary-only", PathOnly = "path-only", - IdOnly = "id-only", + IdOnly = "id-only" } export interface RedocRawOptions { diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts index 2fbd16d00..909692efb 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts @@ -19,14 +19,14 @@ import { OpenAPIResponse, OpenAPISchema, OpenAPIServer, - Referenced, + Referenced } from "../types"; import { isNumeric, removeQueryString, resolveUrl, isArray, - isBoolean, + isBoolean } from "./helpers"; function isWildcardStatusCode( @@ -79,7 +79,7 @@ const operationNames = { patch: true, delete: true, options: true, - $ref: true, + $ref: true }; export function isOperationName(key: string): boolean { @@ -120,7 +120,7 @@ const schemaKeywordTypes = { additionalProperties: "object", unevaluatedProperties: "object", properties: "object", - patternProperties: "object", + patternProperties: "object" }; export function detectType(schema: OpenAPISchema): string { @@ -623,7 +623,7 @@ export function mergeSimilarMediaTypes( } mergedTypes[normalizedMimeName] = { ...mergedTypes[normalizedMimeName], - ...mime, + ...mime }; }); @@ -659,8 +659,8 @@ export function normalizeServers( // Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object servers = [ { - url: "/", - }, + url: "/" + } ]; } @@ -672,7 +672,7 @@ export function normalizeServers( return { ...server, url: normalizeUrl(server.url), - description: server.description || "", + description: server.description || "" }; }); } @@ -688,8 +688,8 @@ export function setSecuritySchemePrefix(prefix: string) { export const shortenHTTPVerb = (verb) => ({ delete: "del", - options: "opts", - }[verb] || verb); + options: "opts" + })[verb] || verb; export function isRedocExtension(key: string): boolean { const redocExtensions = { @@ -705,7 +705,7 @@ export function isRedocExtension(key: string): boolean { "x-tagGroups": true, "x-traitTag": true, "x-additionalPropertiesName": true, - "x-explicitMappingOnly": true, + "x-explicitMappingOnly": true }; return key in redocExtensions; @@ -753,7 +753,7 @@ export function getContentWithLegacyExamples( const examples = xExamples[mime]; mediaContent[mime] = { ...mediaContent[mime], - examples, + examples }; } } else if (xExample) { @@ -762,7 +762,7 @@ export function getContentWithLegacyExamples( const example = xExample[mime]; mediaContent[mime] = { ...mediaContent[mime], - example, + example }; } } diff --git a/packages/docusaurus-plugin-openapi-docs/src/options.ts b/packages/docusaurus-plugin-openapi-docs/src/options.ts index d2a56805d..0fcab893e 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/options.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/options.ts @@ -12,13 +12,13 @@ const sidebarOptions = Joi.object({ categoryLinkSource: Joi.string().valid("tag", "info", "auto"), customProps: Joi.object(), sidebarCollapsible: Joi.boolean(), - sidebarCollapsed: Joi.boolean(), + sidebarCollapsed: Joi.boolean() }); const markdownGenerators = Joi.object({ createApiPageMD: Joi.function(), createInfoPageMD: Joi.function(), - createTagPageMD: Joi.function(), + createTagPageMD: Joi.function() }); export const OptionsSchema = Joi.object({ @@ -39,15 +39,15 @@ export const OptionsSchema = Joi.object({ markdownGenerators: markdownGenerators, version: Joi.string().when("versions", { is: Joi.exist(), - then: Joi.required(), + then: Joi.required() }), label: Joi.string().when("versions", { is: Joi.exist(), - then: Joi.required(), + then: Joi.required() }), baseUrl: Joi.string().when("versions", { is: Joi.exist(), - then: Joi.required(), + then: Joi.required() }), versions: Joi.object().pattern( /^/, @@ -55,10 +55,10 @@ export const OptionsSchema = Joi.object({ specPath: Joi.string().required(), outputDir: Joi.string().required(), label: Joi.string().required(), - baseUrl: Joi.string().required(), + baseUrl: Joi.string().required() }) - ), + ) }) ) - .required(), + .required() }); diff --git a/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts b/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts index b3e62abf3..e36de77b2 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts @@ -11,7 +11,7 @@ import { ProcessedSidebar, SidebarItemCategory, SidebarItemCategoryLinkConfig, - SidebarItemDoc, + SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types"; import { posixPath } from "@docusaurus/utils"; import clsx from "clsx"; @@ -23,7 +23,7 @@ import type { SidebarOptions, APIOptions, ApiPageMetadata, - ApiMetadata, + ApiMetadata } from "../types"; function isApiItem(item: ApiMetadata): item is ApiMetadata { @@ -50,7 +50,7 @@ function groupByTags( sidebarCollapsed, sidebarCollapsible, customProps, - categoryLinkSource, + categoryLinkSource } = sidebarOptions; const apiItems = items.filter(isApiItem); @@ -60,7 +60,7 @@ function groupByTags( id: item.id, title: item.title, description: item.description, - tags: item.info.tags, + tags: item.info.tags }; }); @@ -98,10 +98,10 @@ function groupByTags( className: clsx( { "menu__list-item--deprecated": item.api.deprecated, - "api-method": !!item.api.method, + "api-method": !!item.api.method }, item.api.method - ), + ) }; } @@ -111,7 +111,7 @@ function groupByTags( const id = infoItem.id; rootIntroDoc = { type: "doc" as const, - id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}`, + id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}` }; } @@ -125,7 +125,7 @@ function groupByTags( (t) => tag === t.name ?? { name: tag, - description: `${tag} Index`, + description: `${tag} Index` } ); @@ -138,7 +138,7 @@ function groupByTags( id: basePath === "" || undefined ? `${taggedInfoObject.id}` - : `${basePath}/${taggedInfoObject.id}`, + : `${basePath}/${taggedInfoObject.id}` } as SidebarItemCategoryLinkConfig; } @@ -147,8 +147,7 @@ function groupByTags( const tagId = kebabCase(tagObject.name); linkConfig = { type: "doc", - id: - basePath === "" || undefined ? `${tagId}` : `${basePath}/${tagId}`, + id: basePath === "" || undefined ? `${tagId}` : `${basePath}/${tagId}` } as SidebarItemCategoryLinkConfig; } @@ -165,7 +164,7 @@ function groupByTags( kebabCase(tag) ) ) - : posixPath(path.join("/category", basePath, kebabCase(tag))), + : posixPath(path.join("/category", basePath, kebabCase(tag))) } as SidebarItemCategoryLinkConfig; } @@ -177,7 +176,7 @@ function groupByTags( collapsed: sidebarCollapsed, items: apiItems .filter((item) => !!item.api.tags?.includes(tag)) - .map(createDocItem), + .map(createDocItem) }; }) .filter((item) => item.items.length > 0); // Filter out any categories with no items. @@ -196,8 +195,8 @@ function groupByTags( collapsed: sidebarCollapsed!, items: apiItems .filter(({ api }) => api.tags === undefined || api.tags.length === 0) - .map(createDocItem), - }, + .map(createDocItem) + } ]; } diff --git a/packages/docusaurus-plugin-openapi-docs/src/types.ts b/packages/docusaurus-plugin-openapi-docs/src/types.ts index 7c12d0805..a7d3713e6 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/types.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/types.ts @@ -11,14 +11,14 @@ import { InfoObject, OperationObject, SecuritySchemeObject, - TagObject, + TagObject } from "./openapi/types"; export type { PropSidebarItemCategory, SidebarItemLink, PropSidebar, - PropSidebarItem, + PropSidebarItem } from "@docusaurus/plugin-content-docs-types"; export interface PluginOptions { id?: string; diff --git a/packages/docusaurus-theme-openapi-docs/babel.config.js b/packages/docusaurus-theme-openapi-docs/babel.config.js index dfa76c9ab..3b304e7d3 100644 --- a/packages/docusaurus-theme-openapi-docs/babel.config.js +++ b/packages/docusaurus-theme-openapi-docs/babel.config.js @@ -12,14 +12,14 @@ module.exports = { // we mostly need to transpile some features so that node does not crash... lib: { presets: [ - ["@babel/preset-typescript", { isTSX: true, allExtensions: true }], + ["@babel/preset-typescript", { isTSX: true, allExtensions: true }] ], // Useful to transpile for older node versions plugins: [ "@babel/plugin-transform-modules-commonjs", "@babel/plugin-proposal-nullish-coalescing-operator", - "@babel/plugin-proposal-optional-chaining", - ], + "@babel/plugin-proposal-optional-chaining" + ] }, // USED FOR JS SWIZZLE @@ -28,8 +28,8 @@ module.exports = { // This source code should look clean/human readable to be usable "lib-next": { presets: [ - ["@babel/preset-typescript", { isTSX: true, allExtensions: true }], - ], - }, - }, + ["@babel/preset-typescript", { isTSX: true, allExtensions: true }] + ] + } + } }; diff --git a/packages/docusaurus-theme-openapi-docs/src/index.ts b/packages/docusaurus-theme-openapi-docs/src/index.ts index 1ad7976e9..ae821d31b 100644 --- a/packages/docusaurus-theme-openapi-docs/src/index.ts +++ b/packages/docusaurus-theme-openapi-docs/src/index.ts @@ -19,7 +19,7 @@ export default function docusaurusThemeOpenAPI(): Plugin { const modules = [ require.resolve( path.join(__dirname, "..", "lib", "theme", "styles.scss") - ), + ) ]; return modules; }, @@ -51,17 +51,17 @@ export default function docusaurusThemeOpenAPI(): Plugin { ...getStyleLoaders(isServer, {}), { loader: require.resolve("sass-loader"), - options: {}, - }, - ], - }, - ], - }, + options: {} + } + ] + } + ] + } }; } return { - plugins: [new NodePolyfillPlugin()], + plugins: [new NodePolyfillPlugin()] }; - }, + } }; } diff --git a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts index 8961e7d49..b2dbef810 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts +++ b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts @@ -7,6 +7,8 @@ /// +/* eslint-disable @typescript-eslint/no-use-before-define */ + declare module "@docusaurus/plugin-content-docs-types" { // Makes all properties visible when hovering over the type type Expand> = { [P in keyof T]: T[P] }; diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js index cb71c3299..75f9cef5e 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js @@ -24,7 +24,7 @@ export default function ExpandButton({ showLineNumbers, blockClassName, title, - lineClassNames, + lineClassNames }) { const prismTheme = usePrismTheme(); @@ -51,18 +51,18 @@ export default function ExpandButton({ ? translate({ id: "theme.CodeBlock.expanded", message: "Expanded", - description: "The expanded button label on code blocks", + description: "The expanded button label on code blocks" }) : translate({ id: "theme.CodeBlock.expandButtonAriaLabel", message: "Expand code to fullscreen", - description: "The ARIA label for expand code blocks button", + description: "The ARIA label for expand code blocks button" }) } title={translate({ id: "theme.CodeBlock.expand", message: "Expand", - description: "The expand button label on code blocks", + description: "The expand button label on code blocks" })} className={clsx( "clean-btn", diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Accept/slice.ts b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Accept/slice.ts index 3fa72c085..777f3b550 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Accept/slice.ts +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Accept/slice.ts @@ -20,8 +20,8 @@ export const slice = createSlice({ reducers: { setAccept: (state, action: PayloadAction) => { state.value = action.payload; - }, - }, + } + } }); export const { setAccept } = slice.actions; diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js index 4909314d3..a543b9179 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js @@ -13,7 +13,7 @@ import { parseLanguage, parseLines, containsLineNumbers, - useCodeWordWrap, + useCodeWordWrap } from "@docusaurus/theme-common/internal"; import Container from "@theme/ApiExplorer/ApiCodeBlock/Container"; import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton"; @@ -29,10 +29,10 @@ export default function CodeBlockString({ metastring, title: titleProp, showLineNumbers: showLineNumbersProp, - language: languageProp, + language: languageProp }) { const { - prism: { defaultLanguage, magicComments }, + prism: { defaultLanguage, magicComments } } = useThemeConfig(); const language = languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage; @@ -45,7 +45,7 @@ export default function CodeBlockString({ const { lineClassNames, code } = parseLines(children, { metastring, language, - magicComments, + magicComments }); const showLineNumbers = showLineNumbersProp ?? containsLineNumbers(metastring); diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js index a85b866b2..81f0443ec 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js @@ -31,18 +31,18 @@ export default function CopyButton({ code, className }) { ? translate({ id: "theme.CodeBlock.copied", message: "Copied", - description: "The copied button label on code blocks", + description: "The copied button label on code blocks" }) : translate({ id: "theme.CodeBlock.copyButtonAriaLabel", message: "Copy code to clipboard", - description: "The ARIA label for copy code blocks button", + description: "The ARIA label for copy code blocks button" }) } title={translate({ id: "theme.CodeBlock.copy", message: "Copy", - description: "The copy button label on code blocks", + description: "The copy button label on code blocks" })} className={clsx( "clean-btn", diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js index 676f3f44b..98d7c3edd 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js @@ -17,12 +17,12 @@ export default function ExitButton({ className, handler }) { aria-label={translate({ id: "theme.CodeBlock.exitButtonAriaLabel", message: "Exit expanded view", - description: "The ARIA label for exit expanded view button", + description: "The ARIA label for exit expanded view button" })} title={translate({ id: "theme.CodeBlock.copy", message: "Copy", - description: "The exit button label on code blocks", + description: "The exit button label on code blocks" })} className={clsx( "clean-btn", diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js index 651732f24..9cbab02d2 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js @@ -24,7 +24,7 @@ export default function ExpandButton({ showLineNumbers, blockClassName, title, - lineClassNames, + lineClassNames }) { const [isModalOpen, setIsModalOpen] = useState(false); const prismTheme = usePrismTheme(); @@ -42,18 +42,18 @@ export default function ExpandButton({ ? translate({ id: "theme.CodeBlock.expanded", message: "Expanded", - description: "The expanded button label on code blocks", + description: "The expanded button label on code blocks" }) : translate({ id: "theme.CodeBlock.expandButtonAriaLabel", message: "Expand code to fullscreen", - description: "The ARIA label for expand code blocks button", + description: "The ARIA label for expand code blocks button" }) } title={translate({ id: "theme.CodeBlock.expand", message: "Expand", - description: "The expand button label on code blocks", + description: "The expand button label on code blocks" })} className={clsx( "clean-btn", diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js index 2cf119bf9..5c4964513 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js @@ -14,7 +14,7 @@ export default function CodeBlockLine({ classNames, showLineNumbers, getLineProps, - getTokenProps, + getTokenProps }) { if (line.length === 1 && line[0].content === "\n") { line[0].content = ""; @@ -24,7 +24,7 @@ export default function CodeBlockLine({ className: clsx( classNames, showLineNumbers && "openapi-explorer__code-block-code-line" - ), + ) }); const lineTokens = line.map((token, key) => ( diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js index 447b776a4..682b8d54d 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js @@ -15,7 +15,7 @@ export default function WordWrapButton({ className, onClick, isEnabled }) { id: "theme.CodeBlock.wordWrapToggle", message: "Toggle word wrap", description: - "The title attribute for toggle word wrapping button of code block lines", + "The title attribute for toggle word wrapping button of code block lines" }); return (