func validateApiOperation()

in whisk/api.go [514:548]


func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
	if op.XOpenWhisk != nil && len(op.OperationId) == 0 {
		Debug(DbgError, "validateApiOperation: No operationId field in operation %v\n", op)
		errMsg := wski18n.T("Missing operationId field in API configuration for operation {{.op}}",
			map[string]interface{}{"op": opName})
		whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
		return whiskErr
	}

	if op.XOpenWhisk != nil && len(op.XOpenWhisk.Namespace) == 0 {
		Debug(DbgError, "validateApiOperation: no x-openwhisk.namespace stanza in operation %v\n", op)
		errMsg := wski18n.T("Missing x-openwhisk.namespace field in API configuration for operation {{.op}}",
			map[string]interface{}{"op": opName})
		whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
		return whiskErr
	}

	// Note: The op.XOpenWhisk.Package field can have a value of "", so don't enforce a value

	if op.XOpenWhisk != nil && len(op.XOpenWhisk.ActionName) == 0 {
		Debug(DbgError, "validateApiOperation: no x-openwhisk.action stanza in operation %v\n", op)
		errMsg := wski18n.T("Missing x-openwhisk.action field in API configuration for operation {{.op}}",
			map[string]interface{}{"op": opName})
		whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
		return whiskErr
	}
	if op.XOpenWhisk != nil && len(op.XOpenWhisk.ApiUrl) == 0 {
		Debug(DbgError, "validateApiOperation: no x-openwhisk.url stanza in operation %v\n", op)
		errMsg := wski18n.T("Missing x-openwhisk.url field in API configuration for operation {{.op}}",
			map[string]interface{}{"op": opName})
		whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
		return whiskErr
	}
	return nil
}