-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(rest): add support for form request body #1838
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,9 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) { | |
return function(target: Object, member: string, index: number) { | ||
debug('@requestBody() on %s.%s', target.constructor.name, member); | ||
debug(' parameter index: %s', index); | ||
debug(' options: %s', inspect(requestBodySpec, {depth: null})); | ||
/* istanbul ignore if */ | ||
if (debug.enabled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment please to tell our code coverage tool to ignore the fact that this block is intentionally skipped by tests and thus should be not be counted towards code coverage? |
||
debug(' options: %s', inspect(requestBodySpec, {depth: null})); | ||
|
||
// Use 'application/json' as default content if `requestBody` is undefined | ||
requestBodySpec = requestBodySpec || {content: {}}; | ||
|
@@ -95,7 +97,9 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) { | |
|
||
const paramType = paramTypes[index]; | ||
const schema = resolveSchema(paramType); | ||
debug(' inferred schema: %s', inspect(schema, {depth: null})); | ||
/* istanbul ignore if */ | ||
if (debug.enabled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment please to tell our code coverage tool to ignore the fact that this block is intentionally skipped by tests and thus should be not be counted towards code coverage? |
||
debug(' inferred schema: %s', inspect(schema, {depth: null})); | ||
requestBodySpec.content = _.mapValues(requestBodySpec.content, c => { | ||
if (!c.schema) { | ||
c.schema = schema; | ||
|
@@ -109,7 +113,9 @@ export function requestBody(requestBodySpec?: Partial<RequestBodyObject>) { | |
requestBodySpec[REQUEST_BODY_INDEX] = index; | ||
} | ||
|
||
debug(' final spec: ', inspect(requestBodySpec, {depth: null})); | ||
/* istanbul ignore if */ | ||
if (debug.enabled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment please to tell our code coverage tool to ignore the fact that this block is intentionally skipped by tests and thus should be not be counted towards code coverage? |
||
debug(' final spec: ', inspect(requestBodySpec, {depth: null})); | ||
ParameterDecoratorFactory.createDecorator<RequestBodyObject>( | ||
OAI3Keys.REQUEST_BODY_KEY, | ||
requestBodySpec as RequestBodyObject, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great example 👍