Skip to content

Commit

Permalink
Add a distinguishing prefix to OpenAPI operation IDs for enterprise s…
Browse files Browse the repository at this point in the history
…tubs (#22072)

* Add a distinguishing prefix to OpenAPI operation IDs for enterprise stubs

As discussed in hashicorp/vault-client-go#208

* Dropping system from operation IDs per PR feedback.
  • Loading branch information
maxb authored Jul 27, 2023
1 parent 0268d9d commit efa76db
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions vault/logical_system_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ var (
Pattern: pattern,
Operations: make(map[logical.Operation]framework.OperationHandler),
Fields: make(map[string]*framework.FieldSchema),
DisplayAttrs: &framework.DisplayAttributes{
// Since we lack full information for Fields, and all information for Responses, the generated
// OpenAPI won't be good for much other than identifying the endpoint exists at all. Thus, it
// is useful to make it clear that this is only a stub. Code generation will use this to ignore
// these operations.
OperationPrefix: "enterprise-stub",
},
}

for _, parameter := range pathSpec.parameters {
Expand Down Expand Up @@ -172,14 +179,20 @@ var (
// This path, though an enterprise path, has always been handled in OSS.
paths = append(paths, &framework.Path{
Pattern: "replication/status",
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
resp := &logical.Response{
Data: map[string]interface{}{
"mode": "disabled",
},
}
return resp, nil
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
resp := &logical.Response{
Data: map[string]interface{}{
"mode": "disabled",
},
}
return resp, nil
},
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "read",
OperationSuffix: "replication-status",
},
},
},
})
Expand Down

0 comments on commit efa76db

Please sign in to comment.