Skip to content

Commit eb5e119

Browse files
committed
Fix: Ensure deprecations are parsed correctly
It appears that GoDoc does not parse these deprecation warnings as a deprecation unless there is an explicit blank comment between lines, or it is the start of a doc comment.
1 parent d663b6c commit eb5e119

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

pkg/chi-middleware/oapi_validate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ import (
1717
)
1818

1919
// ErrorHandler is called when there is an error in validation
20+
//
2021
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#ErrorHandler
2122
type ErrorHandler func(w http.ResponseWriter, message string, statusCode int)
2223

2324
// MultiErrorHandler is called when oapi returns a MultiError type
25+
//
2426
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#
2527
type MultiErrorHandler func(openapi3.MultiError) (int, error)
2628

2729
// Options to customize request validation, openapi3filter specified options will be passed through.
30+
//
2831
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#Options
2932
type Options struct {
3033
Options openapi3filter.Options
@@ -36,13 +39,15 @@ type Options struct {
3639

3740
// OapiRequestValidator Creates middleware to validate request by swagger spec.
3841
// This middleware is good for net/http either since go-chi is 100% compatible with net/http.
42+
//
3943
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#OapiRequestValidator
4044
func OapiRequestValidator(swagger *openapi3.T) func(next http.Handler) http.Handler {
4145
return OapiRequestValidatorWithOptions(swagger, nil)
4246
}
4347

4448
// OapiRequestValidatorWithOptions Creates middleware to validate request by swagger spec.
4549
// This middleware is good for net/http either since go-chi is 100% compatible with net/http.
50+
//
4651
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#OapiRequestValidatorWithOptions
4752
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) func(next http.Handler) http.Handler {
4853
if swagger.Servers != nil && (options == nil || !options.SilenceServersWarning) {
@@ -76,6 +81,7 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) func
7681

7782
// validateRequest is called from the middleware above and actually does the work
7883
// of validating a request.
84+
//
7985
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#validateRequest
8086
func validateRequest(r *http.Request, router routers.Router, options *Options) (int, error) {
8187

@@ -124,6 +130,7 @@ func validateRequest(r *http.Request, router routers.Router, options *Options) (
124130

125131
// attempt to get the MultiErrorHandler from the options. If it is not set,
126132
// return a default handler
133+
//
127134
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#getMultiErrorHandlerFromOptions
128135
func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
129136
if options == nil {
@@ -140,6 +147,7 @@ func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
140147
// defaultMultiErrorHandler returns a StatusBadRequest (400) and a list
141148
// of all the errors. This method is called if there are no other
142149
// methods defined on the options.
150+
//
143151
// Deprecated: This has been replaced by github.com/oapi-codegen/nethttp-middleware#defaultMultiErrorHandler
144152
func defaultMultiErrorHandler(me openapi3.MultiError) (int, error) {
145153
return http.StatusBadRequest, me

pkg/fiber-middleware/oapi_validate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type ctxKeyFiberContext struct{}
2323
type ctxKeyUserData struct{}
2424

2525
// OapiValidatorFromYamlFile creates a validator middleware from a YAML file path
26+
//
2627
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#OapiValidatorFromYamlFile
2728
func OapiValidatorFromYamlFile(path string) (fiber.Handler, error) {
2829

@@ -43,21 +44,25 @@ func OapiValidatorFromYamlFile(path string) (fiber.Handler, error) {
4344
// OapiRequestValidator is a fiber middleware function which validates incoming HTTP requests
4445
// to make sure that they conform to the given OAPI 3.0 specification. When
4546
// OAPI validation fails on the request, we return an HTTP/400 with error message
47+
//
4648
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#OapiRequestValidator
4749
func OapiRequestValidator(swagger *openapi3.T) fiber.Handler {
4850
return OapiRequestValidatorWithOptions(swagger, nil)
4951
}
5052

5153
// ErrorHandler is called when there is an error in validation
54+
//
5255
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#ErrorHandler
5356
type ErrorHandler func(c *fiber.Ctx, message string, statusCode int)
5457

5558
// MultiErrorHandler is called when oapi returns a MultiError type
59+
//
5660
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#MultiErrorHandler
5761
type MultiErrorHandler func(openapi3.MultiError) error
5862

5963
// Options to customize request validation. These are passed through to
6064
// openapi3filter.
65+
//
6166
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#Options
6267
type Options struct {
6368
Options openapi3filter.Options
@@ -68,6 +73,7 @@ type Options struct {
6873
}
6974

7075
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
76+
//
7177
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#OapiRequestValidatorWithOptions
7278
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) fiber.Handler {
7379

@@ -95,6 +101,7 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) fibe
95101

96102
// ValidateRequestFromContext is called from the middleware above and actually does the work
97103
// of validating a request.
104+
//
98105
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#
99106
func ValidateRequestFromContext(c *fiber.Ctx, router routers.Router, options *Options) error {
100107

@@ -164,6 +171,7 @@ func ValidateRequestFromContext(c *fiber.Ctx, router routers.Router, options *Op
164171

165172
// GetFiberContext gets the fiber context from within requests. It returns
166173
// nil if not found or wrong type.
174+
//
167175
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#GetFiberContext
168176
func GetFiberContext(c context.Context) *fiber.Ctx {
169177
iface := c.Value(ctxKeyFiberContext{})
@@ -185,6 +193,7 @@ func GetUserData(c context.Context) interface{} {
185193

186194
// getMultiErrorHandlerFromOptions attempts to get the MultiErrorHandler from the options. If it is not set,
187195
// return a default handler
196+
//
188197
// Deprecated: This has been replaced by github.com/oapi-codegen/fiber-middleware#getMultiErrorHandlerFromOptions
189198
func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
190199
if options == nil {

pkg/gin-middleware/oapi_validate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636
)
3737

3838
// OapiValidatorFromYamlFile creates a validator middleware from a YAML file path
39+
//
3940
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#OapiValidatorFromYamlFile
4041
func OapiValidatorFromYamlFile(path string) (gin.HandlerFunc, error) {
4142
data, err := os.ReadFile(path)
@@ -54,21 +55,25 @@ func OapiValidatorFromYamlFile(path string) (gin.HandlerFunc, error) {
5455
// OapiRequestValidator is an gin middleware function which validates incoming HTTP requests
5556
// to make sure that they conform to the given OAPI 3.0 specification. When
5657
// OAPI validation fails on the request, we return an HTTP/400 with error message
58+
//
5759
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#OapiRequestValidator
5860
func OapiRequestValidator(swagger *openapi3.T) gin.HandlerFunc {
5961
return OapiRequestValidatorWithOptions(swagger, nil)
6062
}
6163

6264
// ErrorHandler is called when there is an error in validation
65+
//
6366
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#ErrorHandler
6467
type ErrorHandler func(c *gin.Context, message string, statusCode int)
6568

6669
// MultiErrorHandler is called when oapi returns a MultiError type
70+
//
6771
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#MultiErrorHandler
6872
type MultiErrorHandler func(openapi3.MultiError) error
6973

7074
// Options to customize request validation. These are passed through to
7175
// openapi3filter.
76+
//
7277
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#Options
7378
type Options struct {
7479
ErrorHandler ErrorHandler
@@ -81,6 +86,7 @@ type Options struct {
8186
}
8287

8388
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
89+
//
8490
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#OapiRequestValidatorWithOptions
8591
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.HandlerFunc {
8692
if swagger.Servers != nil && (options == nil || !options.SilenceServersWarning) {
@@ -117,6 +123,7 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.
117123

118124
// ValidateRequestFromContext is called from the middleware above and actually does the work
119125
// of validating a request.
126+
//
120127
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#ValidateRequestFromContext
121128
func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *Options) error {
122129
req := c.Request
@@ -180,6 +187,7 @@ func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *
180187

181188
// GetGinContext gets the echo context from within requests. It returns
182189
// nil if not found or wrong type.
190+
//
183191
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#GetGinContext
184192
func GetGinContext(c context.Context) *gin.Context {
185193
iface := c.Value(GinContextKey)
@@ -199,6 +207,7 @@ func GetUserData(c context.Context) interface{} {
199207

200208
// attempt to get the MultiErrorHandler from the options. If it is not set,
201209
// return a default handler
210+
//
202211
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#getMultiErrorHandlerFromOptions
203212
func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
204213
if options == nil {
@@ -215,6 +224,7 @@ func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
215224
// defaultMultiErrorHandler returns a StatusBadRequest (400) and a list
216225
// of all of the errors. This method is called if there are no other
217226
// methods defined on the options.
227+
//
218228
// Deprecated: This has been replaced by github.com/oapi-codegen/gin-middleware#defaultMultiErrorHandler
219229
func defaultMultiErrorHandler(me openapi3.MultiError) error {
220230
return fmt.Errorf("multiple errors encountered: %s", me)

pkg/iris-middleware/oapi_validate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
)
2222

2323
// OapiValidatorFromYamlFile creates a validator middleware from a YAML file path
24+
//
2425
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#OapiValidatorFromYamlFile
2526
func OapiValidatorFromYamlFile(path string) (iris.Handler, error) {
2627
data, err := os.ReadFile(path)
@@ -40,21 +41,25 @@ func OapiValidatorFromYamlFile(path string) (iris.Handler, error) {
4041
// OapiRequestValidator is a iris middleware function which validates incoming HTTP requests
4142
// to make sure that they conform to the given OAPI 3.0 specification. When
4243
// OAPI validation fails on the request, we return an HTTP/400 with error message
44+
//
4345
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#OapiRequestValidator
4446
func OapiRequestValidator(swagger *openapi3.T) iris.Handler {
4547
return OapiRequestValidatorWithOptions(swagger, nil)
4648
}
4749

4850
// ErrorHandler is called when there is an error in validation
51+
//
4952
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#ErrorHandler
5053
type ErrorHandler func(ctx iris.Context, message string, statusCode int)
5154

5255
// MultiErrorHandler is called when oapi returns a MultiError type
56+
//
5357
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#MultiErrorHandler
5458
type MultiErrorHandler func(openapi3.MultiError) error
5559

5660
// Options to customize request validation. These are passed through to
5761
// openapi3filter.
62+
//
5863
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#Options
5964
type Options struct {
6065
Options openapi3filter.Options
@@ -67,6 +72,7 @@ type Options struct {
6772
}
6873

6974
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
75+
//
7076
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#OapiRequestValidatorWithOptions
7177
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) iris.Handler {
7278
router, err := gorillamux.NewRouter(swagger)
@@ -89,6 +95,7 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) iris
8995

9096
// ValidateRequestFromContext is called from the middleware above and actually does the work
9197
// of validating a request.
98+
//
9299
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#ValidateRequestFromContext
93100
func ValidateRequestFromContext(ctx iris.Context, router routers.Router, options *Options) error {
94101
req := ctx.Request()
@@ -152,6 +159,7 @@ func ValidateRequestFromContext(ctx iris.Context, router routers.Router, options
152159

153160
// GetIrisContext gets the iris context from within requests. It returns
154161
// nil if not found or wrong type.
162+
//
155163
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#GetIrisContext
156164
func GetIrisContext(ctx context.Context) iris.Context {
157165
iface := ctx.Value(IrisContextKey)
@@ -173,6 +181,7 @@ func GetUserData(ctx context.Context) interface{} {
173181

174182
// getMultiErrorHandlerFromOptions attempts to get the MultiErrorHandler from the options. If it is not set,
175183
// return a default handler
184+
//
176185
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#getMultiErrorHandlerFromOptions
177186
func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
178187
if options == nil {
@@ -189,6 +198,7 @@ func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
189198
// defaultMultiErrorHandler returns a StatusBadRequest (400) and a list
190199
// of all the errors. This method is called if there are no other
191200
// methods defined on the options.
201+
//
192202
// Deprecated: This has been replaced by github.com/oapi-codegen/iris-middleware#defaultMultiErrorHandler
193203
func defaultMultiErrorHandler(me openapi3.MultiError) error {
194204
return fmt.Errorf("multiple errors encountered: %s", me)

pkg/middleware/oapi_validate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const (
4040
// to make sure that they conform to the given OAPI 3.0 specification. When
4141
// OAPI validation fails on the request, we return an HTTP/400.
4242
// Create validator middleware from a YAML file path
43+
//
4344
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#OapiValidatorFromYamlFile
4445
func OapiValidatorFromYamlFile(path string) (echo.MiddlewareFunc, error) {
4546
data, err := os.ReadFile(path)
@@ -55,21 +56,25 @@ func OapiValidatorFromYamlFile(path string) (echo.MiddlewareFunc, error) {
5556
}
5657

5758
// OapiRequestValidator creates a validator from a swagger object.
59+
//
5860
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#OapiRequestValidator
5961
func OapiRequestValidator(swagger *openapi3.T) echo.MiddlewareFunc {
6062
return OapiRequestValidatorWithOptions(swagger, nil)
6163
}
6264

6365
// ErrorHandler is called when there is an error in validation
66+
//
6467
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#ErrorHandler
6568
type ErrorHandler func(c echo.Context, err *echo.HTTPError) error
6669

6770
// MultiErrorHandler is called when oapi returns a MultiError type
71+
//
6872
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#MultiErrorHandler
6973
type MultiErrorHandler func(openapi3.MultiError) *echo.HTTPError
7074

7175
// Options to customize request validation. These are passed through to
7276
// openapi3filter.
77+
//
7378
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#Options
7479
type Options struct {
7580
ErrorHandler ErrorHandler
@@ -83,6 +88,7 @@ type Options struct {
8388
}
8489

8590
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
91+
//
8692
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#OapiRequestValidatorWithOptions
8793
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) echo.MiddlewareFunc {
8894
if swagger.Servers != nil && (options == nil || !options.SilenceServersWarning) {
@@ -115,6 +121,7 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) echo
115121

116122
// ValidateRequestFromContext is called from the middleware above and actually does the work
117123
// of validating a request.
124+
//
118125
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#ValidateRequestFromContext
119126
func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options *Options) *echo.HTTPError {
120127
req := ctx.Request()
@@ -197,6 +204,7 @@ func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options
197204

198205
// GetEchoContext gets the echo context from within requests. It returns
199206
// nil if not found or wrong type.
207+
//
200208
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#GetEchoContext
201209
func GetEchoContext(c context.Context) echo.Context {
202210
iface := c.Value(EchoContextKey)
@@ -216,6 +224,7 @@ func GetUserData(c context.Context) interface{} {
216224
}
217225

218226
// attempt to get the skipper from the options whether it is set or not
227+
//
219228
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#getSkipperFromOptions
220229
func getSkipperFromOptions(options *Options) echomiddleware.Skipper {
221230
if options == nil {
@@ -247,6 +256,7 @@ func getMultiErrorHandlerFromOptions(options *Options) MultiErrorHandler {
247256
// defaultMultiErrorHandler returns a StatusBadRequest (400) and a list
248257
// of all of the errors. This method is called if there are no other
249258
// methods defined on the options.
259+
//
250260
// Deprecated: This has been replaced by github.com/oapi-codegen/echo-middleware#defaultMultiErrorHandler
251261
func defaultMultiErrorHandler(me openapi3.MultiError) *echo.HTTPError {
252262
return &echo.HTTPError{

0 commit comments

Comments
 (0)