diff --git a/.changeset/thirty-dancers-cheat.md b/.changeset/thirty-dancers-cheat.md new file mode 100644 index 0000000000..083b3febbb --- /dev/null +++ b/.changeset/thirty-dancers-cheat.md @@ -0,0 +1,17 @@ +--- +'@backstage/backend-openapi-utils': minor +--- + +**BREAKING**: The `wrapInOpenApiTestServer` and `wrapServer` functions are now exported via `/testUtils` subpath. If you were importing these functions directly from the root of the package, you will need to update your imports to use the `/testUtils` subpath: + +```diff +- import { wrapInOpenApiTestServer } from '@backstage/backend-openapi-utils'; ++ import { wrapInOpenApiTestServer } from '@backstage/backend-openapi-utils/testUtils'; +``` + +or + +```diff +- import { wrapServer } from '@backstage/backend-openapi-utils'; ++ import { wrapServer } from '@backstage/backend-openapi-utils/testUtils'; +``` diff --git a/docs/openapi/01-getting-started.md b/docs/openapi/01-getting-started.md index ce14cf6a7f..875a369dbf 100644 --- a/docs/openapi/01-getting-started.md +++ b/docs/openapi/01-getting-started.md @@ -97,7 +97,7 @@ For more information, see [the docs](./generate-client.md). Add the following lines to your `createRouter.test.ts` or `router.test.ts` file, ```diff -+ import { wrapInOpenApiTestServer } from '@backstage/backend-openapi-utils'; ++ import { wrapInOpenApiTestServer } from '@backstage/backend-openapi-utils/testUtils'; + import { Server } from 'http'; ... diff --git a/packages/backend-openapi-utils/package.json b/packages/backend-openapi-utils/package.json index 4453d4338a..eff12e46f6 100644 --- a/packages/backend-openapi-utils/package.json +++ b/packages/backend-openapi-utils/package.json @@ -6,10 +6,7 @@ "role": "node-library" }, "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" }, "homepage": "https://backstage.io", "repository": { @@ -18,8 +15,23 @@ "directory": "packages/backend-openapi-utils" }, "license": "Apache-2.0", + "exports": { + ".": "./src/index.ts", + "./testUtils": "./src/testUtils.ts", + "./package.json": "./package.json" + }, "main": "src/index.ts", "types": "src/index.ts", + "typesVersions": { + "*": { + "testUtils": [ + "src/testUtils.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "files": [ "dist" ], diff --git a/packages/backend-openapi-utils/report-testUtils.api.md b/packages/backend-openapi-utils/report-testUtils.api.md new file mode 100644 index 0000000000..471ff5a3c1 --- /dev/null +++ b/packages/backend-openapi-utils/report-testUtils.api.md @@ -0,0 +1,18 @@ +## API Report File for "@backstage/backend-openapi-utils" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +/// + +import { Express as Express_2 } from 'express'; +import { Server } from 'http'; + +// @public +export const wrapInOpenApiTestServer: (app: Express_2) => Server | Express_2; + +// @public +export function wrapServer(app: Express_2): Promise; + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/backend-openapi-utils/report.api.md b/packages/backend-openapi-utils/report.api.md index 22913eb321..9d8b8e975e 100644 --- a/packages/backend-openapi-utils/report.api.md +++ b/packages/backend-openapi-utils/report.api.md @@ -3,11 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -/// - import type { ContentObject } from 'openapi3-ts'; import type core from 'express-serve-static-core'; -import { Express as Express_2 } from 'express'; import { FromSchema } from 'json-schema-to-ts'; import { JSONSchema } from 'json-schema-to-ts'; import { middleware } from 'express-openapi-validator'; @@ -19,7 +16,6 @@ import { RequestHandler } from 'express'; import type { ResponseObject } from 'openapi3-ts'; import { Router } from 'express'; import type { SchemaObject } from 'openapi3-ts'; -import { Server } from 'http'; // @public export interface ApiRouter extends Router { @@ -925,10 +921,4 @@ type UnknownIfNever

= [P] extends [never] ? unknown : P; // @public type ValueOf = T[keyof T]; - -// @public -export const wrapInOpenApiTestServer: (app: Express_2) => Server | Express_2; - -// @public -export function wrapServer(app: Express_2): Promise; ``` diff --git a/packages/backend-openapi-utils/src/index.ts b/packages/backend-openapi-utils/src/index.ts index 9389fe3be6..849cc72daf 100644 --- a/packages/backend-openapi-utils/src/index.ts +++ b/packages/backend-openapi-utils/src/index.ts @@ -32,7 +32,6 @@ export type { } from './utility'; export type { ApiRouter, TypedRouter } from './router'; export type { PathTemplate } from './types/common'; -export { wrapInOpenApiTestServer, wrapServer } from './testUtils'; export { createValidatedOpenApiRouter, getOpenApiSpecRoute, diff --git a/plugins/catalog-backend/src/service/createRouter.test.ts b/plugins/catalog-backend/src/service/createRouter.test.ts index 16970ce7a6..b0dddbdef0 100644 --- a/plugins/catalog-backend/src/service/createRouter.test.ts +++ b/plugins/catalog-backend/src/service/createRouter.test.ts @@ -15,7 +15,7 @@ */ import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter'; -import { wrapServer } from '@backstage/backend-openapi-utils'; +import { wrapServer } from '@backstage/backend-openapi-utils/testUtils'; import { mockCredentials, mockServices } from '@backstage/backend-test-utils'; import type { Location } from '@backstage/catalog-client'; import { diff --git a/plugins/search-backend/src/service/router.test.ts b/plugins/search-backend/src/service/router.test.ts index 5b6900ede1..c348302045 100644 --- a/plugins/search-backend/src/service/router.test.ts +++ b/plugins/search-backend/src/service/router.test.ts @@ -23,7 +23,7 @@ import { import express from 'express'; import request from 'supertest'; import { createRouter } from './router'; -import { wrapServer } from '@backstage/backend-openapi-utils'; +import { wrapServer } from '@backstage/backend-openapi-utils/testUtils'; import { Server } from 'http'; import { mockCredentials,