feat(oas): medusa-oas-cli as OAS build tool (#3213)
## What Introduce a CLI for extracting OAS from the core `medusa` package. ## Why We need to decouple OAS tooling from documentation tooling in order to allow packages and external systems to leverage our OAS has a dependency. ## How Introduce a new OAS workspace within packages in order to organize current and future OAS related package. Only 1 OAS package for now. Introduce a new CLI only package to act as the main gateway for all upcoming OAS tooling. Only 1 command for now. Update documentation tooling pertaining to OAS to use the CLI instead. ## Test ### Prerequisite From the monorepo root: * `yarn install` * `yarn build` ### Documentation #### Case - validation only - success * Run `yarn openapi:generate --dry-run` * Expect console output `🟢 Valid OAS` but no mention of `🔵 Exported OAS` #### Case - validation only - invalid * Introduce a bug by renaming `@schema Cart` to `@schema Kart` in [models/cart.ts](https://github.com/medusajs/medusa/blob/0adb0d9ff96087613b7a634cbc97a7e301b01121/packages/medusa/src/models/cart.ts#L2) * Run `yarn build` to update `@medusajs/medusa` package with the bug. * Run `yarn openapi:generate --dry-run` * Expect console output `🔴 Invalid OAS` with a stack trace of the issue. #### Case - docs generation * Run `yarn openapi:generate` * Expect `docs/api/` directory to contain: * `admin.oas.json` (raw OAS) * `store.oas.json` (raw OAS) * `admin.oas.yaml` (sanitized OAS) * `store.oas.yaml` (sanitized OAS) * `admin/` (updated redocly split output) * `store/` (updated redocly split output) ### CLI #### Case - crawl additional paths * From a local medusa server (`medusa-starter-default`), add an `index.ts` file in `src/models/` * In the `index.ts`, add dummy OAS JSDoc like `/** @schema Foobar */` * From the root of the monorepo, run `yarn medusa-oas --type store --paths path-to-medusa-server/src` * Expect a `store.oas.json` to be created at the root of the monorepo. * The `store.oas.json` should contain an additional `Foobar` entry in `components.schemas`.
This commit is contained in:
1 parent
1bfbe27b9b
commit
8137061908
20 files changed
+613
-82708
No files matched your search
+6
-3
@@ -4,6 +4,7 @@
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*",
|
||||
"packages/oas/*",
|
||||
"integration-tests/**/*"
|
||||
]
|
||||
},
|
||||
@@ -19,6 +20,8 @@
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@medusajs/medusa-oas-cli": "*",
|
||||
"@readme/openapi-parser": "^2.4.0",
|
||||
"@redocly/cli": "1.0.0-beta.123",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
||||
"@typescript-eslint/parser": "^5.36.2",
|
||||
@@ -33,11 +36,13 @@
|
||||
"eslint-plugin-markdown": "^3.0.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"execa": "^5.1.1",
|
||||
"express": "^4.17.1",
|
||||
"get-port": "^5.1.1",
|
||||
"husky": "^7.0.4",
|
||||
"import-from": "^3.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lint-staged": "^11.2.6",
|
||||
"microbundle": "^0.13.3",
|
||||
"pg-god": "^1.0.12",
|
||||
@@ -89,9 +94,7 @@
|
||||
"@linear/sdk": "^1.22.0",
|
||||
"@octokit/core": "^4.0.5",
|
||||
"global": "^4.4.0",
|
||||
"import-from": "^3.0.0",
|
||||
"oas-normalize": "^5.0.1",
|
||||
"swagger-inline": "^3.2.3"
|
||||
"import-from": "^3.0.0"
|
||||
},
|
||||
"packageManager": "yarn@3.2.1"
|
||||
}
|
||||
Reference in new issue
Block a user