Skip to content

Commit

Permalink
Merge pull request #138 from danielgtaylor/deprecated
Browse files Browse the repository at this point in the history
feat: mark & hide deprecated operations
  • Loading branch information
danielgtaylor committed Nov 3, 2022
2 parents 0d2eae2 + 3cde380 commit e054065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cli/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Operation struct {
BodyMediaType string `json:"bodyMediaType,omitempty"`
Examples []string `json:"examples,omitempty"`
Hidden bool `json:"hidden,omitempty"`
Deprecated string `json:"deprecated,omitempty"`
}

// command returns a Cobra command instance for this operation.
Expand All @@ -52,14 +53,15 @@ func (o Operation) command() *cobra.Command {
}

sub := &cobra.Command{
Use: use,
GroupID: o.Group,
Aliases: o.Aliases,
Short: o.Short,
Long: long,
Example: examples,
Args: argSpec,
Hidden: o.Hidden,
Use: use,
GroupID: o.Group,
Aliases: o.Aliases,
Short: o.Short,
Long: long,
Example: examples,
Args: argSpec,
Hidden: o.Hidden,
Deprecated: o.Deprecated,
Run: func(cmd *cobra.Command, args []string) {
uri := o.URITemplate

Expand Down
6 changes: 6 additions & 0 deletions openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ func openapiOperation(cmd *cobra.Command, method string, uriTemplate *url.URL, p
group = op.Tags[0]
}

dep := ""
if op.Deprecated {
dep = "do not use"
}

return cli.Operation{
Name: name,
Group: group,
Expand All @@ -354,6 +359,7 @@ func openapiOperation(cmd *cobra.Command, method string, uriTemplate *url.URL, p
BodyMediaType: mediaType,
Examples: examples,
Hidden: hidden,
Deprecated: dep,
}
}

Expand Down

0 comments on commit e054065

Please sign in to comment.