From ce72460d2fff06c8e922418e7199707584f3a2b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:06:44 +0000 Subject: [PATCH] Bump github.com/swaggest/openapi-go from 0.2.50 to 0.2.53 Bumps [github.com/swaggest/openapi-go](https://github.com/swaggest/openapi-go) from 0.2.50 to 0.2.53. - [Release notes](https://github.com/swaggest/openapi-go/releases) - [Commits](https://github.com/swaggest/openapi-go/compare/v0.2.50...v0.2.53) --- updated-dependencies: - dependency-name: github.com/swaggest/openapi-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 +-- go.sum | 12 +++---- .../swaggest/jsonschema-go/.golangci.yml | 18 +++------- .../swaggest/jsonschema-go/Makefile | 2 +- .../swaggest/jsonschema-go/reflect.go | 19 ++++++++++ .../swaggest/openapi-go/.golangci.yml | 19 ++++------ .../github.com/swaggest/openapi-go/Makefile | 2 +- .../github.com/swaggest/openapi-go/README.md | 36 +++++++++++-------- .../openapi-go/internal/json_schema.go | 12 +++++-- .../swaggest/openapi-go/openapi3/reflect.go | 11 +++--- vendor/modules.txt | 4 +-- 11 files changed, 77 insertions(+), 62 deletions(-) diff --git a/go.mod b/go.mod index f6a1b4aaf..996ef0d5d 100644 --- a/go.mod +++ b/go.mod @@ -47,8 +47,8 @@ require ( github.com/smartystreets/assertions v1.13.1 github.com/smartystreets/gunit v1.4.5 github.com/stretchr/testify v1.9.0 - github.com/swaggest/jsonschema-go v0.3.70 - github.com/swaggest/openapi-go v0.2.50 + github.com/swaggest/jsonschema-go v0.3.72 + github.com/swaggest/openapi-go v0.2.53 github.com/zitadel/oidc/v2 v2.12.0 go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.49.0 go.opentelemetry.io/contrib/propagators/jaeger v1.27.0 diff --git a/go.sum b/go.sum index cc9cb1ea4..8929527a9 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= -github.com/bool64/dev v0.2.34 h1:P9n315P8LdpxusnYQ0X7MP1CZXwBK5ae5RZrd+GdSZE= -github.com/bool64/dev v0.2.34/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= +github.com/bool64/dev v0.2.35 h1:M17TLsO/pV2J7PYI/gpe3Ua26ETkzZGb+dC06eoMqlk= +github.com/bool64/dev v0.2.35/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -377,10 +377,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= -github.com/swaggest/jsonschema-go v0.3.70 h1:8Vx5nm5t/6DBFw2+WC0/Vp1ZVe9/4mpuA0tuAe0wwCI= -github.com/swaggest/jsonschema-go v0.3.70/go.mod h1:7N43/CwdaWgPUDfYV70K7Qm79tRqe/al7gLSt9YeGIE= -github.com/swaggest/openapi-go v0.2.50 h1:5yQ7N/IhMK9bQSk2yFAEbB75DvoXzyEmji3Q2iS++is= -github.com/swaggest/openapi-go v0.2.50/go.mod h1:5R2TWYBz0U7P3vwIwN0ytwSxqONXZnbiAaa+DQ3Sq1k= +github.com/swaggest/jsonschema-go v0.3.72 h1:IHaGlR1bdBUBPfhe4tfacN2TGAPKENEGiNyNzvnVHv4= +github.com/swaggest/jsonschema-go v0.3.72/go.mod h1:OrGyEoVqpfSFJ4Am4V/FQcQ3mlEC1vVeleA+5ggbVW4= +github.com/swaggest/openapi-go v0.2.53 h1:lWHKgC9IN48nBYxvuBrmAVJgki/1xsrGZWaWJnOLenE= +github.com/swaggest/openapi-go v0.2.53/go.mod h1:2Q7NpuG9NgpGeTaNOo852GSR6cCzSP4IznA9DNdUTQw= github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= diff --git a/vendor/github.com/swaggest/jsonschema-go/.golangci.yml b/vendor/github.com/swaggest/jsonschema-go/.golangci.yml index cd8cfec11..49a308d49 100644 --- a/vendor/github.com/swaggest/jsonschema-go/.golangci.yml +++ b/vendor/github.com/swaggest/jsonschema-go/.golangci.yml @@ -22,40 +22,33 @@ linters-settings: linters: enable-all: true disable: + - err113 - maintidx - musttag - containedctx - - goerr113 - funlen - gocognit - cyclop - lll - - maligned - gochecknoglobals - gomnd - wrapcheck - paralleltest - forbidigo - - exhaustivestruct - - interfacer # deprecated - forcetypeassert - - scopelint # deprecated - - ifshort # too many false positives - - golint # deprecated - varnamelen - tagliatelle - errname - ireturn - exhaustruct - nonamedreturns - - nosnakecase - - structcheck - - varcheck - - deadcode - testableexamples - dupword - depguard - tagalign + - execinquery + - mnd + - testifylint issues: exclude: @@ -67,12 +60,11 @@ issues: exclude-rules: - linters: - gomnd + - mnd - goconst - - goerr113 - noctx - funlen - dupl - - structcheck - unused - unparam - nosnakecase diff --git a/vendor/github.com/swaggest/jsonschema-go/Makefile b/vendor/github.com/swaggest/jsonschema-go/Makefile index a652be233..48c9a2552 100644 --- a/vendor/github.com/swaggest/jsonschema-go/Makefile +++ b/vendor/github.com/swaggest/jsonschema-go/Makefile @@ -1,4 +1,4 @@ -#GOLANGCI_LINT_VERSION := "v1.56.2" # Optional configuration to pinpoint golangci-lint version. +#GOLANGCI_LINT_VERSION := "v1.59.1" # Optional configuration to pinpoint golangci-lint version. # The head of Makefile determines location of dev-go to include standard targets. GO ?= go diff --git a/vendor/github.com/swaggest/jsonschema-go/reflect.go b/vendor/github.com/swaggest/jsonschema-go/reflect.go index fb43d4801..3280a9965 100644 --- a/vendor/github.com/swaggest/jsonschema-go/reflect.go +++ b/vendor/github.com/swaggest/jsonschema-go/reflect.go @@ -18,6 +18,7 @@ import ( var ( typeOfJSONRawMsg = reflect.TypeOf(json.RawMessage{}) + typeOfByteSlice = reflect.TypeOf([]byte{}) typeOfTime = reflect.TypeOf(time.Time{}) typeOfDate = reflect.TypeOf(Date{}) typeOfTextUnmarshaler = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() @@ -731,6 +732,24 @@ func (r *Reflector) applySubSchemas(v reflect.Value, rc *ReflectContext, schema } func (r *Reflector) isWellKnownType(t reflect.Type, schema *Schema) bool { + ts := refl.GoType(t) + + switch ts { + case "github.com/google/uuid.UUID", "github.com/gofrs/uuid.UUID", "github.com/gofrs/uuid/v5::uuid.UUID": + schema.AddType(String) + schema.WithFormat("uuid") + schema.WithExamples("248df4b7-aa70-47b8-a036-33ac447e668d") + + return true + } + + if t == typeOfByteSlice { + schema.AddType(String) + schema.WithFormat("base64") + + return true + } + if t == typeOfTime { schema.AddType(String) schema.WithFormat("date-time") diff --git a/vendor/github.com/swaggest/openapi-go/.golangci.yml b/vendor/github.com/swaggest/openapi-go/.golangci.yml index 0cee4d535..e2c73509e 100644 --- a/vendor/github.com/swaggest/openapi-go/.golangci.yml +++ b/vendor/github.com/swaggest/openapi-go/.golangci.yml @@ -21,51 +21,44 @@ linters: enable-all: true disable: - nilnil - - goerr113 + - err113 - funlen - gocyclo - cyclop - gocognit - musttag - lll - - maligned - gochecknoglobals - gomnd - wrapcheck - paralleltest - forbidigo - - exhaustivestruct - - interfacer # deprecated - forcetypeassert - - scopelint # deprecated - - ifshort # too many false positives - - golint # deprecated - varnamelen - tagliatelle - errname - ireturn - exhaustruct - nonamedreturns - - nosnakecase - - structcheck - - varcheck - - deadcode - testableexamples - dupword - depguard - tagalign + - execinquery + - mnd + - testifylint issues: exclude-use-default: false exclude-rules: - linters: - gomnd + - mnd - goconst - - goerr113 + - err113 - noctx - funlen - dupl - - structcheck - unused - unparam - nosnakecase diff --git a/vendor/github.com/swaggest/openapi-go/Makefile b/vendor/github.com/swaggest/openapi-go/Makefile index 71dd11073..14a78c1c1 100644 --- a/vendor/github.com/swaggest/openapi-go/Makefile +++ b/vendor/github.com/swaggest/openapi-go/Makefile @@ -1,4 +1,4 @@ -#GOLANGCI_LINT_VERSION := "v1.56.2" # Optional configuration to pinpoint golangci-lint version. +#GOLANGCI_LINT_VERSION := "v1.59.1" # Optional configuration to pinpoint golangci-lint version. # The head of Makefile determines location of dev-go to include standard targets. GO ?= go diff --git a/vendor/github.com/swaggest/openapi-go/README.md b/vendor/github.com/swaggest/openapi-go/README.md index 2ea851101..3a643511c 100644 --- a/vendor/github.com/swaggest/openapi-go/README.md +++ b/vendor/github.com/swaggest/openapi-go/README.md @@ -64,18 +64,22 @@ type resp struct { UpdatedAt time.Time `json:"updated_at"` } -putOp := openapi3.Operation{} +putOp, err := reflector.NewOperationContext(http.MethodPut, "/things/{id}") +handleError(err) -handleError(reflector.SetRequest(&putOp, new(req), http.MethodPut)) -handleError(reflector.SetJSONResponse(&putOp, new(resp), http.StatusOK)) -handleError(reflector.SetJSONResponse(&putOp, new([]resp), http.StatusConflict)) -handleError(reflector.Spec.AddOperation(http.MethodPut, "/things/{id}", putOp)) +putOp.AddReqStructure(new(req)) +putOp.AddRespStructure(new(resp), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK }) +putOp.AddRespStructure(new([]resp), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusConflict }) -getOp := openapi3.Operation{} +reflector.AddOperation(putOp) -handleError(reflector.SetRequest(&getOp, new(req), http.MethodGet)) -handleError(reflector.SetJSONResponse(&getOp, new(resp), http.StatusOK)) -handleError(reflector.Spec.AddOperation(http.MethodGet, "/things/{id}", getOp)) +getOp, err := reflector.NewOperationContext(http.MethodGet, "/things/{id}") +handleError(err) + +getOp.AddReqStructure(new(req)) +getOp.AddRespStructure(new(resp), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK }) + +reflector.AddOperation(getOp) schema, err := reflector.Spec.MarshalYAML() if err != nil { @@ -113,7 +117,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Openapi3TestResp' + $ref: '#/components/schemas/Resp' description: OK put: parameters: @@ -132,25 +136,25 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Openapi3TestReq' + $ref: '#/components/schemas/Req' responses: "200": content: application/json: schema: - $ref: '#/components/schemas/Openapi3TestResp' + $ref: '#/components/schemas/Resp' description: OK "409": content: application/json: schema: items: - $ref: '#/components/schemas/Openapi3TestResp' + $ref: '#/components/schemas/Resp' type: array description: Conflict components: schemas: - Openapi3TestReq: + Req: properties: amount: minimum: 0 @@ -164,11 +168,12 @@ components: name: type: string type: object + nullable: true type: array string: type: string type: object - Openapi3TestResp: + Resp: properties: amount: minimum: 0 @@ -185,6 +190,7 @@ components: name: type: string type: object + nullable: true type: array updated_at: format: date-time diff --git a/vendor/github.com/swaggest/openapi-go/internal/json_schema.go b/vendor/github.com/swaggest/openapi-go/internal/json_schema.go index a7166c99b..f19d55f02 100644 --- a/vendor/github.com/swaggest/openapi-go/internal/json_schema.go +++ b/vendor/github.com/swaggest/openapi-go/internal/json_schema.go @@ -66,6 +66,14 @@ func ReflectRequestBody( hasTaggedFields = refl.HasTaggedFields(input, t) } + hasJSONSchemaStruct := false + + refl.WalkFieldsRecursively(reflect.ValueOf(input), func(v reflect.Value, _ reflect.StructField, _ []reflect.StructField) { + if v.Type() == reflect.TypeOf(jsonschema.Struct{}) { + hasJSONSchemaStruct = true + } + }) + // Form data can not have map or array as body. if !hasTaggedFields && len(mapping) == 0 && tag != tagJSON { return nil, false, nil @@ -74,7 +82,7 @@ func ReflectRequestBody( // If `formData` is defined on a request body `json` is ignored. if tag == tagJSON && (refl.HasTaggedFields(input, tagFormData) || refl.HasTaggedFields(input, tagForm)) && - !forceJSONRequestBody { + !forceJSONRequestBody && !hasJSONSchemaStruct { return nil, false, nil } @@ -89,7 +97,7 @@ func ReflectRequestBody( } // JSON can be a map or array without field tags. - if !hasTaggedFields && len(mapping) == 0 && !refl.IsSliceOrMap(input) && + if !hasTaggedFields && !hasJSONSchemaStruct && len(mapping) == 0 && !refl.IsSliceOrMap(input) && refl.FindEmbeddedSliceOrMap(input) == nil && !isProcessWithoutTags { return nil, false, nil } diff --git a/vendor/github.com/swaggest/openapi-go/openapi3/reflect.go b/vendor/github.com/swaggest/openapi-go/openapi3/reflect.go index afae59e4e..faf674277 100644 --- a/vendor/github.com/swaggest/openapi-go/openapi3/reflect.go +++ b/vendor/github.com/swaggest/openapi-go/openapi3/reflect.go @@ -717,13 +717,10 @@ func (r *Reflector) parseJSONResponse(resp *Response, oc openapi.OperationContex contentType = mimeJSON } - resp.Content[contentType] = MediaType{ - Schema: &oaiSchema, - Example: nil, - Examples: nil, - Encoding: nil, - MapOfAnything: nil, - } + mt := resp.Content[contentType] + mt.Schema = &oaiSchema + + resp.Content[contentType] = mt if sch.Description != nil && resp.Description == "" { resp.Description = *sch.Description diff --git a/vendor/modules.txt b/vendor/modules.txt index 6e377357e..f438ef57e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -418,10 +418,10 @@ github.com/spf13/pflag ## explicit; go 1.17 github.com/stretchr/testify/assert github.com/stretchr/testify/require -# github.com/swaggest/jsonschema-go v0.3.70 +# github.com/swaggest/jsonschema-go v0.3.72 ## explicit; go 1.18 github.com/swaggest/jsonschema-go -# github.com/swaggest/openapi-go v0.2.50 +# github.com/swaggest/openapi-go v0.2.53 ## explicit; go 1.18 github.com/swaggest/openapi-go github.com/swaggest/openapi-go/internal