Skip to content

Commit

Permalink
Fix go request and response string value samples
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Sep 24, 2024
1 parent 0c938b9 commit 355878f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/lib/code-sample/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const createGoRequest = (
const params = formatGoArgs(request.parameters ?? {})
const isReqWithParams = Object.keys(request.parameters).length !== 0

return `client.${parts.map((p) => pascalCase(p)).join('.')}(context.Background()${isReqWithParams ? `, api.${pascalCase(parts.join('_'))}Request(${params})` : ''})`
return `client${parts.map((p) => pascalCase(p)).join('.')}(context.Background()${isReqWithParams ? `, api.${pascalCase(parts.join('_'))}Request(${params})` : ''})`
}

const formatGoArgs = (jsonParams: NonNullJson): string =>
Expand Down Expand Up @@ -94,11 +94,8 @@ const formatGoResponse = (

const formatGoResponseValue = (value: Json): any => {
if (value == null) return 'nil'
if (
typeof value === 'string' ||
typeof value === 'boolean' ||
typeof value === 'number'
) {
if (typeof value === 'string') return `"${value}"`
if (typeof value === 'boolean' || typeof value === 'number') {
return value
}
if (Array.isArray(value)) {
Expand Down

0 comments on commit 355878f

Please sign in to comment.