rename to schema/openapi directory

Signed-off-by: Aramis Sennyey <159921952+aramissennyeydd@users.noreply.github.com>
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
Aramis Sennyey
2024-04-01 19:41:38 -04:00
committed by aramissennyeydd
parent 23e2366911
commit 7ab162e730
54 changed files with 46 additions and 14 deletions
+3 -3
View File
@@ -52,7 +52,7 @@ Run `yarn backstage-repo-tools package schema openapi generate --server` from th
Use it like so, update your `router.ts` or `createRouter.ts` file with the following content,
```diff
+ import { createOpenApiRouter } from '../generated';
+ import { createOpenApiRouter } from '../schema/openapi';
- import Router from 'express-promise-router';
...
@@ -67,10 +67,10 @@ export async function createRouter(
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 to add a new entry point to your plugin's common package, `plugins/<plugin-name>-common/client`. 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,
The generated client will have a directory `src/schema/openapi/generated` that exports a `DefaultApiClient` class and all generated types. You can use the client like so,
```diff
+ import { DefaultApiClient } from './generated';
+ import { DefaultApiClient } from '../schema/openapi/generated';
export class CatalogClient implements CatalogApi {
+ private readonly apiClient: DefaultApiClient;
+8 -2
View File
@@ -20,7 +20,7 @@ info:
### Generating your client
1. Run `yarn backstage-repo-tools package schema openapi generate --client-package <directory>`. This will create a new folder in `<directory>/src/generated` to house the generated content. We recommend that the client package be your plugin's common package. You should then add a new entry point into the package so that the generated content can be accessed like so, `<plugin>-common/client`. To do that, adjust your `package.json` like so,
1. Run `yarn backstage-repo-tools package schema openapi generate --client-package <directory>`. This will create a new folder in `<directory>/src/schema/openapi/generated` to house the generated content. We recommend that the client package be your plugin's common package. You should then add a new entry point into the package so that the generated content can be accessed like so, `<plugin>-common/client`. To do that, adjust your `package.json` like so,
```json
// ... other scripts
@@ -52,6 +52,12 @@ info:
// ... other stuff
```
2. You should not need to import anything from subfolders of the `src/generated` parent folder, everything you should require will be accessible from the `src/generated/index.ts` file. Of note,
and then create a new `src/client.ts` with the following content,
```ts name="src/client.ts"
export * from './schema/openapi/generated';
```
2. You should not need to import anything from subfolders of the `src/schema/openapi/generated` parent folder, everything you should require will be accessible from the `src/schema/openapi/generated/index.ts` file. Of note,
1. `DefaultApiClient` - this is the client that you can use to access your specific spec.
1. Any request or response types - these will be available from the index and should match the names in your spec.