-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
BacklogPlaceholder for issues moved to backlogPlaceholder for issues moved to backlog
Description
It would be beneficial to move all the API input argument checks to the same location in endpoints.R.
Incorporate
pipapi/inst/plumber/v1/endpoints.R
Lines 15 to 25 in a14f5ed
| if (!is.null(req$argsQuery$version)) { | |
| if (!req$argsQuery$version %in% lkups$versions) { | |
| res$status <- 404 | |
| out <- list( | |
| error = "Invalid query arguments have been submitted.", | |
| details = list(msg = "You supplied an invalid value for version. Please use one of the valid values.", | |
| valid = lkups$versions)) | |
| return(out) | |
| #return("Invalid version has been submitted. Please check valid versions with /versions") | |
| } | |
| } |
together with
pipapi/inst/plumber/v1/endpoints.R
Lines 57 to 87 in a14f5ed
| if (req$QUERY_STRING != "" & !grepl("swagger", req$PATH_INFO)) { | |
| # STEP 1: Assign required parameters | |
| # Non-provided parameters are typically assigned the underlying function | |
| # arguments' default values. There is an exception to that however: | |
| # The `country` & `year` parameters cannot be NULL in order for to pass | |
| # the if condition that will decide whether or no the request should be | |
| # treated asynchronously. | |
| req <- pipapi:::assign_required_params(req) | |
| # STEP 2: Validate individual query parameters | |
| are_valid <- pipapi:::check_parameters(req, query_controls) | |
| if (any(are_valid == FALSE)) { | |
| res$status <- 404 | |
| invalid_params <- names(req$argsQuery)[!are_valid] | |
| out <- pipapi:::format_error(invalid_params, query_controls) | |
| return(out) | |
| } | |
| # STEP 3: Check for invalid combinations of query parameter values | |
| # Break if bad request | |
| endpoint <- pipapi:::extract_endpoint(req$PATH_INFO) | |
| if (endpoint == "pip-grp") { | |
| if (req$argsQuery$group_by != "none" && req$argsQuery$country != "all") { | |
| res$status <- 400 | |
| out <- list( | |
| error = "Invalid query arguments have been submitted.", | |
| details = list(msg = "You cannot query individual countries when specifying a predefined sub-group. Please use country=all") | |
| ) | |
| return(out) | |
| } | |
| } | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BacklogPlaceholder for issues moved to backlogPlaceholder for issues moved to backlog