@backstage/backend-openapi-utils 0.0.1 → 0.0.2-next.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/backend-openapi-utils
2
2
 
3
+ ## 0.0.2-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fe16bd39e83: Use permalinks for links including a line number reference
8
+ - 021cfbb5152: Corrected resolution of parameter nested schema to use central schemas.
9
+
10
+ ## 0.0.2-next.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 27956d78671: Adjusted README accordingly after the generated output now has a `.generated.ts` extension
15
+
3
16
  ## 0.0.1
4
17
 
5
18
  ### 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`. In the case of projects that require linting + a license header, you will need to do this manually.
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
 
@@ -42,4 +42,4 @@ Router() as ApiRouter<DeepWriteable<typeof spec>>
42
42
 
43
43
  ### Runtime validation
44
44
 
45
- Using a package like [`express-openapi-validator`](https://www.npmjs.com/package/express-openapi-validator), would allow us to remove [validation of request bodies with `AJV`](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend/src/service/util.ts#L58). However, `AJV` currently doesn't have support for OpenAPI 3.1 and `express-openapi-validator` enforces full URL matching for paths, meaning it cannot be mounted at the router level.
45
+ Using a package like [`express-openapi-validator`](https://www.npmjs.com/package/express-openapi-validator), would allow us to remove [validation of request bodies with `AJV`](https://github.com/backstage/backstage/blob/e0506af8fc54074a160fb91c83d6cae8172d3bb3/plugins/catalog-backend/src/service/util.ts#L58). However, `AJV` currently doesn't have support for OpenAPI 3.1 and `express-openapi-validator` enforces full URL matching for paths, meaning it cannot be mounted at the router level.
package/dist/index.d.ts CHANGED
@@ -287,11 +287,7 @@ type DocParameters<Doc extends RequiredDoc, Path extends Extract<keyof Doc['path
287
287
  /**
288
288
  * @public
289
289
  */
290
- type ResolveDocParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = Schema extends ImmutableReferenceObject ? 'parameters' extends ComponentTypes<Doc> ? ComponentRef<Doc, 'parameters', Schema> : never : Schema;
291
- /**
292
- * @public
293
- */
294
- type ParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = ResolveDocParameterSchema<Doc, Schema> extends infer R ? R extends ImmutableSchemaObject ? R extends JSONSchema7 ? FromSchema<R> : never : never : never;
290
+ type ParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = SchemaRef<Doc, Schema> extends infer R ? R extends ImmutableSchemaObject ? R extends JSONSchema7 ? FromSchema<R> : never : never : never;
295
291
  /**
296
292
  * @public
297
293
  */
@@ -438,7 +434,6 @@ type index_d_ImmutablePathObject = ImmutablePathObject;
438
434
  type index_d_ImmutableSchemaObject = ImmutableSchemaObject;
439
435
  type index_d_DocParameter<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path], Parameter extends keyof Doc['paths'][Path][Method]['parameters']> = DocParameter<Doc, Path, Method, Parameter>;
440
436
  type index_d_DocParameters<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path]> = DocParameters<Doc, Path, Method>;
441
- type index_d_ResolveDocParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = ResolveDocParameterSchema<Doc, Schema>;
442
437
  type index_d_ParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = ParameterSchema<Doc, Schema>;
443
438
  type index_d_MapToSchema<Doc extends RequiredDoc, T extends Record<string, ImmutableParameterObject>> = MapToSchema<Doc, T>;
444
439
  type index_d_ParametersSchema<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path], FilterType extends ImmutableParameterObject> = ParametersSchema<Doc, Path, Method, FilterType>;
@@ -504,7 +499,6 @@ declare namespace index_d {
504
499
  index_d_ImmutableSchemaObject as ImmutableSchemaObject,
505
500
  index_d_DocParameter as DocParameter,
506
501
  index_d_DocParameters as DocParameters,
507
- index_d_ResolveDocParameterSchema as ResolveDocParameterSchema,
508
502
  index_d_ParameterSchema as ParameterSchema,
509
503
  index_d_MapToSchema as MapToSchema,
510
504
  index_d_ParametersSchema as ParametersSchema,
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.1",
4
+ "version": "0.0.2-next.1",
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.6"
27
+ "@backstage/cli": "^0.22.7-next.0"
28
28
  },
29
29
  "files": [
30
30
  "dist"