@backstage/backend-openapi-utils 0.7.3-next.1 → 0.7.3

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,20 @@
1
1
  # @backstage/backend-openapi-utils
2
2
 
3
+ ## 0.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 812225c: Fixed the OpenAPI validation test server wrapper to support `supertest` 7.3 by returning a standard server address for the validation proxy.
8
+ - Updated dependencies
9
+ - @backstage/backend-plugin-api@1.11.0
10
+ - @backstage/errors@1.3.2
11
+
12
+ ## 0.7.3-next.2
13
+
14
+ ### Patch Changes
15
+
16
+ - 812225c: Fixed the OpenAPI validation test server wrapper to support `supertest` 7.3 by returning a standard server address for the validation proxy.
17
+
3
18
  ## 0.7.3-next.1
4
19
 
5
20
  ### Patch Changes
@@ -9,7 +9,18 @@ async function wrapServer(app) {
9
9
  await proxy.setup();
10
10
  const server = app.listen(proxy.forwardTo.port);
11
11
  await proxy.initialize(`http://localhost:${proxy.forwardTo.port}`, server);
12
- return { ...server, address: () => new URL(proxy.url) };
12
+ return {
13
+ ...server,
14
+ address: () => {
15
+ const url = new URL(proxy.url);
16
+ const address = url.hostname.replace(/^\[(.*)\]$/, "$1");
17
+ return {
18
+ address,
19
+ family: address.includes(":") ? "IPv6" : "IPv4",
20
+ port: Number(url.port)
21
+ };
22
+ }
23
+ };
13
24
  }
14
25
  let registered = false;
15
26
  function registerHooks() {
@@ -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"],"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;;"}
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 whose address points to the validation proxy, for use 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 {\n ...server,\n address: () => {\n const url = new URL(proxy.url);\n const address = url.hostname.replace(/^\\[(.*)\\]$/, '$1');\n return {\n address,\n family: address.includes(':') ? 'IPv6' : 'IPv4',\n port: Number(url.port),\n };\n },\n } 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;AAAA,IACL,GAAG,MAAA;AAAA,IACH,SAAS,MAAM;AACb,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,KAAA,CAAM,GAAG,CAAA;AAC7B,MAAA,MAAM,OAAA,GAAU,GAAA,CAAI,QAAA,CAAS,OAAA,CAAQ,cAAc,IAAI,CAAA;AACvD,MAAA,OAAO;AAAA,QACL,OAAA;AAAA,QACA,MAAA,EAAQ,OAAA,CAAQ,QAAA,CAAS,GAAG,IAAI,MAAA,GAAS,MAAA;AAAA,QACzC,IAAA,EAAM,MAAA,CAAO,GAAA,CAAI,IAAI;AAAA,OACvB;AAAA,IACF;AAAA,GACF;AACF;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;;"}
@@ -6,7 +6,7 @@ import { Server } from 'node:http';
6
6
  * Setup a server with a custom OpenAPI proxy. This proxy will capture all requests and responses and make sure they
7
7
  * conform to the spec.
8
8
  * @param app - express server, needed to ensure we have the correct ports for the proxy.
9
- * @returns - a configured HTTP server that should be used with supertest.
9
+ * @returns - a configured HTTP server whose address points to the validation proxy, for use with supertest.
10
10
  * @public
11
11
  */
12
12
  declare function wrapServer(app: Express): Promise<Server>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-openapi-utils",
3
- "version": "0.7.3-next.1",
3
+ "version": "0.7.3",
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.11.0-next.1",
58
- "@backstage/errors": "1.3.2-next.0",
59
- "@backstage/types": "1.2.2",
57
+ "@backstage/backend-plugin-api": "^1.11.0",
58
+ "@backstage/errors": "^1.3.2",
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",
@@ -72,8 +72,8 @@
72
72
  "openapi3-ts": "^3.1.2"
73
73
  },
74
74
  "devDependencies": {
75
- "@backstage/cli": "0.36.7-next.0",
76
- "@backstage/test-utils": "1.7.23-next.0",
75
+ "@backstage/cli": "^0.36.7",
76
+ "@backstage/test-utils": "^1.7.23",
77
77
  "msw": "^2.0.0",
78
78
  "supertest": "^7.0.0"
79
79
  }