|
| 1 | +// @ts-check |
| 2 | +// Note: type annotations allow type checking and IDEs autocompletion |
| 3 | + |
| 4 | +const { DOCUSAURUS_VERSION } = require("@docusaurus/utils"); |
| 5 | + |
| 6 | +/** @type {import('@docusaurus/types').Config} */ |
| 7 | +const config = { |
| 8 | + title: "Docusaurus OpenAPI Docs", |
| 9 | + tagline: "OpenAPI plugin for generating API reference docs in Docusaurus v2", |
| 10 | + url: "https://docusaurus-openapi.tryingpan.dev", |
| 11 | + baseUrl: "/", |
| 12 | + onBrokenLinks: "warn", |
| 13 | + onBrokenMarkdownLinks: "warn", |
| 14 | + favicon: "img/favicon.ico", |
| 15 | + organizationName: "PaloAltoNetworks", |
| 16 | + projectName: "docusaurus-openapi-docs", |
| 17 | + |
| 18 | + presets: [ |
| 19 | + [ |
| 20 | + "classic", |
| 21 | + /** @type {import('@docusaurus/preset-classic').Options} */ |
| 22 | + ({ |
| 23 | + docs: { |
| 24 | + routeBasePath: "/", |
| 25 | + sidebarPath: require.resolve("./sidebars.js"), |
| 26 | + editUrl: |
| 27 | + "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/tree/main/demo", |
| 28 | + docLayoutComponent: "@theme/DocPage", |
| 29 | + docItemComponent: "@theme/ApiItem", // Derived from docusaurus-theme-openapi |
| 30 | + }, |
| 31 | + blog: false, |
| 32 | + theme: { |
| 33 | + customCss: require.resolve("./src/css/custom.css"), |
| 34 | + }, |
| 35 | + gtag: { |
| 36 | + trackingID: "GTM-THVM29S", |
| 37 | + anonymizeIP: false, |
| 38 | + }, |
| 39 | + }), |
| 40 | + ], |
| 41 | + ], |
| 42 | + |
| 43 | + themeConfig: |
| 44 | + /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ |
| 45 | + ({ |
| 46 | + docs: { |
| 47 | + sidebar: { |
| 48 | + hideable: true, |
| 49 | + }, |
| 50 | + }, |
| 51 | + navbar: { |
| 52 | + title: "OpenAPI Docs", |
| 53 | + logo: { |
| 54 | + alt: "Keytar", |
| 55 | + src: "img/docusaurus-openapi-docs-logo.svg", |
| 56 | + }, |
| 57 | + items: [ |
| 58 | + { |
| 59 | + type: "doc", |
| 60 | + docId: "intro", |
| 61 | + position: "left", |
| 62 | + label: "Docs", |
| 63 | + }, |
| 64 | + { |
| 65 | + type: "dropdown", |
| 66 | + label: "Demos", |
| 67 | + position: "left", |
| 68 | + items: [ |
| 69 | + { |
| 70 | + label: "API Zoo", |
| 71 | + to: "/category/petstore-api", |
| 72 | + }, |
| 73 | + { |
| 74 | + label: "Petstore (versioned)", |
| 75 | + to: "/category/petstore-versioned-api", |
| 76 | + }, |
| 77 | + ], |
| 78 | + }, |
| 79 | + { |
| 80 | + href: "https://medium.com/palo-alto-networks-developer-blog", |
| 81 | + position: "right", |
| 82 | + className: "header-medium-link", |
| 83 | + "aria-label": "Palo Alto Networks Developer Blog", |
| 84 | + }, |
| 85 | + { |
| 86 | + href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs", |
| 87 | + position: "right", |
| 88 | + className: "header-github-link", |
| 89 | + "aria-label": "GitHub repository", |
| 90 | + }, |
| 91 | + ], |
| 92 | + }, |
| 93 | + footer: { |
| 94 | + style: "dark", |
| 95 | + links: [ |
| 96 | + { |
| 97 | + title: "Docs", |
| 98 | + items: [ |
| 99 | + { |
| 100 | + label: "OpenAPI Docs", |
| 101 | + to: "/", |
| 102 | + }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + { |
| 106 | + title: "Community", |
| 107 | + items: [ |
| 108 | + { |
| 109 | + label: "Stack Overflow", |
| 110 | + href: "https://stackoverflow.com/questions/tagged/docusaurus", |
| 111 | + }, |
| 112 | + { |
| 113 | + label: "Discord", |
| 114 | + href: "https://discordapp.com/invite/docusaurus", |
| 115 | + }, |
| 116 | + { |
| 117 | + label: "Twitter", |
| 118 | + href: "https://twitter.com/docusaurus", |
| 119 | + }, |
| 120 | + ], |
| 121 | + }, |
| 122 | + { |
| 123 | + title: "More", |
| 124 | + items: [ |
| 125 | + { |
| 126 | + label: "Blog", |
| 127 | + href: "https://medium.com/palo-alto-networks-developer-blog", |
| 128 | + }, |
| 129 | + { |
| 130 | + label: "GitHub", |
| 131 | + href: "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs", |
| 132 | + }, |
| 133 | + ], |
| 134 | + }, |
| 135 | + ], |
| 136 | + copyright: `Copyright © ${new Date().getFullYear()} Palo Alto Networks, Inc. Built with Docusaurus ${DOCUSAURUS_VERSION}.`, |
| 137 | + }, |
| 138 | + prism: { |
| 139 | + additionalLanguages: ["ruby", "csharp", "php", "java", "powershell"], |
| 140 | + }, |
| 141 | + languageTabs: [ |
| 142 | + { |
| 143 | + highlight: "bash", |
| 144 | + language: "curl", |
| 145 | + logoClass: "bash", |
| 146 | + }, |
| 147 | + { |
| 148 | + highlight: "python", |
| 149 | + language: "python", |
| 150 | + logoClass: "python", |
| 151 | + variant: "requests", |
| 152 | + }, |
| 153 | + { |
| 154 | + highlight: "go", |
| 155 | + language: "go", |
| 156 | + logoClass: "go", |
| 157 | + }, |
| 158 | + { |
| 159 | + highlight: "javascript", |
| 160 | + language: "nodejs", |
| 161 | + logoClass: "nodejs", |
| 162 | + variant: "axios", |
| 163 | + }, |
| 164 | + { |
| 165 | + highlight: "ruby", |
| 166 | + language: "ruby", |
| 167 | + logoClass: "ruby", |
| 168 | + }, |
| 169 | + { |
| 170 | + highlight: "csharp", |
| 171 | + language: "csharp", |
| 172 | + logoClass: "csharp", |
| 173 | + variant: "httpclient", |
| 174 | + }, |
| 175 | + { |
| 176 | + highlight: "php", |
| 177 | + language: "php", |
| 178 | + logoClass: "php", |
| 179 | + }, |
| 180 | + { |
| 181 | + highlight: "java", |
| 182 | + language: "java", |
| 183 | + logoClass: "java", |
| 184 | + variant: "unirest", |
| 185 | + }, |
| 186 | + { |
| 187 | + highlight: "powershell", |
| 188 | + language: "powershell", |
| 189 | + logoClass: "powershell", |
| 190 | + }, |
| 191 | + ], |
| 192 | + algolia: { |
| 193 | + apiKey: "441074cace987cbf4640c039ebed303c", |
| 194 | + appId: "J0EABTYI1A", |
| 195 | + indexName: "docusaurus-openapi", |
| 196 | + }, |
| 197 | + announcementBar: { |
| 198 | + id: "announcementBar_1", |
| 199 | + content: |
| 200 | + "🥳 First v2.0.0 stable release! Currently only compatible with Docusaurus v2.4.1 -> v2.4.3", |
| 201 | + }, |
| 202 | + }), |
| 203 | + |
| 204 | + plugins: [ |
| 205 | + [ |
| 206 | + "docusaurus-plugin-openapi-docs", |
| 207 | + { |
| 208 | + id: "openapi", |
| 209 | + docsPluginId: "classic", |
| 210 | + config: { |
| 211 | + petstore_versioned: { |
| 212 | + specPath: "examples/petstore.yaml", |
| 213 | + outputDir: "docs/petstore_versioned", // No trailing slash |
| 214 | + sidebarOptions: { |
| 215 | + groupPathsBy: "tag", |
| 216 | + categoryLinkSource: "tag", |
| 217 | + }, |
| 218 | + version: "2.0.0", // Current version |
| 219 | + label: "v2.0.0", // Current version label |
| 220 | + baseUrl: "/petstore_versioned/swagger-petstore-yaml", // Leading slash is important |
| 221 | + versions: { |
| 222 | + "1.0.0": { |
| 223 | + specPath: "examples/petstore-1.0.0.yaml", |
| 224 | + outputDir: "docs/petstore_versioned/1.0.0", // No trailing slash |
| 225 | + label: "v1.0.0", |
| 226 | + baseUrl: "/petstore_versioned/1.0.0/swagger-petstore-yaml", // Leading slash is important |
| 227 | + }, |
| 228 | + }, |
| 229 | + }, |
| 230 | + petstore: { |
| 231 | + specPath: "examples/petstore.yaml", |
| 232 | + proxy: "https://cors.pan.dev", |
| 233 | + outputDir: "docs/petstore", |
| 234 | + sidebarOptions: { |
| 235 | + groupPathsBy: "tag", |
| 236 | + categoryLinkSource: "tag", |
| 237 | + }, |
| 238 | + template: "api.mustache", // Customize API MDX with mustache template |
| 239 | + downloadUrl: |
| 240 | + "https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml", |
| 241 | + hideSendButton: false, |
| 242 | + showSchemas: true, |
| 243 | + disableCompression: true, |
| 244 | + }, |
| 245 | + cos: { |
| 246 | + specPath: "examples/openapi-cos.json", |
| 247 | + outputDir: "docs/cos", |
| 248 | + sidebarOptions: { |
| 249 | + groupPathsBy: "tag", |
| 250 | + }, |
| 251 | + }, |
| 252 | + burgers: { |
| 253 | + specPath: "examples/food/burgers/openapi.yaml", |
| 254 | + outputDir: "docs/food/burgers", |
| 255 | + }, |
| 256 | + yogurt: { |
| 257 | + specPath: "examples/food/yogurtstore/openapi.yaml", |
| 258 | + outputDir: "docs/food/yogurtstore", |
| 259 | + }, |
| 260 | + restaurant: { |
| 261 | + specPath: "examples/food/restaurant/openapi.yaml", |
| 262 | + outputDir: "docs/restaurant", |
| 263 | + sidebarOptions: { |
| 264 | + groupPathsBy: "tagGroup", |
| 265 | + }, |
| 266 | + }, |
| 267 | + }, |
| 268 | + }, |
| 269 | + ], |
| 270 | + ], |
| 271 | + themes: ["docusaurus-theme-openapi-docs"], |
| 272 | + stylesheets: [ |
| 273 | + { |
| 274 | + href: "https://use.fontawesome.com/releases/v5.11.0/css/all.css", |
| 275 | + type: "text/css", |
| 276 | + }, |
| 277 | + ], |
| 278 | +}; |
| 279 | + |
| 280 | +async function createConfig() { |
| 281 | + const lightTheme = (await import("./src/utils/prismLight.mjs")).default; |
| 282 | + const darkTheme = (await import("./src/utils/prismDark.mjs")).default; |
| 283 | + // @ts-expect-error: we know it exists, right |
| 284 | + config.themeConfig.prism.theme = lightTheme; |
| 285 | + // @ts-expect-error: we know it exists, right |
| 286 | + config.themeConfig.prism.darkTheme = darkTheme; |
| 287 | + return config; |
| 288 | +} |
| 289 | + |
| 290 | +module.exports = createConfig; |
0 commit comments