@backstage/backend-openapi-utils 0.0.1-next.0 → 0.0.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +7 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/backend-openapi-utils
|
|
2
2
|
|
|
3
|
+
## 0.0.2-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 27956d78671: Adjusted README accordingly after the generated output now has a `.generated.ts` extension
|
|
8
|
+
|
|
9
|
+
## 0.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 62fe726fdc5: New plugin! Primary focus is to support types on `Router`s in backend packages. Developers can use the `ApiRouter` from this package in their packages to support a typed experience based on their OpenAPI specs. The `ApiRouter` supports request bodies, response bodies, query parameters and path parameters, as well as full path-based context of the above. This means no more guessing on an endpoint like `req.post('/not-my-route', (req, res)=>{res.send(req.body.badparam)})`. Typescript would catch `/not-my-route`, `req.body.badparam`, `res.send(req.body.badparam)`.
|
|
14
|
+
|
|
3
15
|
## 0.0.1-next.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,18 +8,18 @@ This package is meant to provide a typed Express router for an OpenAPI spec. Bas
|
|
|
8
8
|
|
|
9
9
|
### Configuration
|
|
10
10
|
|
|
11
|
-
1. Run `yarn --cwd <package-dir> backstage-cli package schema:openapi:generate` to translate your `src/schema/openapi.yaml` to a new Typescript file in `src/schema/openapi.ts`.
|
|
11
|
+
1. Run `yarn --cwd <package-dir> backstage-cli package schema:openapi:generate` to translate your `src/schema/openapi.yaml` to a new Typescript file in `src/schema/openapi.generated.ts`. The command will try to execute both a lint and prettier step on the generated file, where applicable.
|
|
12
12
|
|
|
13
13
|
2. In your plugin's `src/service/createRouter.ts`,
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {ApiRouter} from `@backstage/backend-openapi-utils`;
|
|
17
|
-
import spec from '../schema/openapi'
|
|
18
|
-
...
|
|
19
|
-
|
|
20
|
-
export function createRouter(){
|
|
16
|
+
import { ApiRouter } from `@backstage/backend-openapi-utils`;
|
|
17
|
+
import spec from '../schema/openapi.generated';
|
|
18
|
+
// ...
|
|
19
|
+
export function createRouter() {
|
|
21
20
|
const router = Router() as ApiRouter<typeof spec>;
|
|
22
|
-
...
|
|
21
|
+
// ...
|
|
22
|
+
return router;
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-openapi-utils",
|
|
3
3
|
"description": "OpenAPI typescript support.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2-next.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"postpack": "backstage-cli package postpack"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@backstage/cli": "^0.22.
|
|
27
|
+
"@backstage/cli": "^0.22.7-next.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|