@backstage/backend-openapi-utils 0.6.10 → 0.7.0-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,23 @@
1
1
  # @backstage/backend-openapi-utils
2
2
 
3
+ ## 0.7.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 84171b3: **BREAKING**: Removed `wrapInOpenApiTestServer`. This function redirected test traffic through the Optic `capture` proxy via the `OPTIC_PROXY` environment variable. Since the Optic dependency has been removed, this function no longer serves a purpose. Use `wrapServer` instead for OpenAPI spec validation in tests.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/backend-plugin-api@1.9.3-next.1
13
+
14
+ ## 0.6.11-next.0
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @backstage/backend-plugin-api@1.9.3-next.0
20
+
3
21
  ## 0.6.10
4
22
 
5
23
  ### Patch Changes
@@ -29,17 +29,6 @@ function registerHooks() {
29
29
  });
30
30
  }
31
31
  registerHooks();
32
- const wrapInOpenApiTestServer = (app) => {
33
- if (process.env.OPTIC_PROXY) {
34
- const server = app.listen(+process.env.PORT);
35
- return {
36
- ...server,
37
- address: () => new URL(process.env.OPTIC_PROXY)
38
- };
39
- }
40
- return app;
41
- };
42
32
 
43
- exports.wrapInOpenApiTestServer = wrapInOpenApiTestServer;
44
33
  exports.wrapServer = wrapServer;
45
34
  //# sourceMappingURL=testUtils.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.cjs.js","sources":["../src/testUtils.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Express } from 'express';\nimport { Server } from 'node:http';\nimport { Proxy } from './proxy/setup';\n\nconst proxiesToCleanup: Set<Proxy> = new Set();\n\n/**\n * !!! THIS CURRENTLY ONLY SUPPORTS SUPERTEST !!!\n * Setup a server with a custom OpenAPI proxy. This proxy will capture all requests and responses and make sure they\n * conform to the spec.\n * @param app - express server, needed to ensure we have the correct ports for the proxy.\n * @returns - a configured HTTP server that should be used with supertest.\n * @public\n */\nexport async function wrapServer(app: Express): Promise<Server> {\n const proxy = new Proxy();\n proxiesToCleanup.add(proxy);\n await proxy.setup();\n\n const server = app.listen(proxy.forwardTo.port);\n await proxy.initialize(`http://localhost:${proxy.forwardTo.port}`, server);\n\n return { ...server, address: () => new URL(proxy.url) } as any;\n}\n\nlet registered = false;\nfunction registerHooks() {\n if (typeof afterAll !== 'function' || typeof beforeAll !== 'function') {\n return;\n }\n if (registered) {\n return;\n }\n registered = true;\n\n afterAll(async () => {\n const stopPromises = Array.from(proxiesToCleanup).map(proxy =>\n proxy.stop(),\n );\n await Promise.allSettled(stopPromises);\n proxiesToCleanup.clear();\n });\n}\n\nregisterHooks();\n\n/**\n * !!! THIS CURRENTLY ONLY SUPPORTS SUPERTEST !!!\n * Running against supertest, we need some way to hit the optic proxy. This ensures that\n * that happens at runtime when in the context of a `yarn optic capture` command.\n * @param app - Express router that would be passed to supertest's `request`.\n * @returns A wrapper around the express router (or the router untouched) that still works with supertest.\n * @public\n */\nexport const wrapInOpenApiTestServer = (app: Express): Server | Express => {\n if (process.env.OPTIC_PROXY) {\n const server = app.listen(+process.env.PORT!);\n return {\n ...server,\n address: () => new URL(process.env.OPTIC_PROXY!),\n } as any;\n }\n return app;\n};\n"],"names":["Proxy"],"mappings":";;;;AAmBA,MAAM,gBAAA,uBAAmC,GAAA,EAAI;AAU7C,eAAsB,WAAW,GAAA,EAA+B;AAC9D,EAAA,MA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AY;AAAA,KACjD;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;;;;;"}
