Skip to content

response from get table request is not parsed properly #27

@rdjy

Description

@rdjy

Summary

The response from get table request is not parsed properly

sample code

func tryGetTable(ctx context.Context, client *restapi.ClientWithResponses, keyspaceName string, tableName string) {
    rsp, err := client.GetTableWithResponse(ctx, keyspaceName, tableName, &restapi.GetTableParams{})
    if err != nil {
        panic(err)
    }
    enc := json.NewEncoder(os.Stdout)
    enc.Encode(rsp.JSON200)
}

expected result

{"columnDefinitions":[{"name":"firstname","static":false,"typeDefinition":"text"},{"name":"lastname","static":false,"typeDefinition":"text"}],"keyspace":"ghoti","name":"foo","primaryKey":{"clusteringKey":[],"partitionKey":["firstname"]},"tableOptions":{"clusteringExpression":[],"defaultTimeToLive":0}}

actual result

{"columnDefinitions":null,"name":"","primaryKey":{"partitionKey":null}}

invesitigation

there is a top level data key in the response

$ curl -s -H 'Content-Type: application/json' -H "X-Cassandra-Token: ${ASTRA_DB_TOKEN}" \
 https://${ASTRA_DB_ID}-${ASTRA_DB_REGION}.apps.astra.datastax.com/api/rest/v2/schemas/keyspaces/${ASTRA_DB_KEYSPACE}/tables/foo  \
  | jq .
{
  "data": {
    "name": "foo",
    "keyspace": "ghoti",
    "columnDefinitions": [
      {
        "name": "firstname",
        "typeDefinition": "text",
        "static": false
      },
      {
        "name": "lastname",
        "typeDefinition": "text",
        "static": false
      }
    ],
    "primaryKey": {
      "partitionKey": [
        "firstname"
      ],
      "clusteringKey": []
    },
    "tableOptions": {
      "defaultTimeToLive": 0,
      "clusteringExpression": []
    }
  }
}

It should be included in the specification here

responses:
'200':
description: ''
content:
application/json:
schema:
"$ref": "#/components/schemas/Table"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions