Skip to content

Commit eb3af8f

Browse files
committed
fix(openapi-v3): check debug.enabled to avoid parameter calculation
1 parent 9246817 commit eb3af8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/openapi-v3/src/decorators/request-body.decorator.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) {
8181
return function(target: Object, member: string, index: number) {
8282
debug('@requestBody() on %s.%s', target.constructor.name, member);
8383
debug(' parameter index: %s', index);
84-
debug(' options: %s', inspect(requestBodySpec, {depth: null}));
84+
if (debug.enabled)
85+
debug(' options: %s', inspect(requestBodySpec, {depth: null}));
8586

8687
// Use 'application/json' as default content if `requestBody` is undefined
8788
requestBodySpec = requestBodySpec || {content: {}};
@@ -95,7 +96,8 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) {
9596

9697
const paramType = paramTypes[index];
9798
const schema = resolveSchema(paramType);
98-
debug(' inferred schema: %s', inspect(schema, {depth: null}));
99+
if (debug.enabled)
100+
debug(' inferred schema: %s', inspect(schema, {depth: null}));
99101
requestBodySpec.content = _.mapValues(requestBodySpec.content, c => {
100102
if (!c.schema) {
101103
c.schema = schema;
@@ -109,7 +111,8 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) {
109111
requestBodySpec[REQUEST_BODY_INDEX] = index;
110112
}
111113

112-
debug(' final spec: ', inspect(requestBodySpec, {depth: null}));
114+
if (debug.enabled)
115+
debug(' final spec: ', inspect(requestBodySpec, {depth: null}));
113116
ParameterDecoratorFactory.createDecorator<RequestBodyObject>(
114117
OAI3Keys.REQUEST_BODY_KEY,
115118
requestBodySpec as RequestBodyObject,

0 commit comments

Comments
 (0)