Skip to content

Commit 3ac8760

Browse files
OpenAPI: Fix ValidationError message attribute (grafana#90846)
It's `message`, not `msg`. It's been fixed for a while here: https://github.com/grafana/grafana-openapi-client-go/blob/9ef69836127d783a63b2d0c61b2f8bf3de0c8e86/scripts/pull-schema.sh#L46-L49 I've also reflected the change in the tests
1 parent 087df1d commit 3ac8760

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

pkg/services/ngalert/api/api_provisioning_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ func TestProvisioningApi(t *testing.T) {
9999
response := sut.RoutePutPolicyTree(&rc, tree)
100100

101101
require.Equal(t, 400, response.Status())
102-
expBody := `{"message":"invalid object specification: invalid policy tree"}`
103-
require.Equal(t, expBody, string(response.Body()))
102+
expBody := definitions.ValidationError{Message: "invalid object specification: invalid policy tree"}
103+
expBodyJSON, marshalErr := json.Marshal(expBody)
104+
require.NoError(t, marshalErr)
105+
require.Equal(t, string(expBodyJSON), string(response.Body()))
104106
})
105107
})
106108

pkg/services/ngalert/api/tooling/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4380,7 +4380,7 @@
43804380
},
43814381
"ValidationError": {
43824382
"properties": {
4383-
"msg": {
4383+
"message": {
43844384
"example": "error message",
43854385
"type": "string"
43864386
}

pkg/services/ngalert/api/tooling/definitions/shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Ack struct{}
1111
// swagger:model
1212
type ValidationError struct {
1313
// example: error message
14-
Msg string `json:"msg"`
14+
Message string `json:"message"`
1515
}
1616

1717
// swagger:model

pkg/services/ngalert/api/tooling/post.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4379,7 +4379,7 @@
43794379
},
43804380
"ValidationError": {
43814381
"properties": {
4382-
"msg": {
4382+
"message": {
43834383
"example": "error message",
43844384
"type": "string"
43854385
}

pkg/services/ngalert/api/tooling/spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8013,7 +8013,7 @@
80138013
"ValidationError": {
80148014
"type": "object",
80158015
"properties": {
8016-
"msg": {
8016+
"message": {
80178017
"type": "string",
80188018
"example": "error message"
80198019
}

public/api-merged.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21969,7 +21969,7 @@
2196921969
"ValidationError": {
2197021970
"type": "object",
2197121971
"properties": {
21972-
"msg": {
21972+
"message": {
2197321973
"type": "string",
2197421974
"example": "error message"
2197521975
}

public/openapi3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12027,7 +12027,7 @@
1202712027
},
1202812028
"ValidationError": {
1202912029
"properties": {
12030-
"msg": {
12030+
"message": {
1203112031
"example": "error message",
1203212032
"type": "string"
1203312033
}

0 commit comments

Comments
 (0)