1
+ {"version":3,"file":"testUtils.cjs.js","sources":["../src/testUtils.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Express } from 'express';\nimport { Server } from 'node:http';\nimport { Proxy } from './proxy/setup';\n\nconst proxiesToCleanup: Set<Proxy> = new Set();\n\n/**\n * !!! THIS CURRENTLY ONLY SUPPORTS SUPERTEST !!!\n * Setup a server with a custom OpenAPI proxy. This proxy will capture all requests and responses and make sure they\n * conform to the spec.\n * @param app - express server, needed to ensure we have the correct ports for the proxy.\n * @returns - a configured HTTP server that should be used with supertest.\n * @public\n */\nexport async function wrapServer(app: Express): Promise<Server> {\n const proxy = new Proxy();\n proxiesToCleanup.add(proxy);\n await proxy.setup();\n\n const server = app.listen(proxy.forwardTo.port);\n await proxy.initialize(`http://localhost:${proxy.forwardTo.port}`, server);\n\n return { ...server, address: () => new URL(proxy.url) } as any;\n}\n\nlet registered = false;\nfunction registerHooks() {\n if (typeof afterAll !== 'function' || typeof beforeAll !== 'function') {\n return;\n }\n if (registered) {\n return;\n }\n registered = true;\n\n afterAll(async () => {\n const stopPromises = Array.from(proxiesToCleanup).map(proxy =>\n proxy.stop(),\n );\n await Promise.allSettled(stopPromises);\n proxiesToCleanup.clear();\n });\n}\n\nregisterHooks();\n"],"names":["Proxy"],"mappings":";;;;AAmBA,MAAM,gBAAA,uBAAmC,GAAA,EAAI;AAU7C,eAAsB,WAAW,GAAA,EAA+B;AAC9D,EAAA,MAAM,KAAA,GAAQ,IAAIA,WAAA,EAAM;AACxB,EAAA,gBAAA,CAAiB,IAAI,KAAK,CAAA;AAC1B,EAAA,MAAM,MAAM,KAAA,EAAM;AAElB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,UAAU,IAAI,CAAA;AAC9C,EAAA,MAAM,MAAM,UAAA,CAAW,CAAA,iBAAA,EAAoB,MAAM,SAAA,CAAU,IAAI,IAAI,MAAM,CAAA;AAEzE,EAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,OAAA,EAAS,MAAM,IAAI,GAAA,CAAI,KAAA,CAAM,GAAG,CAAA,EAAE;AACxD;AAEA,IAAI,UAAA,GAAa,KAAA;AACjB,SAAS,aAAA,GAAgB;AACvB,EAAA,IAAI,OAAO,QAAA,KAAa,UAAA,IAAc,OAAO,cAAc,UAAA,EAAY;AACrE,IAAA;AAAA,EACF;AACA,EAAA,IAAI,UAAA,EAAY;AACd,IAAA;AAAA,EACF;AACA,EAAA,UAAA,GAAa,IAAA;AAEb,EAAA,QAAA,CAAS,YAAY;AACnB,IAAA,MAAM,YAAA,GAAe,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA,CAAE,GAAA;AAAA,MAAI,CAAA,KAAA,KACpD,MAAM,IAAA;AAAK,KACb;AACA,IAAA,MAAM,OAAA,CAAQ,WAAW,YAAY,CAAA;AACrC,IAAA,gBAAA,CAAiB,KAAA,EAAM;AAAA,EACzB,CAAC,CAAA;AACH;AAEA,aAAA,EAAc;;;;"}
@@ -10,14 +10,5 @@ import { Server } from 'node:http';
10
10
  * @public
11
11
  */
12
12
  declare function wrapServer(app: Express): Promise<Server>;
13
- /**
14
- * !!! THIS CURRENTLY ONLY SUPPORTS SUPERTEST !!!
15
- * Running against supertest, we need some way to hit the optic proxy. This ensures that
16
- * that happens at runtime when in the context of a `yarn optic capture` command.
17
- * @param app - Express router that would be passed to supertest's `request`.
18
- * @returns A wrapper around the express router (or the router untouched) that still works with supertest.
19
- * @public
20
- */
21
- declare const wrapInOpenApiTestServer: (app: Express) => Server | Express;
22
13
 
23
- export { wrapInOpenApiTestServer, wrapServer };
14
+ export { wrapServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-openapi-utils",
3
- "version": "0.6.10",
3
+ "version": "0.7.0-next.1",
4
4
  "description": "OpenAPI typescript support.",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -54,9 +54,9 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@apidevtools/swagger-parser": "^10.1.0",
57
- "@backstage/backend-plugin-api": "^1.9.2",
58
- "@backstage/errors": "^1.3.1",
59
- "@backstage/types": "^1.2.2",
57
+ "@backstage/backend-plugin-api": "1.9.3-next.1",
58
+ "@backstage/errors": "1.3.1",
59
+ "@backstage/types": "1.2.2",
60
60
  "@types/express": "^4.17.6",
61
61
  "@types/express-serve-static-core": "^4.17.5",
62
62
  "ajv": "^8.16.0",
@@ -71,9 +71,9 @@
71
71
  "openapi3-ts": "^3.1.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@backstage/cli": "^0.36.3",
75
- "@backstage/test-utils": "^1.7.19",
76
- "msw": "^1.0.0",
74
+ "@backstage/cli": "0.36.4-next.2",
75
+ "@backstage/test-utils": "1.7.20-next.0",
76
+ "msw": "^2.0.0",
77
77
  "supertest": "^7.0.0"
78
78
  }
79
79
  }