diff --git a/src/lib/code-sample/go.ts b/src/lib/code-sample/go.ts index 00102c1..bd95141 100644 --- a/src/lib/code-sample/go.ts +++ b/src/lib/code-sample/go.ts @@ -109,11 +109,14 @@ const formatGoValue = ({ const formattedItems = value.map((v) => formatGoValue({ value: v, key })) const item = value[0] - const arrayType = item - ? isPrimitiveValue(item) - ? getPrimitiveTypeName(item) - : `api.${pascalCase(key)}` - : '' + if (item == null) { + throw new Error(`Null value in response array for '${key}'`) + } + + const arrayType = isPrimitiveValue(item) + ? getPrimitiveTypeName(item) + : `api.${pascalCase(key)}` + return `[${value.length}]${arrayType}{${formattedItems.join(', ')}}` }