mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
Change OpenAPI code generator to extract request objects (#14217)
This commit is contained in:
committed by
GitHub
parent
ef8ce03e70
commit
dcb5942bd1
@@ -198,7 +198,7 @@ func (b *Backend) HandleRequest(ctx context.Context, req *logical.Request) (*log
|
||||
|
||||
// If the path is empty and it is a help operation, handle that.
|
||||
if req.Path == "" && req.Operation == logical.HelpOperation {
|
||||
return b.handleRootHelp()
|
||||
return b.handleRootHelp(req)
|
||||
}
|
||||
|
||||
// Find the matching route
|
||||
@@ -457,7 +457,7 @@ func (b *Backend) route(path string) (*Path, map[string]string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *Backend) handleRootHelp() (*logical.Response, error) {
|
||||
func (b *Backend) handleRootHelp(req *logical.Request) (*logical.Response, error) {
|
||||
// Build a mapping of the paths and get the paths alphabetized to
|
||||
// make the output prettier.
|
||||
pathsMap := make(map[string]*Path)
|
||||
@@ -486,9 +486,18 @@ func (b *Backend) handleRootHelp() (*logical.Response, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Plugins currently don't have a direct knowledge of their own "type"
|
||||
// (e.g. "kv", "cubbyhole"). It defaults to the name of the executable but
|
||||
// can be overridden when the plugin is mounted. Since we need this type to
|
||||
// form the request & response full names, we are passing it as an optional
|
||||
// request parameter to the plugin's root help endpoint. If specified in
|
||||
// the request, the type will be used as part of the request/response body
|
||||
// names in the OAS document.
|
||||
requestResponsePrefix := req.GetString("requestResponsePrefix")
|
||||
|
||||
// Build OpenAPI response for the entire backend
|
||||
doc := NewOASDocument()
|
||||
if err := documentPaths(b, doc); err != nil {
|
||||
if err := documentPaths(b, requestResponsePrefix, doc); err != nil {
|
||||
b.Logger().Warn("error generating OpenAPI", "error", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user