Skip to content

Commit 2080cee

Browse files
committed
enhance: openapi3/modify: enhance SpecSetDeprecatedImplicit()
1 parent 0409be8 commit 2080cee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

openapi3/modify/deprecated.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ func SpecOperationsSetDeprecated(spec *oas3.Swagger, newDeprecated bool) {
2929
var rxDeprecated = regexp.MustCompile(`(?i)\bdeprecated\b`)
3030

3131
func SpecSetDeprecatedImplicit(spec *oas3.Swagger) {
32+
openapi3.VisitOperations(
33+
spec,
34+
func(path, method string, op *oas3.Operation) {
35+
if op != nil && rxDeprecated.MatchString(op.Description) {
36+
op.Deprecated = true
37+
}
38+
},
39+
)
3240
for _, schemaRef := range spec.Components.Schemas {
3341
if len(schemaRef.Ref) == 0 && schemaRef.Value != nil {
3442
if rxDeprecated.MatchString(schemaRef.Value.Description) {

0 commit comments

Comments
 (0)