Skip to content

Commit

Permalink
feat: Add @hey-api/openapi-ts to generate API client and types MAASEN…
Browse files Browse the repository at this point in the history
…G-3449 (#5575)

- Added `@hey-api/openapi-ts` to generate API client and types from MAAS spec
- Generated an API client for the current v3 API
- Created a config for the generator

Resolves [MAASENG-3449](https://warthogs.atlassian.net/browse/MAASENG-3449)
  • Loading branch information
ndv99 authored Jan 13, 2025
1 parent d25a45b commit cccbd73
Show file tree
Hide file tree
Showing 6 changed files with 4,694 additions and 8 deletions.
12 changes: 12 additions & 0 deletions openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
client: "@hey-api/client-fetch",
input: "http://maas-ui-demo.internal:5240/MAAS/a/openapi.json",
output: {
path: "src/app/apiclient",
format: "prettier",
lint: "eslint",
},
experimentalParser: true,
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"cypress-run-a11y": "yarn cypress run --config specPattern=cypress/e2e/accessibility/**/*.ts",
"cypress-run-docs": "yarn cypress run --config specPattern=cypress/e2e/docs-links/**/*.ts ",
"cypress-run": "yarn cypress run",
"generate-api-client": "openapi-ts",
"lint": "npmPkgJsonLint . && eslint src cypress && tsc --project tsconfig.json --noEmit && tsc --project cypress/tsconfig.json --noEmit",
"link-components": "yarn link \"@canonical/react-components\" && yarn link \"react\" && yarn install",
"percy": "./cypress/percy.sh",
Expand All @@ -46,6 +47,7 @@
"@canonical/maas-react-components": "1.28.0",
"@canonical/macaroon-bakery": "1.3.2",
"@canonical/react-components": "0.55.0",
"@hey-api/client-fetch": "0.6.0",
"@redux-devtools/extension": "3.3.0",
"@reduxjs/toolkit": "1.9.7",
"@sentry/browser": "5.30.0",
Expand Down Expand Up @@ -89,6 +91,7 @@
},
"devDependencies": {
"@canonical/typescript-config-react": "0.4.0-experimental.0",
"@hey-api/openapi-ts": "0.61.2",
"@percy/cli": "1.28.8",
"@percy/cypress": "3.1.2",
"@playwright/test": "1.45.0",
Expand Down
3 changes: 3 additions & 0 deletions src/app/apiclient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file is auto-generated by @hey-api/openapi-ts
export * from "./types.gen";
export * from "./sdk.gen";
Loading

0 comments on commit cccbd73

Please sign in to comment.