openapi: generate
This commit is contained in:
@@ -102,74 +102,31 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "ScriptPolicyID"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'h': // Prefix: "hash/"
|
||||
origElem := elem
|
||||
if l := len("hash/"); len(elem) >= l && elem[0:l] == "hash/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "GET":
|
||||
s.handleGetScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "POST":
|
||||
s.handleUpdateScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,POST")
|
||||
}
|
||||
|
||||
// Param: "FromScriptHash"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetScriptPolicyFromHashRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
case 'i': // Prefix: "id/"
|
||||
origElem := elem
|
||||
if l := len("id/"); len(elem) >= l && elem[0:l] == "id/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "ScriptPolicyID"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "GET":
|
||||
s.handleGetScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "POST":
|
||||
s.handleUpdateScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
return
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
@@ -186,10 +143,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListScriptsRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "POST":
|
||||
s.handleCreateScriptRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "POST")
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
@@ -684,86 +643,41 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "ScriptPolicyID"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'h': // Prefix: "hash/"
|
||||
origElem := elem
|
||||
if l := len("hash/"); len(elem) >= l && elem[0:l] == "hash/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = DeleteScriptPolicyOperation
|
||||
r.summary = "Delete the specified script policy by ID"
|
||||
r.operationID = "deleteScriptPolicy"
|
||||
r.pathPattern = "/script-policy/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = GetScriptPolicyOperation
|
||||
r.summary = "Get the specified script policy by ID"
|
||||
r.operationID = "getScriptPolicy"
|
||||
r.pathPattern = "/script-policy/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = UpdateScriptPolicyOperation
|
||||
r.summary = "Update the specified script policy by ID"
|
||||
r.operationID = "updateScriptPolicy"
|
||||
r.pathPattern = "/script-policy/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
// Param: "FromScriptHash"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetScriptPolicyFromHashOperation
|
||||
r.summary = "Get the policy for the given hash of script source code"
|
||||
r.operationID = "getScriptPolicyFromHash"
|
||||
r.pathPattern = "/script-policy/hash/{FromScriptHash}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
case 'i': // Prefix: "id/"
|
||||
origElem := elem
|
||||
if l := len("id/"); len(elem) >= l && elem[0:l] == "id/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "ScriptPolicyID"
|
||||
// Leaf parameter
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = DeleteScriptPolicyOperation
|
||||
r.summary = "Delete the specified script policy by ID"
|
||||
r.operationID = "deleteScriptPolicy"
|
||||
r.pathPattern = "/script-policy/id/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = GetScriptPolicyOperation
|
||||
r.summary = "Get the specified script policy by ID"
|
||||
r.operationID = "getScriptPolicy"
|
||||
r.pathPattern = "/script-policy/id/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = UpdateScriptPolicyOperation
|
||||
r.summary = "Update the specified script policy by ID"
|
||||
r.operationID = "updateScriptPolicy"
|
||||
r.pathPattern = "/script-policy/id/{ScriptPolicyID}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
}
|
||||
|
||||
elem = origElem
|
||||
@@ -780,6 +694,14 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = ListScriptsOperation
|
||||
r.summary = "Get list of scripts"
|
||||
r.operationID = "listScripts"
|
||||
r.pathPattern = "/scripts"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = CreateScriptOperation
|
||||
r.summary = "Create a new script"
|
||||
|
||||
Reference in New Issue
Block a user