Skip to content

Commit

Permalink
chore(deps): bump github.com/getkin/kin-openapi from 0.120.0 to 0.127…
Browse files Browse the repository at this point in the history
….0 (#140)

* chore(deps): bump github.com/getkin/kin-openapi from 0.120.0 to 0.124.0

Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.120.0 to 0.124.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](getkin/kin-openapi@v0.120.0...v0.124.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix: openapi spec generation

* fix: flaky logger test if environment vars are set

* fix: flaky openapi validation test

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lvlcn-t <[email protected]>
  • Loading branch information
dependabot[bot] and lvlcn-t authored Aug 8, 2024
1 parent 88fe045 commit 6b80766
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/caas-team/sparrow
go 1.22

require (
github.com/getkin/kin-openapi v0.120.0
github.com/getkin/kin-openapi v0.127.0
github.com/go-chi/chi/v5 v5.1.0
github.com/google/go-cmp v0.6.0
github.com/jarcoal/httpmock v1.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/getkin/kin-openapi v0.120.0 h1:MqJcNJFrMDFNc07iwE8iFC5eT2k/NPUFDIpNeiZv8Jg=
github.com/getkin/kin-openapi v0.120.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw=
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
github.com/getkin/kin-openapi v0.127.0/go.mod h1:OZrfXzUfGrNbsKj+xmFBx6E5c6yH3At/tAKSc2UszXM=
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down
5 changes: 2 additions & 3 deletions internal/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ func TestFromContext(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := FromContext(tt.ctx)
_, ok := got.Handler().(*slog.JSONHandler)
if !ok {
t.Errorf("FromContext() = %T, want %T", got, tt.want)
if reflect.TypeOf(got.Handler()) != reflect.TypeOf(tt.want.Handler()) {
t.Errorf("FromContext() = %T, want %T", got.Handler(), tt.want.Handler())
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/checks/oapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func TestOpenapiFromPerfData(t *testing.T) {
args: args[string]{perfData: "hello world"},
want: &openapi3.SchemaRef{
Value: openapi3.NewObjectSchema().WithProperties(map[string]*openapi3.Schema{
"data": {Type: "string"},
"data": {Type: openapi3.NewStringSchema().Type},
"timestamp": {
Type: "string",
Type: openapi3.NewStringSchema().Type,
Format: "date-time",
},
}),
Expand Down
24 changes: 13 additions & 11 deletions pkg/sparrow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ var oapiBoilerplate = openapi3.T{
Name: "CaaS Team",
},
},
Paths: make(openapi3.Paths),
Paths: &openapi3.Paths{
Extensions: make(map[string]any),
},
Extensions: make(map[string]any),
Components: &openapi3.Components{
Schemas: make(openapi3.Schemas),
Expand All @@ -203,21 +205,21 @@ func (cc *ChecksController) GenerateCheckSpecs(ctx context.Context) (openapi3.T,

routeDesc := fmt.Sprintf("Returns the performance data for check %s", name)
bodyDesc := fmt.Sprintf("Metrics for check %s", name)
doc.Paths["/v1/metrics/"+name] = &openapi3.PathItem{
responses := &openapi3.Responses{}
responses.Set(fmt.Sprint(http.StatusOK), &openapi3.ResponseRef{
Value: &openapi3.Response{
Description: &bodyDesc,
Content: openapi3.NewContentWithSchemaRef(ref, []string{"application/json"}),
},
})
doc.Paths.Set(fmt.Sprintf("/v1/metrics/%s", name), &openapi3.PathItem{
Description: name,
Get: &openapi3.Operation{
Description: routeDesc,
Tags: []string{"Metrics", name},
Responses: openapi3.Responses{
fmt.Sprint(http.StatusOK): &openapi3.ResponseRef{
Value: &openapi3.Response{
Description: &bodyDesc,
Content: openapi3.NewContentWithSchemaRef(ref, []string{"application/json"}),
},
},
},
Responses: responses,
},
}
})
}

return doc, nil
Expand Down
10 changes: 6 additions & 4 deletions pkg/sparrow/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func TestGenerateCheckSpecs(t *testing.T) {
name string
}
res := CheckResultSpec{name: "check1"}
return checks.OpenapiFromPerfData[CheckResultSpec](res)
return checks.OpenapiFromPerfData(res)
},
},
&checks.CheckMock{
Expand All @@ -316,16 +316,18 @@ func TestGenerateCheckSpecs(t *testing.T) {
name string
}
res := CheckResultSpec{name: "check2"}
return checks.OpenapiFromPerfData[CheckResultSpec](res)
return checks.OpenapiFromPerfData(res)
},
},
},
wantErr: false,
validate: func(t *testing.T, doc openapi3.T) {
if _, ok := doc.Paths["/v1/metrics/check1"]; !ok {
item := doc.Paths.Find("/v1/metrics/check1")
if item == nil {
t.Errorf("Expected path '/v1/metrics/check1' not found")
}
if _, ok := doc.Paths["/v1/metrics/check2"]; !ok {
item = doc.Paths.Find("/v1/metrics/check2")
if item == nil {
t.Errorf("Expected path '/v1/metrics/check2' not found")
}
},
Expand Down

0 comments on commit 6b80766

Please sign in to comment.