From 37a01dba223d62521143ff6a6884e47404c3601d Mon Sep 17 00:00:00 2001 From: Jefftree Date: Tue, 18 Jan 2022 13:10:17 -0800 Subject: [PATCH 1/2] Upgrade to restful v2.9.5 and support Deprecated field --- go.mod | 4 ++-- pkg/builder/openapi.go | 1 + pkg/builder3/openapi.go | 1 + pkg/common/interfaces.go | 2 ++ pkg/common/restfuladapter/route_adapter.go | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 6694d8600..a2eb17b0e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a github.com/emicklei/go-restful/v3 v3.8.0 - github.com/getkin/kin-openapi v0.76.0 + github.com/getkin/kin-openapi v0.76.0 github.com/go-openapi/jsonreference v0.19.3 github.com/go-openapi/swag v0.19.5 github.com/golang/protobuf v1.5.2 @@ -14,7 +14,7 @@ require ( github.com/google/go-cmp v0.5.5 github.com/google/gofuzz v1.1.0 github.com/google/uuid v1.1.2 - github.com/mitchellh/mapstructure v1.1.2 + github.com/mitchellh/mapstructure v1.1.2 github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d github.com/onsi/ginkgo/v2 v2.1.4 github.com/onsi/gomega v1.19.0 diff --git a/pkg/builder/openapi.go b/pkg/builder/openapi.go index 98be932cb..db2ca2688 100644 --- a/pkg/builder/openapi.go +++ b/pkg/builder/openapi.go @@ -286,6 +286,7 @@ func (o *openAPI) buildOperations(route common.Route, inPathCommonParamsMap map[ Description: route.Description(), Consumes: route.Consumes(), Produces: route.Produces(), + Deprecated: route.Deprecated(), Schemes: o.config.ProtocolList, Responses: &spec.Responses{ ResponsesProps: spec.ResponsesProps{ diff --git a/pkg/builder3/openapi.go b/pkg/builder3/openapi.go index a0c00f07f..5e142a4b1 100644 --- a/pkg/builder3/openapi.go +++ b/pkg/builder3/openapi.go @@ -77,6 +77,7 @@ func (o *openAPI) buildOperations(route common.Route, inPathCommonParamsMap map[ ret := &spec3.Operation{ OperationProps: spec3.OperationProps{ Description: route.Description(), + Deprecated: route.Deprecated(), Responses: &spec3.Responses{ ResponsesProps: spec3.ResponsesProps{ StatusCodeResponses: make(map[int]*spec3.Response), diff --git a/pkg/common/interfaces.go b/pkg/common/interfaces.go index 059fc551b..1767a950c 100644 --- a/pkg/common/interfaces.go +++ b/pkg/common/interfaces.go @@ -36,6 +36,8 @@ type Route interface { // StatusCodeResponses defines a mapping of HTTP Status Codes to the specific response(s). // Multiple responses with the same HTTP Status Code are acceptable. StatusCodeResponses() []StatusCodeResponse + // Deprecated marks a route as deprecated + Deprecated() bool } // StatusCodeResponse is an explicit response type with an HTTP Status Code. diff --git a/pkg/common/restfuladapter/route_adapter.go b/pkg/common/restfuladapter/route_adapter.go index c7ba3a564..362f35bfb 100644 --- a/pkg/common/restfuladapter/route_adapter.go +++ b/pkg/common/restfuladapter/route_adapter.go @@ -66,3 +66,7 @@ func (r *RouteAdapter) RequestPayloadSample() interface{} { func (r *RouteAdapter) ResponsePayloadSample() interface{} { return r.Route.WriteSample } + +func (r *RouteAdapter) Deprecated() bool { + return r.Route.Deprecated +} From 0c38d6d6cc20ebcdb8affb441a93a3522aac28c8 Mon Sep 17 00:00:00 2001 From: Jefftree Date: Tue, 9 Aug 2022 23:04:26 +0000 Subject: [PATCH 2/2] Rebase indent --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index a2eb17b0e..6694d8600 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a github.com/emicklei/go-restful/v3 v3.8.0 - github.com/getkin/kin-openapi v0.76.0 + github.com/getkin/kin-openapi v0.76.0 github.com/go-openapi/jsonreference v0.19.3 github.com/go-openapi/swag v0.19.5 github.com/golang/protobuf v1.5.2 @@ -14,7 +14,7 @@ require ( github.com/google/go-cmp v0.5.5 github.com/google/gofuzz v1.1.0 github.com/google/uuid v1.1.2 - github.com/mitchellh/mapstructure v1.1.2 + github.com/mitchellh/mapstructure v1.1.2 github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d github.com/onsi/ginkgo/v2 v2.1.4 github.com/onsi/gomega v1.19.0