Distinguish LIST-only paths in OpenAPI (#13643)

* Distinguish LIST-only paths in OpenAPI

* add changelog

* Put enum field inside schema
This commit is contained in:
VAL
2022-01-18 09:21:44 -08:00
committed by GitHub
parent 417452fb1b
commit 1bc8fb0cf3
4 changed files with 138 additions and 3 deletions

View File

@@ -368,8 +368,18 @@ func documentPath(p *Path, specialPaths *logical.Paths, backendType logical.Back
}
}
// LIST is represented as GET with a `list` query parameter
if opType == logical.ListOperation || (opType == logical.ReadOperation && operations[logical.ListOperation] != nil) {
// LIST is represented as GET with a `list` query parameter.
if opType == logical.ListOperation {
// Only accepts List (due to the above skipping of ListOperations that also have ReadOperations)
op.Parameters = append(op.Parameters, OASParameter{
Name: "list",
Description: "Must be set to `true`",
Required: true,
In: "query",
Schema: &OASSchema{Type: "string", Enum: []interface{}{"true"}},
})
} else if opType == logical.ReadOperation && operations[logical.ListOperation] != nil {
// Accepts both Read and List
op.Parameters = append(op.Parameters, OASParameter{
Name: "list",
Description: "Return a list if `true`",