rework generate to take flags instead of subcommands
Signed-off-by: Aramis <sennyeyaramis@gmail.com>
This commit is contained in:
@@ -45,7 +45,7 @@ You should create a new folder, `src/schema` in your backend plugin to store you
|
||||
|
||||
## Generating a typed express router from a spec
|
||||
|
||||
Run `yarn backstage-repo-tools package schema openapi generate server <plugin-directory>`. This will create an `openapi.generated.ts` file in the `src/schema` directory that contains the OpenAPI schema as well as a generated express router with types. You should add this command to your `package.json` for future use.
|
||||
Run `yarn backstage-repo-tools package schema openapi generate --server` from the directory with your plugin. This will create an `openapi.generated.ts` file in the `src/schema` directory that contains the OpenAPI schema as well as a generated express router with types. You should add this command to your `package.json` for future use and you can combine both the server generation and the client generation below like so, `yarn backstage-repo-tools package schema openapi generate --server --client-package <clientPackageDirectory>`
|
||||
|
||||
Use it like so, update your `router.ts` or `createRouter.ts` file with the following content,
|
||||
|
||||
@@ -63,7 +63,7 @@ export async function createRouter(
|
||||
|
||||
## Generating a typed client from a spec
|
||||
|
||||
From your current backend plugin directory, run `yarn backstage-repo-tools package schema openapi generate client --output-package <plugin-client-directory>`. `<plugin-client-directory>` is a new directory and npm package that you should create. The general pattern is `plugins/<plugin-name>-client` or if you want to co-locate this with your other shared types, use `plugins/<plugin-name>-common`. You should add this command to your `package.json` for future use.
|
||||
From your current backend plugin directory, run `yarn backstage-repo-tools package schema openapi generate --client-package <plugin-client-directory>`. `<plugin-client-directory>` is a new directory and npm package that you should create. The general pattern is `plugins/<plugin-name>-client` or if you want to co-locate this with your other shared types, use `plugins/<plugin-name>-common`. You should add this command to your `package.json` for future use.
|
||||
|
||||
The generated client will have a directory `src/generated` that exports a `DefaultApiClient` class and all generated types. You can use the client like so,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user