Skip to content

Commit

Permalink
fix destructure of openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Jan 15, 2020
1 parent 3bb1241 commit d41fc02
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class OpenApiValidator {
}

public async install(app: Application | Router): Promise<void>;
public install(app: Application | Router, callback: (error: Error) => void): void;
public install(
app: Application | Router,
callback: (error: Error) => void,
): void;
public install(
app: Application | Router,
callback?: (error: Error) => void,
Expand Down Expand Up @@ -102,7 +105,10 @@ export class OpenApiValidator {
}
}

private installPathParams(app: Application | Router, context: OpenApiContext): void {
private installPathParams(
app: Application | Router,
context: OpenApiContext,
): void {
const pathParams: string[] = [];
for (const route of context.routes) {
if (route.pathParams.length > 0) {
Expand All @@ -121,8 +127,9 @@ export class OpenApiValidator {
value: any,
name: string,
) => {
const { pathParams } = <OpenApiRequestMetadata>req.openapi;
if (pathParams) {
const openapi = <OpenApiRequestMetadata>req.openapi;
if (openapi?.pathParams) {
const { pathParams } = openapi;
// override path params
req.params[name] = pathParams[name] || req.params[name];
}
Expand Down

0 comments on commit d41fc02

Please sign in to comment.