|
| 1 | +# OpenAPI Content Page Builder |
| 2 | + |
| 3 | +The OpenAPI Content Page Builder is a module dedicated to building OpenAPI content |
| 4 | +pages on the MongoDB Documentation site out of OpenAPI spec (OAS) files. |
| 5 | + |
| 6 | +This module is intended to be called after the Snooty [parser](https://github.com/mongodb/snooty-parser) and [frontend](https://github.com/mongodb/snooty) have completed their |
| 7 | +tasks, but before [mut](https://github.com/mongodb/mut) uploads files to S3. |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +If using `nvm`, run `nvm use` to ensure you're using the intended version |
| 12 | +of Node found in `.nvmrc`. |
| 13 | + |
| 14 | +To install dependencies, run: |
| 15 | + |
| 16 | +``` |
| 17 | +npm ci |
| 18 | +``` |
| 19 | + |
| 20 | +Ensure that the proper environment variables are set up locally. `sample.env` |
| 21 | +contains environment variables that can be copied to a local `.env` file. |
| 22 | + |
| 23 | +### Building |
| 24 | + |
| 25 | +The module is compiled by `tsc` to `./dist/index.js`. Run the following to build: |
| 26 | + |
| 27 | +``` |
| 28 | +npm run build |
| 29 | +``` |
| 30 | + |
| 31 | +If developing locally, build in between runs to ensure the compiled JS file contains |
| 32 | +the latest changes. |
| 33 | + |
| 34 | +### Running |
| 35 | + |
| 36 | +Make sure the module has been built/compiled with an existing `./dist/index.js` file. |
| 37 | +Run the following to run the module: |
| 38 | + |
| 39 | +``` |
| 40 | +npm run start -- --bundle <path> --output <path> --redoc <path> --repo <path> |
| 41 | +``` |
| 42 | + |
| 43 | +All of the options above are required for the module to run properly. Run |
| 44 | +`npm run start -- --help` for more information or see [(Required) Options](#required-options). |
| 45 | + |
| 46 | +**Example** |
| 47 | + |
| 48 | +The following example shows what the command would be like if ran through the |
| 49 | +autobuilder. If running locally, update the paths according to your local setup. |
| 50 | + |
| 51 | +``` |
| 52 | +npm run start -- --bundle /home/docsworker-xlarge/repos/cloud-docs/bundle.zip --output /home/docsworker-xlarge/repos/cloud-docs/public/ --redoc /home/docsworker-xlarge/redoc/cli/index.js --repo /home/docsworker-xlarge/repos/cloud-docs/ |
| 53 | +``` |
| 54 | + |
| 55 | +### (Required) Options |
| 56 | + |
| 57 | +| Option | Description | |
| 58 | +| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 59 | +| bundle | Path to the parsed bundle zip file. This should be the output of the parser and will be used to obtain build metadata about OpenAPI content pages. | |
| 60 | +| output | Path to the directory that the OpenAPI content pages should be built to. Typically, this would be the same output `public/` directory of a Snooty frontend build. | |
| 61 | +| redoc | Path to the local installation of Redoc CLI to use. This should point to the team's [fork of Redoc](https://github.com/mongodb-forks/redoc), with the target being a compiled JS file. | |
| 62 | +| repo | Path to the parsed docs repo's directory. This is to ensure that OpenAPI content pages using local OAS files can be properly sourced and passed down as an argument to Redoc CLI. | |
0 commit comments