Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
fix(express-openapi): fixed Openapi package caused by express 2.8.0 u…
Browse files Browse the repository at this point in the history
…pdate
  • Loading branch information
vikaskandari authored Jan 20, 2023
1 parent 3b6fb84 commit 9416cba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions express-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@decorators/express-openapi",
"version": "1.0.0-beta",
"version": "1.0.1-beta",
"description": "node decorators - openapi decorators for swagger-ui-express and @decorators/express",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"peerDependencies": {
"express": ">=4.16.3",
"@decorators/di": ">=1.0.2",
"@decorators/express": ">=2.5.0",
"swagger-ui-express": ">=4.1.6"
"@decorators/di": ">=1.0.3",
"@decorators/express": ">=2.8.0",
"swagger-ui-express": ">=4.6.0"
},
"devDependencies": {
"@decorators/di": ">=1.0.2",
Expand All @@ -35,4 +35,4 @@
"scripts": {
"compile": "tsc"
}
}
}
13 changes: 6 additions & 7 deletions express-openapi/src/decorators/WithDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export function WithDefinitions(options: WithDefinitionsOpts): ClassDecorator {
// for each method get all associated routes
function getRoutes(routes: any, methodName: string) {
const route = routes[methodName];
if (!route) return [];
return [route];
return route.routes ? route.routes : [];
}

function getPathName(basePath: string, url: string) {
Expand Down Expand Up @@ -75,20 +74,20 @@ function isDeprecated(url: string, pathMeta: PathMeta): boolean {
return Array.isArray(pathMeta.deprecated) && pathMeta.deprecated.indexOf(url) >= 0;
}

const ExpressParamType: {[key: number]: ParamLocation} = {
const ExpressParamType: { [key: number]: ParamLocation } = {
2: 'path',
3: 'query',
5: 'header',
6: 'cookie',
};

function getRouteParams(params: { type: number, name?: string }[]): ParamDef[] {
return params
.filter(({ type, name }) => ExpressParamType[type] && name)
.map(({ type, name }) => ({ name, in: ExpressParamType[type], required: ExpressParamType[type] === 'path' }));
return params
.filter(({ type, name }) => ExpressParamType[type] && name)
.map(({ type, name }) => ({ name, in: ExpressParamType[type], required: ExpressParamType[type] === 'path' }));
}

function getParameters(meta: PathMeta, routeParams: ParamDef[] = []): ParamDef[]{
function getParameters(meta: PathMeta, routeParams: ParamDef[] = []): ParamDef[] {
const parameters = meta.parameters || [];
routeParams.forEach(param => {
if (parameters.findIndex(p => p.name === param.name && p.in === param.in) < 0) {
Expand Down

0 comments on commit 9416cba

Please sign in to comment.