diff --git a/.eslintrc.js b/.eslintrc.js index d5022179..4981f126 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,7 @@ const tsExtensions = [".ts", ".tsx", ".d.ts"]; const allExtensions = [...tsExtensions, ".js", ".jsx"]; module.exports = { - ignorePatterns: ["demo/**"], + ignorePatterns: ["demo/**", "packages/docusaurus-template-*/**"], root: true, extends: [ "react-app", diff --git a/README.md b/README.md index 73f90c4b..c52008a7 100644 --- a/README.md +++ b/README.md @@ -22,125 +22,119 @@ OpenAPI plugin for generating API reference docs in Docusaurus v2.
-> ### π₯ [Breaking Changes](https://github.com/cloud-annotations/docusaurus-plugin-openapi/releases/tag/v0.2.0): v0.1.0 -> v0.2.0 +## Quick Overview -## Preset usage +```sh +npx create-docusaurus-openapi my-website +cd my-website +npm start +``` -Install the preset in your docusaurus project by running: +> Coming from `v0.1.0`? See the [migration guide](https://github.com/cloud-annotations/docusaurus-plugin-openapi/releases/tag/v0.2.0). -```sh -// with npm -npm install docusaurus-preset-openapi +_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher)_ + +Then open [http://localhost:3000/](http://localhost:3000/) to see your site.+ + + +
+ +## Multiple OpenAPI Definitions + +To have more than one OpenAPI pages, add additional OpenAPI plugin instances: + +```js +/* docusaurus.config.js */ + +{ + presets: [ + [ + 'docusaurus-preset-openapi', + { + api: { + // id: 'cars', // omitted => default instance + path: 'cars/openapi.json', + routeBasePath: 'cars', + // ... other options + }, + }, + ], + ], + plugins: [ + [ + 'docusaurus-plugin-openapi', + { + id: 'trains', + path: 'trains/openapi.json', + routeBasePath: 'trains', + // ... other options + }, + ], + [ + 'docusaurus-plugin-openapi', + { + id: 'bikes', + path: 'bikes/openapi.json', + routeBasePath: 'bikes', + // ... other options + }, + ], + ], +} +``` + +This will create routes for `/cars`, `/trains` and `/bikes`. + +> **Note:** One instance of the plugin is included in the preset. All additional plugin instances will require an `id`. diff --git a/packages/docusaurus-template-openapi/README.md b/packages/docusaurus-template-openapi/README.md new file mode 100644 index 00000000..b439ec88 --- /dev/null +++ b/packages/docusaurus-template-openapi/README.md @@ -0,0 +1 @@ +# docusaurus-template-openapi diff --git a/packages/docusaurus-template-openapi/package.json b/packages/docusaurus-template-openapi/package.json new file mode 100644 index 00000000..8929cb62 --- /dev/null +++ b/packages/docusaurus-template-openapi/package.json @@ -0,0 +1,27 @@ +{ + "name": "docusaurus-template-openapi", + "version": "0.4.0", + "keywords": [ + "react", + "create-docusaurus", + "template", + "openapi" + ], + "description": "OpenAPI template for Docusaurus.", + "repository": { + "type": "git", + "url": "https://github.com/cloud-annotations/docusaurus-openapi.git", + "directory": "packages/docusaurus-template-openapi" + }, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "bugs": { + "url": "https://github.com/cloud-annotations/docusaurus-openapi/issues" + }, + "files": [ + "template", + "template.json" + ] +} diff --git a/packages/docusaurus-template-openapi/template.json b/packages/docusaurus-template-openapi/template.json new file mode 100644 index 00000000..5f4fc496 --- /dev/null +++ b/packages/docusaurus-template-openapi/template.json @@ -0,0 +1,35 @@ +{ + "package": { + "name": "demo", + "version": "0.4.0", + "private": true, + "scripts": { + "docusaurus": "docusaurus", + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "clear": "docusaurus clear", + "serve": "docusaurus serve", + "write-translations": "docusaurus write-translations", + "write-heading-ids": "docusaurus write-heading-ids" + }, + "dependencies": { + "@docusaurus/core": "2.0.0-beta.14", + "docusaurus-preset-openapi": "0.4.0", + "@mdx-js/react": "^1.6.21", + "clsx": "^1.1.1", + "prism-react-renderer": "^1.2.1", + "react": "^17.0.1", + "react-dom": "^17.0.1" + }, + "browserslist": { + "production": [">0.5%", "not dead", "not op_mini all"], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } + } +} diff --git a/packages/docusaurus-template-openapi/template/README.md b/packages/docusaurus-template-openapi/template/README.md new file mode 100644 index 00000000..aaba2fa1 --- /dev/null +++ b/packages/docusaurus-template-openapi/template/README.md @@ -0,0 +1,41 @@ +# Website + +This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. + +### Installation + +``` +$ yarn +``` + +### Local Development + +``` +$ yarn start +``` + +This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. + +### Build + +``` +$ yarn build +``` + +This command generates static content into the `build` directory and can be served using any static contents hosting service. + +### Deployment + +Using SSH: + +``` +$ USE_SSH=true yarn deploy +``` + +Not using SSH: + +``` +$ GIT_USER=This is a React page
+docs directory.
+ >
+ ),
+ },
+ {
+ title: "Powered by React",
+ Svg: require("../../static/img/undraw_docusaurus_react.svg").default,
+ description: (
+ <>
+ 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 }) {
+ return (
+ {description}
+{siteConfig.tagline}
+