Skip to content

Commit

Permalink
Default req params to empty object
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Sep 24, 2024
1 parent ea4a7cc commit 6206bdd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/code-sample/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const createJavascriptRequest = (
_context: Context,
): string => {
const parts = request.path.split('/')
const isWithoutParams = Object.keys(request.parameters ?? []).length === 0
const isWithoutParams = Object.keys(request.parameters ?? {}).length === 0
const formattedParams = isWithoutParams
? ''
: JSON.stringify(request.parameters)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/code-sample/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const createPhpRequest = (
_context: Context,
): string => {
const parts = request.path.split('/')
const requestParams = Object.entries(request.parameters ?? [])
const requestParams = Object.entries(request.parameters ?? {})
.map(([key, value]) => `${key}:${JSON.stringify(value)}`)
.join(',')

Expand Down
2 changes: 1 addition & 1 deletion src/lib/code-sample/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const createPythonRequest = (
_context: Context,
): string => {
const parts = request.path.split('/')
const params = formatPythonArgs(request.parameters ?? [])
const params = formatPythonArgs(request.parameters ?? {})

return `seam${parts.map((p) => snakeCase(p)).join('.')}(${params})`
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/code-sample/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const createRubyRequest = (
_context: Context,
): string => {
const parts = request.path.split('/')
const params = Object.entries(request.parameters ?? [])
const params = Object.entries(request.parameters ?? {})
.map(([key, value]) => `${snakeCase(key)}: ${formatRubyValue(value)}`)
.join(', ')

Expand Down
2 changes: 1 addition & 1 deletion src/lib/code-sample/seam-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const createSeamCliRequest = (
_context: Context,
): string => {
const parts = request.path.split('/')
const requestParams = Object.entries(request.parameters ?? [])
const requestParams = Object.entries(request.parameters ?? {})
.map(([key, value]) => `--${key} ${JSON.stringify(value)}`)
.join(' ')

Expand Down

0 comments on commit 6206bdd

Please sign in to comment.