From efa76db05abba080583735e1ce5833a417baba12 Mon Sep 17 00:00:00 2001 From: Max Bowsher Date: Thu, 27 Jul 2023 01:43:19 +0100 Subject: [PATCH] Add a distinguishing prefix to OpenAPI operation IDs for enterprise stubs (#22072) * Add a distinguishing prefix to OpenAPI operation IDs for enterprise stubs As discussed in https://github.com/hashicorp/vault-client-go/issues/208 * Dropping system from operation IDs per PR feedback. --- vault/logical_system_helpers.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/vault/logical_system_helpers.go b/vault/logical_system_helpers.go index 057765a80d96..a175b86b25b3 100644 --- a/vault/logical_system_helpers.go +++ b/vault/logical_system_helpers.go @@ -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 { @@ -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", + }, }, }, })