Skip to content

Commit af5fb19

Browse files
committed
Add labels to request response pair
1 parent d0a5551 commit af5fb19

File tree

6 files changed

+62
-50
lines changed

6 files changed

+62
-50
lines changed

core/handlers/v2/schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@
161161
},
162162
"request-response-pair": {
163163
"properties": {
164+
"labels": {
165+
"items": {
166+
"type": "string"
167+
},
168+
"type": "array"
169+
},
164170
"request": {
165171
"$ref": "#/definitions/request"
166172
},

core/handlers/v2/simulation_views.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewSimulationViewFromRequestBody(requestBody []byte) (SimulationViewV5, err
3232

3333
schemaVersion := jsonMap["meta"].(map[string]interface{})["schemaVersion"].(string)
3434

35-
if schemaVersion == "v5" || schemaVersion == "v5.1" || schemaVersion == "v5.2" {
35+
if strings.HasPrefix(schemaVersion, "v5") {
3636

3737
err := ValidateSimulationSchemaFromFile(jsonMap, SimulationViewV5Schema)
3838
if err != nil {

core/handlers/v2/simulation_views_v5.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type DataViewV5 struct {
1717
}
1818

1919
type RequestMatcherResponsePairViewV5 struct {
20+
Labels []string `json:"labels,omitempty"`
2021
RequestMatcher RequestMatcherViewV5 `json:"request"`
2122
Response ResponseDetailsViewV5 `json:"response"`
2223
}

core/models/request_matcher.go

+3
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ func getViewFromRequestFieldMatcher(matcher *RequestFieldMatchers) *v2.MatcherVi
142142
}
143143

144144
type RequestMatcherResponsePair struct {
145+
Labels []string
145146
RequestMatcher RequestMatcher
146147
Response ResponseDetails
147148
}
148149

149150
func NewRequestMatcherResponsePairFromView(view *v2.RequestMatcherResponsePairViewV5) *RequestMatcherResponsePair {
150151

151152
return &RequestMatcherResponsePair{
153+
Labels: view.Labels,
152154
RequestMatcher: RequestMatcher{
153155
Path: NewRequestFieldMatchersFromView(view.RequestMatcher.Path),
154156
Method: NewRequestFieldMatchersFromView(view.RequestMatcher.Method),
@@ -229,6 +231,7 @@ func (this *RequestMatcherResponsePair) BuildView() v2.RequestMatcherResponsePai
229231
}
230232

231233
return v2.RequestMatcherResponsePairViewV5{
234+
Labels: this.Labels,
232235
RequestMatcher: v2.RequestMatcherViewV5{
233236
Path: path,
234237
Method: method,

0 commit comments

Comments
 (0)