Skip to content

Commit ba4fdb1

Browse files
authored
fix(openapi): bulk response definition (#854)
1 parent a2ef7c9 commit ba4fdb1

File tree

7 files changed

+43
-59
lines changed

7 files changed

+43
-59
lines changed

docs/api/README.md

+5-14
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,7 @@ Accept: application/json
625625
}
626626
],
627627
"errorCode": "VALIDATION",
628-
"errorMessage": "[VALIDATION] invalid 'cursor' query param",
629-
"details": "https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9"
628+
"errorMessage": "[VALIDATION] invalid 'cursor' query param"
630629
}
631630
```
632631

@@ -3862,26 +3861,18 @@ and
38623861
}
38633862
],
38643863
"errorCode": "VALIDATION",
3865-
"errorMessage": "[VALIDATION] invalid 'cursor' query param",
3866-
"details": "https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9"
3864+
"errorMessage": "[VALIDATION] invalid 'cursor' query param"
38673865
}
38683866

38693867
```
38703868

38713869
### Properties
38723870

3873-
allOf
3874-
3875-
|Name|Type|Required|Restrictions|Description|
3876-
|---|---|---|---|---|
3877-
|*anonymous*|object|false|none|none|
3878-
|» data|[[V2BulkElementResult](#schemav2bulkelementresult)]|false|none|none|
3879-
3880-
and
3881-
38823871
|Name|Type|Required|Restrictions|Description|
38833872
|---|---|---|---|---|
3884-
|*anonymous*|[V2ErrorResponse](#schemav2errorresponse)|false|none|none|
3873+
|data|[[V2BulkElementResult](#schemav2bulkelementresult)]|false|none|none|
3874+
|errorCode|[V2ErrorsEnum](#schemav2errorsenum)|false|none|none|
3875+
|errorMessage|string|false|none|none|
38853876

38863877
<h2 id="tocS_V2BulkElementResult">V2BulkElementResult</h2>
38873878
<!-- backwards compatibility -->

openapi.yaml

+10-9
Original file line numberDiff line numberDiff line change
@@ -3777,16 +3777,17 @@ components:
37773777
- targetType
37783778
- key
37793779
V2BulkResponse:
3780-
allOf:
3781-
- properties:
3782-
data:
3783-
type: array
3784-
items:
3785-
$ref: "#/components/schemas/V2BulkElementResult"
3786-
- $ref: "#/components/schemas/V2ErrorResponse"
37873780
type: object
3788-
required:
3789-
- data
3781+
properties:
3782+
data:
3783+
type: array
3784+
items:
3785+
$ref: "#/components/schemas/V2BulkElementResult"
3786+
errorCode:
3787+
$ref: "#/components/schemas/V2ErrorsEnum"
3788+
errorMessage:
3789+
type: string
3790+
example: "[VALIDATION] invalid 'cursor' query param"
37903791
V2BulkElementResult:
37913792
type: object
37923793
oneOf:

openapi/v2.yaml

+10-9
Original file line numberDiff line numberDiff line change
@@ -1934,16 +1934,17 @@ components:
19341934
- targetType
19351935
- key
19361936
V2BulkResponse:
1937-
allOf:
1938-
- properties:
1939-
data:
1940-
type: array
1941-
items:
1942-
$ref: "#/components/schemas/V2BulkElementResult"
1943-
- $ref: "#/components/schemas/V2ErrorResponse"
19441937
type: object
1945-
required:
1946-
- data
1938+
properties:
1939+
data:
1940+
type: array
1941+
items:
1942+
$ref: "#/components/schemas/V2BulkElementResult"
1943+
errorCode:
1944+
$ref: "#/components/schemas/V2ErrorsEnum"
1945+
errorMessage:
1946+
type: string
1947+
example: "[VALIDATION] invalid 'cursor' query param"
19471948
V2BulkElementResult:
19481949
type: object
19491950
oneOf:

pkg/client/.speakeasy/gen.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
lockVersion: 2.0.0
22
id: a9ac79e1-e429-4ee3-96c4-ec973f19bec3
33
management:
4-
docChecksum: 2eda230dcb858e207c81e8ba6f80428e
4+
docChecksum: 2d8f4181402576bb8ac4f4ce71d6e596
55
docVersion: v2
66
speakeasyVersion: 1.517.3
77
generationVersion: 2.548.6
@@ -720,9 +720,9 @@ examples:
720720
application/json: [{"action": "<value>", "data": {"postings": [{"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}, {"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}, {"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}], "script": {"plain": "vars {\naccount $user\n}\nsend [COIN 10] (\n\tsource = @world\n\tdestination = $user\n)\n", "vars": {"user": "users:042"}}, "reference": "ref:001", "metadata": {"admin": "true"}, "accountMetadata": {"key": {"admin": "true"}}}}]
721721
responses:
722722
"200":
723-
application/json: {"data": [{"responseType": "<value>", "logID": 642842, "data": {"timestamp": "2023-05-07T17:50:11.166Z", "postings": [{"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}, {"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}], "reference": "ref:001", "metadata": {"admin": "true"}, "id": 860718, "reverted": true, "preCommitVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "postCommitVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "preCommitEffectiveVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "postCommitEffectiveVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}}}], "errorCode": "VALIDATION", "errorMessage": "[VALIDATION] invalid 'cursor' query param", "details": "https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9"}
723+
application/json: {"data": [{"responseType": "<value>", "logID": 642842, "data": {"timestamp": "2023-05-07T17:50:11.166Z", "postings": [{"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}, {"amount": 100, "asset": "COIN", "destination": "users:002", "source": "users:001"}], "reference": "ref:001", "metadata": {"admin": "true"}, "id": 860718, "reverted": true, "preCommitVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "postCommitVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "preCommitEffectiveVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}, "postCommitEffectiveVolumes": {"orders:1": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}, "orders:2": {"USD": {"input": 100, "output": 20, "balance": 80}, "EUR": {"input": 100, "output": 20, "balance": 80}}}}}], "errorCode": "VALIDATION", "errorMessage": "[VALIDATION] invalid 'cursor' query param"}
724724
"400":
725-
application/json: {"data": [], "errorCode": "VALIDATION", "errorMessage": "[VALIDATION] invalid 'cursor' query param", "details": "https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9"}
725+
application/json: {"data": [], "errorCode": "VALIDATION", "errorMessage": "[VALIDATION] invalid 'cursor' query param"}
726726
default:
727727
application/json: {"errorCode": "VALIDATION", "errorMessage": "[VALIDATION] invalid 'cursor' query param", "details": "https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9"}
728728
v2CountAccounts:

pkg/client/docs/models/components/v2bulkresponse.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
## Fields
55

6-
| Field | Type | Required | Description | Example |
7-
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
8-
| `Data` | [][components.V2BulkElementResult](../../models/components/v2bulkelementresult.md) | :heavy_check_mark: | N/A | |
9-
| `ErrorCode` | [components.V2ErrorsEnum](../../models/components/v2errorsenum.md) | :heavy_check_mark: | N/A | VALIDATION |
10-
| `ErrorMessage` | *string* | :heavy_check_mark: | N/A | [VALIDATION] invalid 'cursor' query param |
11-
| `Details` | **string* | :heavy_minus_sign: | N/A | https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9 |
6+
| Field | Type | Required | Description | Example |
7+
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
8+
| `Data` | [][components.V2BulkElementResult](../../models/components/v2bulkelementresult.md) | :heavy_minus_sign: | N/A | |
9+
| `ErrorCode` | [*components.V2ErrorsEnum](../../models/components/v2errorsenum.md) | :heavy_minus_sign: | N/A | VALIDATION |
10+
| `ErrorMessage` | **string* | :heavy_minus_sign: | N/A | [VALIDATION] invalid 'cursor' query param |

pkg/client/models/components/v2bulkresponse.go

+8-16
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,28 @@
33
package components
44

55
type V2BulkResponse struct {
6-
Data []V2BulkElementResult `json:"data"`
7-
ErrorCode V2ErrorsEnum `json:"errorCode"`
8-
ErrorMessage string `json:"errorMessage"`
9-
Details *string `json:"details,omitempty"`
6+
Data []V2BulkElementResult `json:"data,omitempty"`
7+
ErrorCode *V2ErrorsEnum `json:"errorCode,omitempty"`
8+
ErrorMessage *string `json:"errorMessage,omitempty"`
109
}
1110

1211
func (o *V2BulkResponse) GetData() []V2BulkElementResult {
1312
if o == nil {
14-
return []V2BulkElementResult{}
13+
return nil
1514
}
1615
return o.Data
1716
}
1817

19-
func (o *V2BulkResponse) GetErrorCode() V2ErrorsEnum {
18+
func (o *V2BulkResponse) GetErrorCode() *V2ErrorsEnum {
2019
if o == nil {
21-
return V2ErrorsEnum("")
20+
return nil
2221
}
2322
return o.ErrorCode
2423
}
2524

26-
func (o *V2BulkResponse) GetErrorMessage() string {
27-
if o == nil {
28-
return ""
29-
}
30-
return o.ErrorMessage
31-
}
32-
33-
func (o *V2BulkResponse) GetDetails() *string {
25+
func (o *V2BulkResponse) GetErrorMessage() *string {
3426
if o == nil {
3527
return nil
3628
}
37-
return o.Details
29+
return o.ErrorMessage
3830
}

pkg/generate/generator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ func (r Action) Apply(ctx context.Context, client *client.V2, l string) ([]compo
152152
if response.HTTPMeta.Response.StatusCode == http.StatusBadRequest {
153153
return nil, fmt.Errorf(
154154
"unexpected error: %s [%s]",
155-
response.V2BulkResponse.ErrorMessage,
156-
response.V2BulkResponse.ErrorCode,
155+
*response.V2BulkResponse.ErrorMessage,
156+
*response.V2BulkResponse.ErrorCode,
157157
)
158158
}
159159

0 commit comments

Comments
 (0)