You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by du...@apache.org on 2018/01/19 20:07:31 UTC
[incubator-openwhisk-client-go] branch master updated: Add path
param support (#56)
This is an automated email from the ASF dual-hosted git repository.
dubeejw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new a086445 Add path param support (#56)
a086445 is described below
commit a0864455f7c18db70d93d4dd2bc0b43d2334ed90
Author: Jesus Alva <ja...@us.ibm.com>
AuthorDate: Fri Jan 19 14:07:29 2018 -0600
Add path param support (#56)
* Changes to support parameters at the Path level, compatible with the v2.0 spec
* Removed comment as it is no longer valid and I dont think its needed as the object is no longer a map of maps
---
whisk/api.go | 44 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/whisk/api.go b/whisk/api.go
index 6d695a6..e62f2dc 100644
--- a/whisk/api.go
+++ b/whisk/api.go
@@ -146,13 +146,51 @@ type ApiSwagger struct {
SwaggerName string `json:"swagger,omitempty"`
BasePath string `json:"basePath,omitempty"`
Info *ApiSwaggerInfo `json:"info,omitempty"`
- Paths map[string]map[string]*ApiSwaggerOperation `json:"paths,omitempty"` // Paths["/a/path"]["get"] -> a generic object
+ Paths map[string]*ApiSwaggerPath `json:"paths,omitempty"`
SecurityDef interface{} `json:"securityDefinitions,omitempty"`
Security interface{} `json:"security,omitempty"`
XConfig interface{} `json:"x-ibm-configuration,omitempty"`
XRateLimit interface{} `json:"x-ibm-rate-limit,omitempty"`
}
+type ApiSwaggerPath struct{
+ Get *ApiSwaggerOperation `json:"get,omitempty"`
+ Put *ApiSwaggerOperation `json:"put,omitempty"`
+ Post *ApiSwaggerOperation `json:"post,omitempty"`
+ Delete *ApiSwaggerOperation `json:"delete,omitempty"`
+ Options *ApiSwaggerOperation `json:"options,omitempty"`
+ Head *ApiSwaggerOperation `json:"head,omitempty"`
+ Patch *ApiSwaggerOperation `json:"patch,omitempty"`
+ Parameters []ApiParameter `json:"parameters,omitempty"`
+}
+
+func (asp *ApiSwaggerPath) MakeOperationMap() map[string]*ApiSwaggerOperation {
+ var opMap map[string]*ApiSwaggerOperation = make(map[string]*ApiSwaggerOperation)
+ if asp.Get != nil {
+ opMap["get"] = asp.Get
+ }
+ if asp.Put != nil {
+ opMap["put"] = asp.Put
+ }
+ if asp.Post != nil {
+ opMap["post"] = asp.Post
+ }
+ if asp.Delete != nil {
+ opMap["delete"] = asp.Delete
+ }
+ if asp.Options != nil {
+ opMap["options"] = asp.Options
+ }
+ if asp.Head != nil {
+ opMap["head"] = asp.Head
+ }
+ if asp.Patch != nil {
+ opMap["patch"] = asp.Patch
+ }
+ return opMap
+}
+
+
type ApiSwaggerInfo struct {
Title string `json:"title,omitempty"`
Version string `json:"version,omitempty"`
@@ -463,8 +501,8 @@ func validateApiSwaggerResponse(swagger *ApiSwagger) error {
return nil
}
-func validateApiPath(path map[string]*ApiSwaggerOperation) error {
- for op, opv := range path {
+func validateApiPath(path *ApiSwaggerPath) error {
+ for op, opv := range path.MakeOperationMap() {
err := validateApiOperation(op, opv)
if err != nil {
Debug(DbgError, "validateApiPath: Invalid Api operation object: %v\n", opv)
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].