Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: switch to upstream openapi #195

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://github.com/Unleash/unleash-proxy#readme",
"dependencies": {
"@unleash/express-openapi": "^0.3.0",
"@wesleytodd/openapi": "^1.1.0",
"compression": "^1.7.4",
"cors": "^2.8.5",
"express": "^4.21.0",
Expand Down
1 change: 0 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export function createApp(
const corsOptions = config.cors;
app.use(cors(corsOptions));

// @ts-expect-error Express struggles with its types here, compression seems to be too old
app.use(compression());

app.use(
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference path="./types/openapi.d.ts" />

import { createApp } from './app';
import Client from './client';
import { createProxyConfig } from './config';
Expand Down
4 changes: 2 additions & 2 deletions src/openapi/openapi-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import openapi, { type IExpressOpenApi } from '@unleash/express-openapi';
import openapi, { type IExpressOpenApi } from '@wesleytodd/openapi';
import type { Application, RequestHandler } from 'express';
import type { OpenAPIV3 } from 'openapi-types';
import { createOpenApiSchema } from '.';
Expand Down Expand Up @@ -30,7 +30,7 @@ export class OpenApiService {
// and the OpenAPI SwaggerUI at `${this.docsPathPath}`.
useDocs(app: Application): void {
app.use(this.api);
app.use(this.docsPath(), this.api.swaggerui);
app.use(this.docsPath(), this.api.swaggerui());
}

// Create request validation middleware
Expand Down
4 changes: 1 addition & 3 deletions src/test/content-type-checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const mockRequest =

// @ts-expect-error (It's not a real request)
return {
header: (name: string) =>
//@ts-expect-error (yes, this may fail)
headers[name.toLowerCase()],
header: (name: string) => headers[name.toLowerCase()],
headers,
};
};
Expand Down
16 changes: 0 additions & 16 deletions src/types/openapi.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "strict": true, /* Enable all strict type-checking options. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to switch this config off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main reason was the lack of types for the lib. But I adjusted the type definitions we already had

// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
Expand Down
162 changes: 86 additions & 76 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1751,22 +1751,6 @@ __metadata:
languageName: node
linkType: hard

"@unleash/express-openapi@npm:^0.3.0":
version: 0.3.0
resolution: "@unleash/express-openapi@npm:0.3.0"
dependencies:
ajv: "npm:^6.10.2"
http-errors: "npm:^1.7.3"
merge-deep: "npm:^3.0.2"
path-to-regexp: "npm:^2.4.0"
router: "npm:^1.3.3"
serve-static: "npm:^1.13.2"
swagger-parser: "npm:^10.0.3"
swagger-ui-dist: "npm:^4.10.3"
checksum: 10c0/54000d35bab88fda64f06abce96b7da4f836706295d8c56289da1c30ff5dc8f288b58f2e7f88ce4004344119829763e2766ea249099ec2b95a30c4481ee45783
languageName: node
linkType: hard

"@unleash/proxy@workspace:.":
version: 0.0.0-use.local
resolution: "@unleash/proxy@workspace:."
Expand All @@ -1781,7 +1765,7 @@ __metadata:
"@types/node": "npm:20.14.8"
"@types/supertest": "npm:^6.0.2"
"@types/type-is": "npm:^1.6.6"
"@unleash/express-openapi": "npm:^0.3.0"
"@wesleytodd/openapi": "npm:^1.1.0"
babel-jest: "npm:^29.7.0"
compression: "npm:^1.7.4"
cors: "npm:^2.8.5"
Expand All @@ -1801,6 +1785,25 @@ __metadata:
languageName: unknown
linkType: soft

"@wesleytodd/openapi@npm:^1.1.0":
version: 1.1.0
resolution: "@wesleytodd/openapi@npm:1.1.0"
dependencies:
ajv: "npm:^8.12.0"
ajv-formats: "npm:^2.1.1"
ajv-keywords: "npm:^5.1.0"
http-errors: "npm:^2.0.0"
merge-deep: "npm:^3.0.3"
path-to-regexp: "npm:^6.2.1"
router: "npm:^1.3.8"
serve-static: "npm:^1.15.0"
swagger-parser: "npm:^10.0.3"
swagger-ui-dist: "npm:^5.11.8"
yaml: "npm:^2.4.0"
checksum: 10c0/3fd07e02c6ef98c9029e8ac8cf6e602eab1a162c9bccd4af6ca2858b26ae0c9eba5bf37b1c88912c831fdbbf38674cfeff59765db6b0c050411eea5efac7a574
languageName: node
linkType: hard

"abbrev@npm:^2.0.0":
version: 2.0.0
resolution: "abbrev@npm:2.0.0"
Expand Down Expand Up @@ -1867,15 +1870,40 @@ __metadata:
languageName: node
linkType: hard

"ajv@npm:^6.10.2":
version: 6.12.6
resolution: "ajv@npm:6.12.6"
"ajv-formats@npm:^2.1.1":
version: 2.1.1
resolution: "ajv-formats@npm:2.1.1"
dependencies:
fast-deep-equal: "npm:^3.1.1"
fast-json-stable-stringify: "npm:^2.0.0"
json-schema-traverse: "npm:^0.4.1"
uri-js: "npm:^4.2.2"
checksum: 10c0/41e23642cbe545889245b9d2a45854ebba51cda6c778ebced9649420d9205f2efb39cb43dbc41e358409223b1ea43303ae4839db682c848b891e4811da1a5a71
ajv: "npm:^8.0.0"
peerDependencies:
ajv: ^8.0.0
peerDependenciesMeta:
ajv:
optional: true
checksum: 10c0/e43ba22e91b6a48d96224b83d260d3a3a561b42d391f8d3c6d2c1559f9aa5b253bfb306bc94bbeca1d967c014e15a6efe9a207309e95b3eaae07fcbcdc2af662
languageName: node
linkType: hard

"ajv-keywords@npm:^5.1.0":
version: 5.1.0
resolution: "ajv-keywords@npm:5.1.0"
dependencies:
fast-deep-equal: "npm:^3.1.3"
peerDependencies:
ajv: ^8.8.2
checksum: 10c0/18bec51f0171b83123ba1d8883c126e60c6f420cef885250898bf77a8d3e65e3bfb9e8564f497e30bdbe762a83e0d144a36931328616a973ee669dc74d4a9590
languageName: node
linkType: hard

"ajv@npm:^8.0.0, ajv@npm:^8.12.0":
version: 8.17.1
resolution: "ajv@npm:8.17.1"
dependencies:
fast-deep-equal: "npm:^3.1.3"
fast-uri: "npm:^3.0.1"
json-schema-traverse: "npm:^1.0.0"
require-from-string: "npm:^2.0.2"
checksum: 10c0/ec3ba10a573c6b60f94639ffc53526275917a2df6810e4ab5a6b959d87459f9ef3f00d5e7865b82677cb7d21590355b34da14d1d0b9c32d75f95a187e76fff35
languageName: node
linkType: hard

Expand Down Expand Up @@ -2691,13 +2719,6 @@ __metadata:
languageName: node
linkType: hard

"depd@npm:~1.1.2":
version: 1.1.2
resolution: "depd@npm:1.1.2"
checksum: 10c0/acb24aaf936ef9a227b6be6d495f0d2eb20108a9a6ad40585c5bda1a897031512fef6484e4fdbb80bd249fdaa82841fa1039f416ece03188e677ba11bcfda249
languageName: node
linkType: hard

"destroy@npm:1.2.0":
version: 1.2.0
resolution: "destroy@npm:1.2.0"
Expand Down Expand Up @@ -2979,14 +3000,14 @@ __metadata:
languageName: node
linkType: hard

"fast-deep-equal@npm:^3.1.1":
"fast-deep-equal@npm:^3.1.1, fast-deep-equal@npm:^3.1.3":
version: 3.1.3
resolution: "fast-deep-equal@npm:3.1.3"
checksum: 10c0/40dedc862eb8992c54579c66d914635afbec43350afbbe991235fdcb4e3a8d5af1b23ae7e79bef7d4882d0ecee06c3197488026998fb19f72dc95acff1d1b1d0
languageName: node
linkType: hard

"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0":
"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.1.0":
version: 2.1.0
resolution: "fast-json-stable-stringify@npm:2.1.0"
checksum: 10c0/7f081eb0b8a64e0057b3bb03f974b3ef00135fbf36c1c710895cd9300f13c94ba809bb3a81cf4e1b03f6e5285610a61abbd7602d0652de423144dfee5a389c9b
Expand All @@ -3000,6 +3021,13 @@ __metadata:
languageName: node
linkType: hard

"fast-uri@npm:^3.0.1":
version: 3.0.1
resolution: "fast-uri@npm:3.0.1"
checksum: 10c0/3cd46d6006083b14ca61ffe9a05b8eef75ef87e9574b6f68f2e17ecf4daa7aaadeff44e3f0f7a0ef4e0f7e7c20fc07beec49ff14dc72d0b500f00386592f2d10
languageName: node
linkType: hard

"fb-watchman@npm:^2.0.0":
version: 2.0.1
resolution: "fb-watchman@npm:2.0.1"
Expand Down Expand Up @@ -3337,7 +3365,7 @@ __metadata:
languageName: node
linkType: hard

"http-errors@npm:2.0.0":
"http-errors@npm:2.0.0, http-errors@npm:^2.0.0":
version: 2.0.0
resolution: "http-errors@npm:2.0.0"
dependencies:
Expand All @@ -3350,19 +3378,6 @@ __metadata:
languageName: node
linkType: hard

"http-errors@npm:^1.7.3":
version: 1.8.1
resolution: "http-errors@npm:1.8.1"
dependencies:
depd: "npm:~1.1.2"
inherits: "npm:2.0.4"
setprototypeof: "npm:1.2.0"
statuses: "npm:>= 1.5.0 < 2"
toidentifier: "npm:1.0.1"
checksum: 10c0/f01aeecd76260a6fe7f08e192fcbe9b2f39ed20fc717b852669a69930167053b01790998275c6297d44f435cf0e30edd50c05223d1bec9bc484e6cf35b2d6f43
languageName: node
linkType: hard

"http-proxy-agent@npm:^7.0.0, http-proxy-agent@npm:^7.0.2":
version: 7.0.2
resolution: "http-proxy-agent@npm:7.0.2"
Expand Down Expand Up @@ -4195,13 +4210,6 @@ __metadata:
languageName: node
linkType: hard

"json-schema-traverse@npm:^0.4.1":
version: 0.4.1
resolution: "json-schema-traverse@npm:0.4.1"
checksum: 10c0/108fa90d4cc6f08243aedc6da16c408daf81793bf903e9fd5ab21983cda433d5d2da49e40711da016289465ec2e62e0324dcdfbc06275a607fe3233fde4942ce
languageName: node
linkType: hard

"json-schema-traverse@npm:^1.0.0":
version: 1.0.0
resolution: "json-schema-traverse@npm:1.0.0"
Expand Down Expand Up @@ -4385,7 +4393,7 @@ __metadata:
languageName: node
linkType: hard

"merge-deep@npm:^3.0.2":
"merge-deep@npm:^3.0.3":
version: 3.0.3
resolution: "merge-deep@npm:3.0.3"
dependencies:
Expand Down Expand Up @@ -4924,10 +4932,10 @@ __metadata:
languageName: node
linkType: hard

"path-to-regexp@npm:^2.4.0":
version: 2.4.0
resolution: "path-to-regexp@npm:2.4.0"
checksum: 10c0/286e3f2ea633ae9447d9c6beb2974db67801ffd64927e70129604e1fb987d94c9b38fa70cc494cd088c78d521914edec87de7f11928848c9ac265632c8644fc8
"path-to-regexp@npm:^6.2.1":
version: 6.3.0
resolution: "path-to-regexp@npm:6.3.0"
checksum: 10c0/73b67f4638b41cde56254e6354e46ae3a2ebc08279583f6af3d96fe4664fc75788f74ed0d18ca44fa4a98491b69434f9eee73b97bb5314bd1b5adb700f5c18d6
languageName: node
linkType: hard

Expand Down Expand Up @@ -5172,9 +5180,9 @@ __metadata:
languageName: node
linkType: hard

"router@npm:^1.3.3":
version: 1.3.7
resolution: "router@npm:1.3.7"
"router@npm:^1.3.8":
version: 1.3.8
resolution: "router@npm:1.3.8"
dependencies:
array-flatten: "npm:3.0.0"
debug: "npm:2.6.9"
Expand All @@ -5183,7 +5191,7 @@ __metadata:
path-to-regexp: "npm:0.1.7"
setprototypeof: "npm:1.2.0"
utils-merge: "npm:1.0.1"
checksum: 10c0/3187cf54e1e476c009a86504812066ce59e977605f4fd5f9ffbf5cf5062e9b6360e512d277fb09264f9567c547934ec28a2863656be0352a80a547b3a4155de5
checksum: 10c0/328adcea82ac4dc120aa84e29904003dd55bfd79bb444813a07ab7c08cf19f16ab5bfaecb88ff34f9e086b15a43ffa879ae95271693e689364fdaae9c5e4e304
languageName: node
linkType: hard

Expand Down Expand Up @@ -5267,7 +5275,7 @@ __metadata:
languageName: node
linkType: hard

"serve-static@npm:1.16.2, serve-static@npm:^1.13.2":
"serve-static@npm:1.16.2, serve-static@npm:^1.15.0":
version: 1.16.2
resolution: "serve-static@npm:1.16.2"
dependencies:
Expand Down Expand Up @@ -5454,13 +5462,6 @@ __metadata:
languageName: node
linkType: hard

"statuses@npm:>= 1.5.0 < 2":
version: 1.5.0
resolution: "statuses@npm:1.5.0"
checksum: 10c0/e433900956357b3efd79b1c547da4d291799ac836960c016d10a98f6a810b1b5c0dcc13b5a7aa609a58239b5190e1ea176ad9221c2157d2fd1c747393e6b2940
languageName: node
linkType: hard

"string-length@npm:^4.0.1":
version: 4.0.2
resolution: "string-length@npm:4.0.2"
Expand Down Expand Up @@ -5625,10 +5626,10 @@ __metadata:
languageName: node
linkType: hard

"swagger-ui-dist@npm:^4.10.3":
version: 4.11.0
resolution: "swagger-ui-dist@npm:4.11.0"
checksum: 10c0/2f2944fb2eb34ee03b5fa255be6addde076656c441d733ec55232a65e3d64026d9c2832ec9b330ddd1da92c70504b852b1fce903266448bcd2f4124b677269ce
"swagger-ui-dist@npm:^5.11.8":
version: 5.17.14
resolution: "swagger-ui-dist@npm:5.17.14"
checksum: 10c0/cb61bba39e76d7d0d83da605a55e9504c1a5b421f9f13cced06d3e222f0a291594d417ec57b30a38aabe30d8a7e257c4977b8f0bba0e865d60f92b0a8ef4dfc1
languageName: node
linkType: hard

Expand Down Expand Up @@ -6065,6 +6066,15 @@ __metadata:
languageName: node
linkType: hard

"yaml@npm:^2.4.0":
version: 2.5.1
resolution: "yaml@npm:2.5.1"
bin:
yaml: bin.mjs
checksum: 10c0/40fba5682898dbeeb3319e358a968fe886509fab6f58725732a15f8dda3abac509f91e76817c708c9959a15f786f38ff863c1b88062d7c1162c5334a7d09cb4a
languageName: node
linkType: hard

"yargs-parser@npm:^21.0.0":
version: 21.0.1
resolution: "yargs-parser@npm:21.0.1"
Expand Down
Loading