diff --git a/DESCRIPTION b/DESCRIPTION index 0d91438..9665da3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,8 +29,7 @@ Imports: Suggests: testthat (>= 3.0.0) Remotes: - jonthegeek/stbl, - RConsortium/S7 + jonthegeek/stbl Config/testthat/edition: 3 Config/testthat/parallel: true Encoding: UTF-8 @@ -38,9 +37,9 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Collate: 'properties.R' - 'security_requirements.R' + 'security.R' 'components-security_scheme_details.R' - 'components-security_scheme_collection.R' + 'components-security_schemes.R' 'components.R' 'servers-server_variables.R' 'servers-string_replacements.R' diff --git a/NAMESPACE b/NAMESPACE index 776a200..4e1019f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,8 @@ # Generated by roxygen2: do not edit by hand -export(api_key_security_scheme) export(as_api_key_security_scheme) export(as_api_object) -export(as_component_collection) +export(as_components) export(as_contact) export(as_info) export(as_license) @@ -14,33 +13,34 @@ export(as_oauth2_token_flow) export(as_origin) export(as_rapid) export(as_scopes) -export(as_security_requirements) +export(as_security) export(as_security_scheme) -export(as_security_scheme_collection) export(as_security_scheme_details) +export(as_security_schemes) export(as_server_variables) export(as_servers) export(as_string_replacements) export(caller_arg) export(caller_env) +export(class_api_key_security_scheme) +export(class_components) +export(class_contact) +export(class_info) +export(class_license) +export(class_oauth2_authorization_code_flow) +export(class_oauth2_implicit_flow) +export(class_oauth2_security_scheme) +export(class_oauth2_token_flow) export(class_origin) -export(component_collection) -export(contact) +export(class_rapid) +export(class_scopes) +export(class_security) +export(class_security_scheme_details) +export(class_security_schemes) +export(class_server_variables) +export(class_servers) +export(class_string_replacements) export(expand_servers) -export(info) -export(license) -export(oauth2_authorization_code_flow) -export(oauth2_implicit_flow) -export(oauth2_security_scheme) -export(oauth2_token_flow) -export(rapid) -export(scopes) -export(security_requirements) -export(security_scheme_collection) -export(security_scheme_details) -export(server_variables) -export(servers) -export(string_replacements) if (getRversion() < "4.3.0") importFrom("S7", "@") importFrom(S7,"prop<-") importFrom(S7,class_any) diff --git a/R/absolute_paths.R b/R/absolute_paths.R index 92b072b..7d0ad31 100644 --- a/R/absolute_paths.R +++ b/R/absolute_paths.R @@ -10,12 +10,12 @@ NULL #' @inheritParams rlang::args_dots_empty #' @param x The object to update. Must be a `rapid`. #' -#' @return A `rapid` object as returned by [rapid()], with absolute server +#' @return A `rapid` object as returned by [class_rapid()], with absolute server #' paths. #' @export expand_servers <- S7::new_generic("expand_servers", "x") -S7::method(expand_servers, rapid) <- function(x) { +S7::method(expand_servers, class_rapid) <- function(x) { if (length(x@servers@url)) { relative_servers <- .is_relative_url(x@servers@url) origin_url <- x@info@origin@url diff --git a/R/components-security_scheme-api_key.R b/R/components-security_scheme-api_key.R index 2a49f91..a6425e8 100644 --- a/R/components-security_scheme-api_key.R +++ b/R/components-security_scheme-api_key.R @@ -16,14 +16,14 @@ NULL #' @export #' #' @examples -#' api_key_security_scheme( +#' class_api_key_security_scheme( #' parameter_name = "Authorization", #' location = "header" #' ) -api_key_security_scheme <- S7::new_class( +class_api_key_security_scheme <- S7::new_class( name = "api_key_security_scheme", package = "rapid", - parent = security_scheme, + parent = abstract_security_scheme, properties = list( parameter_name = character_scalar_property("parameter_name"), location = character_scalar_property("location") @@ -49,7 +49,7 @@ api_key_security_scheme <- S7::new_class( } ) -S7::method(length, api_key_security_scheme) <- function(x) { +S7::method(length, class_api_key_security_scheme) <- function(x) { length(x@parameter_name) } @@ -57,8 +57,8 @@ S7::method(length, api_key_security_scheme) <- function(x) { #' #' `as_api_key_security_scheme()` turns an existing object into an #' `api_key_security_scheme`. This is in contrast with -#' [api_key_security_scheme()], which builds an `api_key_security_scheme` from -#' individual properties. +#' [class_api_key_security_scheme()], which builds an `api_key_security_scheme` +#' from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -68,7 +68,7 @@ S7::method(length, api_key_security_scheme) <- function(x) { #' are ignored. #' #' @return An `api_key_security_scheme` as returned by -#' [api_key_security_scheme()]. +#' [class_api_key_security_scheme()]. #' @export as_api_key_security_scheme <- function(x, ..., @@ -76,7 +76,7 @@ as_api_key_security_scheme <- function(x, call = caller_env()) { as_api_object( x, - api_key_security_scheme, + class_api_key_security_scheme, ..., alternate_names = c("in" = "location", "name" = "parameter_name"), arg = arg, diff --git a/R/components-security_scheme-oauth2-authorization_code_flow.R b/R/components-security_scheme-oauth2-authorization_code_flow.R index f431761..2332f08 100644 --- a/R/components-security_scheme-oauth2-authorization_code_flow.R +++ b/R/components-security_scheme-oauth2-authorization_code_flow.R @@ -7,26 +7,26 @@ NULL #' the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI #' 2.0. #' -#' @inheritParams oauth2_flow +#' @inheritParams abstract_oauth2_flow #' @inheritParams rlang::args_dots_empty -#' @inheritParams oauth2_implicit_flow -#' @inheritParams oauth2_token_flow +#' @inheritParams class_oauth2_implicit_flow +#' @inheritParams class_oauth2_token_flow #' #' @export #' @examples -#' oauth2_authorization_code_flow( +#' class_oauth2_authorization_code_flow( #' authorization_url = "https://example.com/authorize", #' token_url = "https://example.com/token", #' refresh_url = "https://example.com/refresh", -#' scopes = scopes( +#' scopes = class_scopes( #' name = c("server:read", "server:write"), #' description = c("Read server settings", "Write server settings") #' ) #' ) -oauth2_authorization_code_flow <- S7::new_class( +class_oauth2_authorization_code_flow <- S7::new_class( name = "oauth2_authorization_code_flow", package = "rapid", - parent = oauth2_flow, + parent = abstract_oauth2_flow, properties = list( authorization_url = character_scalar_property("authorization_url"), token_url = character_scalar_property("token_url") @@ -35,7 +35,7 @@ oauth2_authorization_code_flow <- S7::new_class( token_url = character(), ..., refresh_url = character(), - scopes = character()) { + scopes = class_scopes()) { check_dots_empty() S7::new_object( S7::S7_object(), @@ -56,7 +56,7 @@ oauth2_authorization_code_flow <- S7::new_class( } ) -S7::method(length, oauth2_authorization_code_flow) <- function(x) { +S7::method(length, class_oauth2_authorization_code_flow) <- function(x) { length(x@authorization_url) } @@ -64,7 +64,7 @@ S7::method(length, oauth2_authorization_code_flow) <- function(x) { #' #' `as_oauth2_authorization_code_flow()` turns an existing object into an #' `oauth2_authorization_code_flow`. This is in contrast with -#' [oauth2_authorization_code_flow()], which builds an +#' [class_oauth2_authorization_code_flow()], which builds an #' `oauth2_authorization_code_flow` from individual properties. #' #' @inheritParams rlang::args_dots_empty @@ -75,11 +75,11 @@ S7::method(length, oauth2_authorization_code_flow) <- function(x) { #' [snakecase::to_snake_case()]. Additional names are ignored. #' #' @return An `oauth2_authorization_code_flow` as returned by -#' [oauth2_authorization_code_flow()]. +#' [class_oauth2_authorization_code_flow()]. #' @export as_oauth2_authorization_code_flow <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, oauth2_authorization_code_flow, ..., arg = arg, call = call) + as_api_object(x, class_oauth2_authorization_code_flow, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme-oauth2-flow.R b/R/components-security_scheme-oauth2-flow.R index e3f638f..80f91d4 100644 --- a/R/components-security_scheme-oauth2-flow.R +++ b/R/components-security_scheme-oauth2-flow.R @@ -10,18 +10,18 @@ NULL #' @param refresh_url Character scalar (optional). The URL to be used for #' obtaining refresh tokens. This must be in the form of a URL. The OAuth2 #' standard requires the use of TLS. -#' @param scopes An optional [scopes()] object with the available scopes for the -#' OAuth2 security scheme. +#' @param scopes An optional [class_scopes()] object with the available scopes +#' for the OAuth2 security scheme. #' #' @keywords internal -#' @seealso [oauth2_token_flow()], [oauth2_implicit_flow()], and -#' [oauth2_authorization_code_flow()] -oauth2_flow <- S7::new_class( +#' @seealso [class_oauth2_token_flow()], [class_oauth2_implicit_flow()], and +#' [class_oauth2_authorization_code_flow()] +abstract_oauth2_flow <- S7::new_class( name = "oauth2_flow", package = "rapid", properties = list( refresh_url = character_scalar_property("refresh_url"), - scopes = scopes + scopes = class_scopes ), abstract = TRUE ) diff --git a/R/components-security_scheme-oauth2-implicit_flow.R b/R/components-security_scheme-oauth2-implicit_flow.R index dbedcc6..620955a 100644 --- a/R/components-security_scheme-oauth2-implicit_flow.R +++ b/R/components-security_scheme-oauth2-implicit_flow.R @@ -6,7 +6,7 @@ NULL #' An `oauth2_implicit_flow` object describes the configuration for the OAuth #' Implicit flow. #' -#' @inheritParams oauth2_flow +#' @inheritParams abstract_oauth2_flow #' @inheritParams rlang::args_dots_empty #' @param authorization_url Character vector (required). The authorization URL #' to be used for this flow. This must be in the form of a URL. The OAuth2 @@ -14,21 +14,21 @@ NULL #' #' @export #' @examples -#' oauth2_implicit_flow( +#' class_oauth2_implicit_flow( #' authorization_url = "https://example.com/authorize", #' refresh_url = "https://example.com/refresh" #' ) -oauth2_implicit_flow <- S7::new_class( +class_oauth2_implicit_flow <- S7::new_class( name = "oauth2_implicit_flow", package = "rapid", - parent = oauth2_flow, + parent = abstract_oauth2_flow, properties = list( authorization_url = character_scalar_property("authorization_url") ), constructor = function(authorization_url = character(), ..., refresh_url = character(), - scopes = character()) { + scopes = class_scopes()) { check_dots_empty() S7::new_object( S7::S7_object(), @@ -47,14 +47,14 @@ oauth2_implicit_flow <- S7::new_class( } ) -S7::method(length, oauth2_implicit_flow) <- function(x) { +S7::method(length, class_oauth2_implicit_flow) <- function(x) { length(x@authorization_url) } #' Coerce lists and character vectors to OAuth2 implicit flows #' #' `as_oauth2_implicit_flow()` turns an existing object into an -#' `oauth2_implicit_flow`. This is in contrast with [oauth2_implicit_flow()], +#' `oauth2_implicit_flow`. This is in contrast with [class_oauth2_implicit_flow()], #' which builds an `oauth2_implicit_flow` from individual properties. #' #' @inheritParams rlang::args_dots_empty @@ -64,11 +64,11 @@ S7::method(length, oauth2_implicit_flow) <- function(x) { #' names that can be coerced to those names via [snakecase::to_snake_case()]. #' Additional names are ignored. #' -#' @return An `oauth2_implicit_flow` as returned by [oauth2_implicit_flow()]. +#' @return An `oauth2_implicit_flow` as returned by [class_oauth2_implicit_flow()]. #' @export as_oauth2_implicit_flow <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, oauth2_implicit_flow, ..., arg = arg, call = call) + as_api_object(x, class_oauth2_implicit_flow, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme-oauth2-scopes.R b/R/components-security_scheme-oauth2-scopes.R index c1564fe..65be87d 100644 --- a/R/components-security_scheme-oauth2-scopes.R +++ b/R/components-security_scheme-oauth2-scopes.R @@ -10,7 +10,7 @@ #' @seealso [as_scopes()] for coercing objects to `scopes`. #' @export #' @examples -#' scopes( +#' class_scopes( #' name = c( #' "https://www.googleapis.com/auth/youtube", #' "https://www.googleapis.com/auth/youtube.channel-memberships.creator", @@ -30,7 +30,7 @@ #' "View private information of your YouTube channel" #' ) #' ) -scopes <- S7::new_class( +class_scopes <- S7::new_class( name = "scopes", package = "rapid", properties = list( @@ -54,20 +54,20 @@ scopes <- S7::new_class( } ) -S7::method(length, scopes) <- function(x) { +S7::method(length, class_scopes) <- function(x) { length(x@name) } #' Coerce lists and character vectors to scopes #' #' `as_scopes()` turns an existing object into a `scopes`. This is in contrast -#' with [scopes()], which builds a `scopes` from individual properties. +#' with [class_scopes()], which builds a `scopes` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context #' @param x The object to coerce. Must be coercible to a named character vector. #' -#' @return A `scopes` as returned by [scopes()]. +#' @return A `scopes` as returned by [class_scopes()]. #' @export as_scopes <- S7::new_generic("as_scopes", "x") @@ -84,7 +84,7 @@ S7::method( call = call ) } - scopes( + class_scopes( name = names(x), description = unname(x) ) @@ -94,5 +94,5 @@ S7::method(as_scopes, class_any) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, scopes, ..., arg = arg, call = call) + as_api_object(x, class_scopes, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme-oauth2-token_flow.R b/R/components-security_scheme-oauth2-token_flow.R index 51a7c88..5f69f4b 100644 --- a/R/components-security_scheme-oauth2-token_flow.R +++ b/R/components-security_scheme-oauth2-token_flow.R @@ -7,7 +7,7 @@ NULL #' Resource Owner Password flow or the OAuth Client Credentials flow (previously #' called application in OpenAPI 2.0). #' -#' @inheritParams oauth2_flow +#' @inheritParams abstract_oauth2_flow #' @inheritParams rlang::args_dots_empty #' @param token_url Character vector (required). The token URL to be used for #' this flow. This must be in the form of a URL. The OAuth2 standard requires @@ -17,25 +17,25 @@ NULL #' #' @export #' @examples -#' oauth2_token_flow( +#' class_oauth2_token_flow( #' token_url = "https://example.com/token", #' refresh_url = "https://example.com/refresh", -#' scopes = scopes( +#' scopes = class_scopes( #' name = c("server:read", "server:write"), #' description = c("Read server settings", "Write server settings") #' ) #' ) -oauth2_token_flow <- S7::new_class( +class_oauth2_token_flow <- S7::new_class( name = "oauth2_token_flow", package = "rapid", - parent = oauth2_flow, + parent = abstract_oauth2_flow, properties = list( token_url = class_character ), constructor = function(token_url = character(), ..., refresh_url = character(), - scopes = character()) { + scopes = class_scopes()) { check_dots_empty() S7::new_object( S7::S7_object(), @@ -54,14 +54,14 @@ oauth2_token_flow <- S7::new_class( } ) -S7::method(length, oauth2_token_flow) <- function(x) { +S7::method(length, class_oauth2_token_flow) <- function(x) { length(x@token_url) } #' Coerce lists and character vectors to OAuth2 token flows #' #' `as_oauth2_token_flow()` turns an existing object into an -#' `oauth2_token_flow`. This is in contrast with [oauth2_token_flow()], which +#' `oauth2_token_flow`. This is in contrast with [class_oauth2_token_flow()], which #' builds an `oauth2_token_flow` from individual properties. #' #' @inheritParams rlang::args_dots_empty @@ -71,11 +71,11 @@ S7::method(length, oauth2_token_flow) <- function(x) { #' can be coerced to those names via [snakecase::to_snake_case()]. Additional #' names are ignored. #' -#' @return An `oauth2_token_flow` as returned by [oauth2_token_flow()]. +#' @return An `oauth2_token_flow` as returned by [class_oauth2_token_flow()]. #' @export as_oauth2_token_flow <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, oauth2_token_flow, ..., arg = arg, call = call) + as_api_object(x, class_oauth2_token_flow, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme-oauth2.R b/R/components-security_scheme-oauth2.R index a6c48ad..faaa046 100644 --- a/R/components-security_scheme-oauth2.R +++ b/R/components-security_scheme-oauth2.R @@ -10,38 +10,36 @@ NULL #' #' @inheritParams rlang::args_dots_empty #' @param implicit_flow An `oauth2_implicit_flow` object created with -#' [oauth2_implicit_flow()]. -#' @param password_flow An `oauth2_token_flow` object created with -#' [oauth2_token_flow()]. -#' @param client_credentials_flow An `oauth2_token_flow` object created with -#' [oauth2_token_flow()]. +#' [class_oauth2_implicit_flow()]. +#' @param password_flow,client_credentials_flow An `oauth2_token_flow` object created with +#' [class_oauth2_token_flow()]. #' @param authorization_code_flow An `oauth2_authorization_code_flow` object -#' created with [oauth2_authorization_code_flow()]. +#' created with [class_oauth2_authorization_code_flow()]. #' #' @return An `oauth2_security_scheme` S7 object, with fields `implicit_flow`, #' `password_flow`, `client_credentials_flow`, and `authorization_code_flow`. #' @export #' #' @examples -#' oauth2_security_scheme() -#' oauth2_security_scheme( -#' password_flow = oauth2_token_flow(token_url = "/tokens/passwords") +#' class_oauth2_security_scheme() +#' class_oauth2_security_scheme( +#' password_flow = class_oauth2_token_flow(token_url = "/tokens/passwords") #' ) -oauth2_security_scheme <- S7::new_class( +class_oauth2_security_scheme <- S7::new_class( name = "oauth2_security_scheme", package = "rapid", - parent = security_scheme, + parent = abstract_security_scheme, properties = list( - implicit_flow = oauth2_implicit_flow, - password_flow = oauth2_token_flow, - client_credentials_flow = oauth2_token_flow, - authorization_code_flow = oauth2_authorization_code_flow + implicit_flow = class_oauth2_implicit_flow, + password_flow = class_oauth2_token_flow, + client_credentials_flow = class_oauth2_token_flow, + authorization_code_flow = class_oauth2_authorization_code_flow ), constructor = function(..., - implicit_flow = oauth2_implicit_flow(), - password_flow = oauth2_token_flow(), - client_credentials_flow = oauth2_token_flow(), - authorization_code_flow = oauth2_authorization_code_flow()) { + implicit_flow = class_oauth2_implicit_flow(), + password_flow = class_oauth2_token_flow(), + client_credentials_flow = class_oauth2_token_flow(), + authorization_code_flow = class_oauth2_authorization_code_flow()) { check_dots_empty() S7::new_object( S7::S7_object(), @@ -55,7 +53,7 @@ oauth2_security_scheme <- S7::new_class( } ) -S7::method(length, oauth2_security_scheme) <- function(x) { +S7::method(length, class_oauth2_security_scheme) <- function(x) { max(lengths(S7::props(x))) } @@ -63,8 +61,8 @@ S7::method(length, oauth2_security_scheme) <- function(x) { #' #' `as_oauth2_security_scheme()` turns an existing object into an #' `oauth2_security_scheme`. This is in contrast with -#' [oauth2_security_scheme()], which builds an `oauth2_security_scheme` from -#' individual properties. +#' [class_oauth2_security_scheme()], which builds an `oauth2_security_scheme` +#' from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -73,7 +71,7 @@ S7::method(length, oauth2_security_scheme) <- function(x) { #' [snakecase::to_snake_case()]. Additional names are ignored. #' #' @return An `oauth2_security_scheme` as returned by -#' [oauth2_security_scheme()]. +#' [class_oauth2_security_scheme()]. #' @export as_oauth2_security_scheme <- S7::new_generic("as_oauth2_security_scheme", "x") @@ -83,7 +81,7 @@ S7::method( ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { force(arg) if (!length(x) || !any(lengths(x))) { - return(oauth2_security_scheme()) + return(class_oauth2_security_scheme()) } if (!("flows" %in% names(x))) { @@ -93,7 +91,7 @@ S7::method( ) } names(x$flows) <- snakecase::to_snake_case(names(x$flows)) - oauth2_security_scheme( + class_oauth2_security_scheme( implicit_flow = x$flows[["implicit"]], password_flow = x$flows[["password"]], client_credentials_flow = x$flows[["client_credentials"]], @@ -105,5 +103,5 @@ S7::method( as_oauth2_security_scheme, class_any ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, oauth2_security_scheme, ..., arg = arg, call = call) + as_api_object(x, class_oauth2_security_scheme, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme.R b/R/components-security_scheme.R index e51d3ca..d53a8a0 100644 --- a/R/components-security_scheme.R +++ b/R/components-security_scheme.R @@ -4,8 +4,8 @@ #' schemes. #' #' @keywords internal -#' @seealso [api_key_security_scheme()], [oauth2_security_scheme()] -security_scheme <- S7::new_class( +#' @seealso [class_api_key_security_scheme()], [class_oauth2_security_scheme()] +abstract_security_scheme <- S7::new_class( name = "security_scheme", package = "rapid", abstract = TRUE @@ -24,8 +24,8 @@ security_scheme <- S7::new_class( #' [snakecase::to_snake_case()], and then must be one of "api_key", "oauth2", #' or "oauth_2". #' -#' @return A `security_scheme` object as returned by [api_key_security_scheme()] -#' or [oauth2_security_scheme()]. +#' @return A `security_scheme` object as returned by +#' [class_api_key_security_scheme()] or [class_oauth2_security_scheme()]. #' @export #' #' @examples @@ -70,7 +70,7 @@ security_scheme <- S7::new_class( #' ) as_security_scheme <- S7::new_generic("as_security_scheme", "x") -S7::method(as_security_scheme, security_scheme) <- function(x, ...) { +S7::method(as_security_scheme, abstract_security_scheme) <- function(x, ...) { x } diff --git a/R/components-security_scheme_details.R b/R/components-security_scheme_details.R index b74657e..d2ee65c 100644 --- a/R/components-security_scheme_details.R +++ b/R/components-security_scheme_details.R @@ -1,23 +1,24 @@ #' Details of API security schemes #' #' The object provides a list of details of security schemes for the API. Each -#' element within the list is a +#' element within the list is a [abstract_security_scheme()] object. #' -#' @param ... One or more [security_scheme()] objects or a list of such objects. -#' These objects must be generated by [api_key_security_scheme()] or -#' [oauth2_security_scheme()] (`http_security_scheme()` and -#' `open_id_connect_security_scheme()` coming soon). +#' @param ... One or more [abstract_security_scheme()] objects or a list of such +#' objects. These objects must be generated by +#' [class_api_key_security_scheme()] or [class_oauth2_security_scheme()] +#' (`http_security_scheme()` and `open_id_connect_security_scheme()` coming +#' soon). #' -#' @return A [security_scheme_details()] object, which is a validated list of -#' [security_scheme()] objects. +#' @return A `security_scheme_details` object, which is a validated list of +#' [abstract_security_scheme()] objects. #' @export #' #' @examples -#' security_scheme_details( -#' oauth2_security_scheme( -#' password_flow = oauth2_token_flow( +#' class_security_scheme_details( +#' class_oauth2_security_scheme( +#' password_flow = class_oauth2_token_flow( #' token_url = "/account/authorization", -#' scopes = scopes( +#' scopes = class_scopes( #' name = c("Catalog", "Commerce", "Playback", "Settings"), #' description = c( #' "Access all read-only content", @@ -28,25 +29,25 @@ #' ) #' ) #' ), -#' oauth2_security_scheme( -#' password_flow = oauth2_token_flow( +#' class_oauth2_security_scheme( +#' password_flow = class_oauth2_token_flow( #' token_url = "/account/profile/authorization", -#' scopes = scopes( +#' scopes = class_scopes( #' name = "Catalog", #' description = "Modify profile preferences and activity" #' ) #' ) #' ), -#' api_key_security_scheme( +#' class_api_key_security_scheme( #' parameter_name = "authorization", #' location = "header" #' ), -#' api_key_security_scheme( +#' class_api_key_security_scheme( #' parameter_name = "authorization", #' location = "header" #' ) #' ) -security_scheme_details <- S7::new_class( +class_security_scheme_details <- S7::new_class( "security_scheme_details", package = "rapid", parent = class_list, @@ -59,7 +60,7 @@ security_scheme_details <- S7::new_class( validator = function(self) { bad_security_schemes <- !purrr::map_lgl( S7::S7_data(self), - ~ S7::S7_inherits(.x, security_scheme) || is.null(.x) + ~ S7::S7_inherits(.x, abstract_security_scheme) || is.null(.x) ) if (any(bad_security_schemes)) { bad_locations <- which(bad_security_schemes) @@ -77,8 +78,8 @@ security_scheme_details <- S7::new_class( #' #' `as_security_scheme_details()` turns an existing object into a #' `security_scheme_details` object. This is in contrast with -#' [security_scheme_details()], which builds a `security_scheme_details` from -#' individual properties. +#' [class_security_scheme_details()], which builds a `security_scheme_details` +#' from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -87,7 +88,7 @@ security_scheme_details <- S7::new_class( #' security schemes for a single API. #' #' @return A `security_scheme_details` object as returned by -#' [security_scheme_details()]. +#' [class_security_scheme_details()]. #' @export #' #' @examples @@ -140,9 +141,9 @@ S7::method( class_list ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { if (!length(x) || !any(lengths(x))) { - return(security_scheme_details()) + return(class_security_scheme_details()) } - security_scheme_details( + class_security_scheme_details( purrr::map( unname(x), function(x) { @@ -156,5 +157,5 @@ S7::method( as_security_scheme_details, class_any ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, security_scheme_details, ..., arg = arg, call = call) + as_api_object(x, class_security_scheme_details, ..., arg = arg, call = call) } diff --git a/R/components-security_scheme_collection.R b/R/components-security_schemes.R similarity index 74% rename from R/components-security_scheme_collection.R rename to R/components-security_schemes.R index d1d00cf..2eebd15 100644 --- a/R/components-security_scheme_collection.R +++ b/R/components-security_schemes.R @@ -11,26 +11,26 @@ NULL #' @param name Character vector (required). Names by which security schemes will #' be referenced. #' @param details The details of each security scheme, as a -#' [security_scheme_details()] object. +#' [class_security_scheme_details()] object. #' @param description Character vector (optional). A short description for the #' security schemes. [CommonMark syntax](https://spec.commonmark.org/) may be #' used for rich text representation. #' -#' @return A `security_scheme_collection` S7 object with details about security -#' available for operations. +#' @return A `security_schemes` S7 object with details about security available +#' for operations. #' @export #' @examples -#' security_scheme_collection() -#' security_scheme_collection( +#' class_security_schemes() +#' class_security_schemes( #' name = c( #' "accountAuth", #' "resetPasswordAuth" #' ), -#' details = security_scheme_details( -#' oauth2_security_scheme( -#' password_flow = oauth2_token_flow( +#' details = class_security_scheme_details( +#' class_oauth2_security_scheme( +#' password_flow = class_oauth2_token_flow( #' token_url = "/account/authorization", -#' scopes = scopes( +#' scopes = class_scopes( #' name = c("Catalog", "Commerce", "Playback", "Settings"), #' description = c( #' "Access all read-only content", @@ -41,22 +41,22 @@ NULL #' ) #' ) #' ), -#' api_key_security_scheme( +#' class_api_key_security_scheme( #' parameter_name = "authorization", #' location = "header" #' ) #' ) #' ) -security_scheme_collection <- S7::new_class( - name = "security_scheme_collection", +class_security_schemes <- S7::new_class( + name = "security_schemes", package = "rapid", properties = list( name = class_character, - details = security_scheme_details, + details = class_security_scheme_details, description = class_character ), constructor = function(name = character(), - details = security_scheme_details(), + details = class_security_scheme_details(), ..., description = character()) { check_dots_empty() @@ -77,16 +77,15 @@ security_scheme_collection <- S7::new_class( } ) -S7::method(length, security_scheme_collection) <- function(x) { +S7::method(length, class_security_schemes) <- function(x) { length(x@name) } -#' Coerce lists to security_scheme_collection objects +#' Coerce lists to security_schemes objects #' -#' `as_security_scheme_collection()` turns an existing object into a -#' `security_scheme_collection` object. This is in contrast with -#' [security_scheme_collection()], which builds a `security_scheme_collection` -#' from individual properties. +#' `as_security_schemes()` turns an existing object into a `security_schemes` +#' object. This is in contrast with [class_security_schemes()], which builds a +#' `security_schemes` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -94,13 +93,13 @@ S7::method(length, security_scheme_collection) <- function(x) { #' element describes a security scheme object. This object should describe the #' security schemes for a single API. #' -#' @return A `security_scheme_collection` object as returned by -#' [security_scheme_collection()]. +#' @return A `security_schemes` object as returned by +#' [class_security_schemes()]. #' @export #' #' @examples -#' as_security_scheme_collection() -#' as_security_scheme_collection( +#' as_security_schemes() +#' as_security_schemes( #' list( #' accountAuth = list( #' description = "Account JWT token", @@ -141,20 +140,20 @@ S7::method(length, security_scheme_collection) <- function(x) { #' ) #' ) #' ) -as_security_scheme_collection <- S7::new_generic( - "as_security_scheme_collection", +as_security_schemes <- S7::new_generic( + "as_security_schemes", "x" ) S7::method( - as_security_scheme_collection, + as_security_schemes, class_list ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { force(arg) # This is the first one where we're fundamentally rearranging things, so watch # out for new things to standardize (and then delete this comment)! if (!length(x) || !any(lengths(x))) { - return(security_scheme_collection()) + return(class_security_schemes()) } if (rlang::is_named2(x)) { @@ -162,7 +161,7 @@ S7::method( x <- unname(x) descriptions <- .extract_along_chr(x, "description") return( - security_scheme_collection( + class_security_schemes( name = scheme_names, details = x, description = descriptions @@ -176,8 +175,8 @@ S7::method( } S7::method( - as_security_scheme_collection, + as_security_schemes, class_any ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, security_scheme_collection, ..., arg = arg, call = call) + as_api_object(x, class_security_schemes, ..., arg = arg, call = call) } diff --git a/R/components.R b/R/components.R index 09ba23b..531c550 100644 --- a/R/components.R +++ b/R/components.R @@ -1,4 +1,4 @@ -#' @include components-security_scheme_collection.R +#' @include components-security_schemes.R NULL #' An element to hold various schemas for the API @@ -7,53 +7,53 @@ NULL #' defined within the components object will have no effect on the API unless #' they are explicitly referenced from properties outside the components object. #' We currently only support the security_schemes object within the components -#' object (see [security_scheme_collection()]). +#' object (see [class_security_schemes()]). #' #' @inheritParams rlang::args_dots_empty #' @param security_schemes An object to hold reusable security scheme objects -#' created by [security_scheme_collection()]. +#' created by [class_security_schemes()]. #' -#' @return A `component_collection` S7 object with various schemas for the API. +#' @return A `components` S7 object with various schemas for the API. #' @export #' -#' @seealso [as_component_collection()] for coercing objects to -#' `component_collection` objects. +#' @seealso [as_components()] for coercing objects to +#' `components` objects. #' #' @examples -#' component_collection() -#' component_collection( -#' security_schemes = security_scheme_collection( +#' class_components() +#' class_components( +#' security_schemes = class_security_schemes( #' name = "a", -#' details = security_scheme_details( -#' api_key_security_scheme("parm", "query") +#' details = class_security_scheme_details( +#' class_api_key_security_scheme("parm", "query") #' ) #' ) #' ) -component_collection <- S7::new_class( - "component_collection", +class_components <- S7::new_class( + "components", package = "rapid", properties = list( - security_schemes = security_scheme_collection + security_schemes = class_security_schemes ), constructor = function(..., - security_schemes = security_scheme_collection()) { + security_schemes = class_security_schemes()) { check_dots_empty() S7::new_object( S7::S7_object(), - security_schemes = as_security_scheme_collection(security_schemes) + security_schemes = as_security_schemes(security_schemes) ) } ) -S7::method(length, component_collection) <- function(x) { +S7::method(length, class_components) <- function(x) { sum(lengths(S7::props(x)) > 0) } -#' Coerce lists to component_collection objects +#' Coerce lists to components objects #' -#' `as_component_collection()` turns an existing object into a -#' `component_collection` object. This is in contrast with -#' [component_collection()], which builds a `component_collection` from +#' `as_components()` turns an existing object into a +#' `components` object. This is in contrast with +#' [class_components()], which builds a `components` from #' individual properties. #' #' @inheritParams rlang::args_dots_empty @@ -63,13 +63,13 @@ S7::method(length, component_collection) <- function(x) { #' "security_schemes" via [snakecase::to_snake_case()]. Additional names are #' ignored. #' -#' @return A `component_collection` object as returned by -#' [component_collection()]. +#' @return A `components` object as returned by +#' [class_components()]. #' @export #' #' @examples -#' as_component_collection() -#' as_component_collection(list( +#' as_components() +#' as_components(list( #' securitySchemes = list( #' accountAuth = list( #' description = "Account JWT token", @@ -110,9 +110,9 @@ S7::method(length, component_collection) <- function(x) { #' ) #' ) #' )) -as_component_collection <- function(x, - ..., - arg = caller_arg(x), - call = caller_env()) { - as_api_object(x, component_collection, ..., arg = arg, call = call) +as_components <- function(x, + ..., + arg = caller_arg(x), + call = caller_env()) { + as_api_object(x, class_components, ..., arg = arg, call = call) } diff --git a/R/info-contact.R b/R/info-contact.R index 573604d..c7bb85e 100644 --- a/R/info-contact.R +++ b/R/info-contact.R @@ -19,12 +19,12 @@ NULL #' @seealso [as_contact()] for coercing objects to `contact`. #' #' @examples -#' contact( +#' class_contact( #' "API Support", #' "support@example.com", #' "https://www.example.com/support" #' ) -contact <- S7::new_class( +class_contact <- S7::new_class( "contact", package = "rapid", properties = list( @@ -37,14 +37,14 @@ contact <- S7::new_class( ) ) -S7::method(length, contact) <- function(x) { +S7::method(length, class_contact) <- function(x) { max(lengths(S7::props(x))) } #' Coerce lists and character vectors to contacts #' #' `as_contact()` turns an existing object into a `contact`. This is in contrast -#' with [contact()], which builds a `contact` from individual properties. +#' with [class_contact()], which builds a `contact` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -53,12 +53,12 @@ S7::method(length, contact) <- function(x) { #' [snakecase::to_snake_case()]. Extra names are ignored. This object should #' describe a single point of contact. #' -#' @return A `contact` as returned by [contact()]. +#' @return A `contact` as returned by [class_contact()]. #' @export #' #' @examples #' as_contact() #' as_contact(list(name = "Jon Harmon", email = "jonthegeek@gmail.com")) as_contact <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, contact, ..., arg = arg, call = call) + as_api_object(x, class_contact, ..., arg = arg, call = call) } diff --git a/R/info-license.R b/R/info-license.R index 593d0d6..80f9946 100644 --- a/R/info-license.R +++ b/R/info-license.R @@ -23,15 +23,15 @@ NULL #' @seealso [as_license()] for coercing objects to `license`. #' #' @examples -#' license( +#' class_license( #' "Apache 2.0", #' identifier = "Apache-2.0" #' ) -#' license( +#' class_license( #' "Apache 2.0", #' url = "https://opensource.org/license/apache-2-0/" #' ) -license <- S7::new_class( +class_license <- S7::new_class( "license", package = "rapid", properties = list( @@ -59,14 +59,14 @@ license <- S7::new_class( } ) -S7::method(length, license) <- function(x) { +S7::method(length, class_license) <- function(x) { max(lengths(S7::props(x))) } #' Coerce lists and character vectors to licenses #' #' `as_license()` turns an existing object into a `license`. This is in contrast -#' with [license()], which builds a `license` from individual properties. +#' with [class_license()], which builds a `license` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -75,12 +75,12 @@ S7::method(length, license) <- function(x) { #' [snakecase::to_snake_case()]. Extra names are ignored. This object should #' describe a single license. #' -#' @return A `license` as returned by [license()]. +#' @return A `license` as returned by [class_license()]. #' @export #' #' @examples #' as_license() #' as_license(list(name = "Apache 2.0", identifier = "Apache-2.0")) as_license <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, license, ..., arg = arg, call = call) + as_api_object(x, class_license, ..., arg = arg, call = call) } diff --git a/R/info-origin.R b/R/info-origin.R index 91a49c2..90f8fd7 100644 --- a/R/info-origin.R +++ b/R/info-origin.R @@ -3,8 +3,8 @@ NULL #' Source information for the API description #' -#' A `class_origin` object provides information about the primary source -#' document(s) used to build an API. +#' An `origin` object provides information about the primary source document(s) +#' used to build an API. #' #' @inheritParams rlang::args_dots_empty #' @param url Character (required). The URL(s) where the document(s) can be @@ -17,11 +17,11 @@ NULL #' will be "3.0" (as in "OpenAPI Specification version 3.0"), "3.1", or a #' patch version of those. #' -#' @return A `class_origin` S7 object describing where to find the API -#' description, with fields `url`, `format`, and `version`. +#' @return An `origin` S7 object describing where to find the API description, +#' with fields `url`, `format`, and `version`. #' @export #' -#' @seealso [as_origin()] for coercing objects to `class_origin`. +#' @seealso [as_origin()] for coercing objects to `origin`. #' #' @examples #' class_origin( @@ -30,7 +30,7 @@ NULL #' version = "3.0" #' ) class_origin <- S7::new_class( - "class_origin", + "origin", package = "rapid", properties = list( url = character_scalar_property("url"), @@ -62,11 +62,10 @@ S7::method(length, class_origin) <- function(x) { length(x@url) } -#' Coerce lists and character vectors to class_origin +#' Coerce lists and character vectors to origin #' -#' `as_origin()` turns an existing object into a `class_origin`. This is in -#' contrast with [class_origin()], which builds a `class_origin` from individual -#' properties. +#' `as_origin()` turns an existing object into an `origin`. This is in contrast +#' with [class_origin()], which builds an `origin` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -75,7 +74,7 @@ S7::method(length, class_origin) <- function(x) { #' [snakecase::to_snake_case()]. Extra names are ignored. This object should #' describe a single origin for this API description. #' -#' @return A `class_origin` as returned by [class_origin()]. +#' @return An `origin` as returned by [class_origin()]. #' @export #' #' @examples diff --git a/R/info.R b/R/info.R index 24df8b5..9416fef 100644 --- a/R/info.R +++ b/R/info.R @@ -17,7 +17,7 @@ NULL #' distinct from the OpenAPI Specification version or the API implementation #' version). Required when the object is not empty. #' @param contact The contact information for the exposed API, generated via -#' [contact()]. +#' [class_contact()]. #' @param description Character scalar (optional). A description of the API. #' [CommonMark syntax](https://spec.commonmark.org/) may be used for rich text #' representation. @@ -37,29 +37,29 @@ NULL #' @seealso [as_info()] for coercing objects to `info`. #' #' @examples -#' info() -#' info( +#' class_info() +#' class_info( #' title = "My Cool API", #' version = "1.0.2", -#' license = license( +#' license = class_license( #' name = "Apache 2.0", #' url = "https://opensource.org/license/apache-2-0/" #' ) #' ) -#' info( +#' class_info( #' title = "My Abbreviated API", #' version = "2.0.0", #' origin = "https://root.url" #' ) -info <- S7::new_class( +class_info <- S7::new_class( "info", package = "rapid", properties = list( title = character_scalar_property("title"), version = character_scalar_property("version"), - contact = contact, + contact = class_contact, description = character_scalar_property("description"), - license = license, + license = class_license, summary = character_scalar_property("summary"), terms_of_service = character_scalar_property("terms_of_service"), origin = class_origin @@ -67,9 +67,9 @@ info <- S7::new_class( constructor = function(title = character(), version = character(), ..., - contact = class_missing, + contact = class_contact(), description = character(), - license = class_missing, + license = class_license(), summary = character(), terms_of_service = character(), origin = class_origin()) { @@ -103,14 +103,14 @@ info <- S7::new_class( } ) -S7::method(length, info) <- function(x) { +S7::method(length, class_info) <- function(x) { max(lengths(S7::props(x))) } #' Coerce lists and character vectors to info objects #' #' `as_info()` turns an existing object into an `info` object. This is in -#' contrast with [info()], which builds an `info` from individual properties. +#' contrast with [class_info()], which builds an `info` from individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -121,7 +121,7 @@ S7::method(length, info) <- function(x) { #' [snakecase::to_snake_case()]. Extra names are ignored. This object should #' describe a single API. #' -#' @return An `info` object as returned by [info()]. +#' @return An `info` object as returned by [class_info()]. #' @export #' #' @examples @@ -130,7 +130,7 @@ S7::method(length, info) <- function(x) { as_info <- function(x, ..., arg = caller_arg(x), call = caller_env()) { as_api_object( x, - info, + class_info, ..., alternate_names = c("x-origin" = "origin"), arg = arg, diff --git a/R/security_requirements.R b/R/security.R similarity index 70% rename from R/security_requirements.R rename to R/security.R index 064f9bd..81d61c9 100644 --- a/R/security_requirements.R +++ b/R/security.R @@ -9,25 +9,25 @@ NULL #' @inheritParams rlang::args_dots_empty #' @param name Character vector (required). The names must correspond to #' security schemes declared in the `security_schemes` property of a -#' [component_collection()]. +#' [class_components()]. #' @param required_scopes A list of character vectors, each of which describe #' the scopes required for this security scheme. The vector corresponding to a #' given `name` can be empty. #' -#' @return A `security_requirements` S7 object with references of security -#' required for operations. +#' @return A `security` S7 object with references of security required for +#' operations. #' @export #' @examples -#' security_requirements() -#' security_requirements( +#' class_security() +#' class_security( #' name = c("oauth2", "internalApiKey"), #' required_scopes = list( #' c("user", "user:email", "user:follow"), #' character() #' ) #' ) -security_requirements <- S7::new_class( - "security_requirements", +class_security <- S7::new_class( + "security", package = "rapid", properties = list( name = class_character, @@ -57,16 +57,15 @@ security_requirements <- S7::new_class( } ) -S7::method(length, security_requirements) <- function(x) { +S7::method(length, class_security) <- function(x) { length(x@name) } -#' Coerce lists to as_security_requirements objects +#' Coerce lists to as_security objects #' -#' `as_security_requirements()` turns an existing object into a -#' `security_requirements` object. This is in contrast with -#' [security_requirements()], which builds a `security_requirements` from -#' individual properties. +#' `as_security()` turns an existing object into a `security` object. This is in +#' contrast with [class_security()], which builds a `security` from individual +#' properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -75,13 +74,12 @@ S7::method(length, security_requirements) <- function(x) { #' "security_schemes" via [snakecase::to_snake_case()]. Additional names are #' ignored. #' -#' @return A `security_requirements` object as returned by -#' [security_requirements()]. +#' @return A `security` object as returned by [class_security()]. #' @export #' #' @examples -#' as_security_requirements() -#' as_security_requirements( +#' as_security() +#' as_security( #' list( #' list( #' oauth2 = c("user", "user:email", "user:follow") @@ -89,10 +87,10 @@ S7::method(length, security_requirements) <- function(x) { #' list(internalApiKey = list()) #' ) #' ) -as_security_requirements <- S7::new_generic("as_security_requirements", "x") +as_security <- S7::new_generic("as_security", "x") S7::method( - as_security_requirements, + as_security, class_list ) <- function(x, ..., arg = caller_arg(x)) { force(arg) @@ -103,15 +101,15 @@ S7::method( "{.arg {arg}} must be a named list.", ) } - security_requirements( + class_security( name = names(x), required_scopes = unname(x) ) } S7::method( - as_security_requirements, + as_security, class_any ) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, security_requirements, ..., arg = arg, call = call) + as_api_object(x, class_security, ..., arg = arg, call = call) } diff --git a/R/servers-server_variables.R b/R/servers-server_variables.R index c6e678b..178516a 100644 --- a/R/servers-server_variables.R +++ b/R/servers-server_variables.R @@ -1,22 +1,22 @@ #' A collection of string replacements for multiple servers #' #' A list of string replacements objects, each of which is constructed with -#' [string_replacements()]. +#' [class_string_replacements()]. #' -#' @param ... One or more [string_replacements()] objects, or a list of -#' [string_replacements()] objects. +#' @param ... One or more [class_string_replacements()] objects, or a list of +#' [class_string_replacements()] objects. #' #' @return A `server_variables` S7 object, which is a validated list of -#' [string_replacements()] objects. +#' [class_string_replacements()] objects. #' @export #' #' @seealso [as_server_variables()] for coercing objects to `server_variables`. #' #' @examples -#' server_variables( -#' list(string_replacements(), string_replacements()) +#' class_server_variables( +#' list(class_string_replacements(), class_string_replacements()) #' ) -server_variables <- S7::new_class( +class_server_variables <- S7::new_class( "server_variables", package = "rapid", parent = class_list, @@ -29,7 +29,7 @@ server_variables <- S7::new_class( validator = function(self) { bad_string_replacements <- !purrr::map_lgl( S7::S7_data(self), - ~ S7::S7_inherits(.x, string_replacements) + ~ S7::S7_inherits(.x, class_string_replacements) ) if (any(bad_string_replacements)) { bad_locations <- which(bad_string_replacements) @@ -46,7 +46,7 @@ server_variables <- S7::new_class( #' Coerce lists to server_variables #' #' `as_server_variables()` turns an existing object into a `server_variables` -#' object. This is in contrast with [server_variables()], which builds a +#' object. This is in contrast with [class_server_variables()], which builds a #' `server_variables` object from individual properties. #' #' @inheritParams rlang::args_dots_empty @@ -54,7 +54,7 @@ server_variables <- S7::new_class( #' @param x The object to coerce. Must be empty or be a list of objects that can #' be coerced to `string_replacements` objects via [as_string_replacements()]. #' -#' @return A `server_variables` object as returned by [server_variables()]. +#' @return A `server_variables` object as returned by [class_server_variables()]. #' @export #' #' @examples @@ -80,9 +80,9 @@ as_server_variables <- S7::new_generic("as_server_variables", "x") S7::method(as_server_variables, class_list) <- function(x) { if (!length(x) || !any(lengths(x))) { - return(server_variables()) + return(class_server_variables()) } - server_variables( + class_server_variables( purrr::map(x, as_string_replacements) ) } @@ -91,5 +91,5 @@ S7::method(as_server_variables, class_any) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, server_variables, ..., arg = arg, call = call) + as_api_object(x, class_server_variables, ..., arg = arg, call = call) } diff --git a/R/servers-string_replacements.R b/R/servers-string_replacements.R index d84bc46..f233f4e 100644 --- a/R/servers-string_replacements.R +++ b/R/servers-string_replacements.R @@ -27,17 +27,17 @@ NULL #' @export #' #' @seealso [as_string_replacements()] for coercing objects to -#' `string_replacements`, and [server_variables()] for creating collections of -#' `string_replacements`. +#' `string_replacements`, and [class_server_variables()] for creating +#' collections of `string_replacements`. #' #' @examples -#' string_replacements( +#' class_string_replacements( #' "username", #' "demo", #' enum = c("demo", "other"), #' description = "The active user's folder." #' ) -string_replacements <- S7::new_class( +class_string_replacements <- S7::new_class( "string_replacements", package = "rapid", properties = list( @@ -74,15 +74,16 @@ string_replacements <- S7::new_class( } ) -S7::method(length, string_replacements) <- function(x) { +S7::method(length, class_string_replacements) <- function(x) { length(x@name) } #' Coerce lists to string_replacements #' #' `as_string_replacements()` turns an existing object into a -#' `string_replacements`. This is in contrast with [string_replacements()], -#' which builds a `string_replacements` from individual properties. +#' `string_replacements`. This is in contrast with +#' [class_string_replacements()], which builds a `string_replacements` from +#' individual properties. #' #' @inheritParams rlang::args_dots_empty #' @inheritParams rlang::args_error_context @@ -91,7 +92,7 @@ S7::method(length, string_replacements) <- function(x) { #' coerced to those names via [snakecase::to_snake_case()]. Additional names #' are ignored. #' -#' @return A `string_replacements` as returned by [string_replacements()]. +#' @return A `string_replacements` as returned by [class_string_replacements()]. #' @export #' #' @examples @@ -112,7 +113,7 @@ as_string_replacements <- S7::new_generic("as_string_replacements", "x") S7::method(as_string_replacements, class_list) <- function(x) { nameless <- unname(x) - string_replacements( + class_string_replacements( name = names(x), default = purrr::map_chr(nameless, "default"), enum = purrr::map(nameless, "enum"), @@ -124,5 +125,5 @@ S7::method(as_string_replacements, class_any) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, string_replacements, ..., arg = arg, call = call) + as_api_object(x, class_string_replacements, ..., arg = arg, call = call) } diff --git a/R/servers.R b/R/servers.R index 5c14082..3d4632d 100644 --- a/R/servers.R +++ b/R/servers.R @@ -8,12 +8,12 @@ NULL #' servers are intended to be used as the base urls for calls to the API. #' #' @param url Character vector (required). The urls of the target hosts. These -#' urls support [string_replacements()]. Variable substitutions will be made -#' when a variable is named in \{brackets\}. +#' urls support [class_string_replacements()]. Variable substitutions will be +#' made when a variable is named in \{brackets\}. #' @param description Character vector (optional). Strings describing the hosts #' designated by `url`. [CommonMark syntax](https://spec.commonmark.org/) may #' be used for rich text representation. -#' @param variables A [server_variables()] object. +#' @param variables A [class_server_variables()] object. #' #' @return A `servers` S7 object, with properties `url`, `description`, and #' `variables`. @@ -22,7 +22,7 @@ NULL #' @seealso [as_servers()] for coercing objects to `servers`. #' #' @examples -#' servers( +#' class_servers( #' url = c( #' "https://development.gigantic-server.com/v1", #' "https://staging.gigantic-server.com/v1", @@ -34,10 +34,10 @@ NULL #' "Production server" #' ) #' ) -#' servers( +#' class_servers( #' url = "https://{username}.gigantic-server.com:{port}/{basePath}", #' description = "The production API server", -#' variables = server_variables(string_replacements( +#' variables = class_server_variables(class_string_replacements( #' name = c("username", "port", "basePath"), #' default = c("demo", "8443", "v2"), #' description = c( @@ -51,17 +51,17 @@ NULL #' ) #' )) #' ) -servers <- S7::new_class( +class_servers <- S7::new_class( "servers", package = "rapid", properties = list( url = class_character, description = class_character, - variables = server_variables + variables = class_server_variables ), constructor = function(url = character(), description = character(), - variables = server_variables()) { + variables = class_server_variables()) { S7::new_object( S7::S7_object(), url = url %||% character(), @@ -78,14 +78,14 @@ servers <- S7::new_class( } ) -S7::method(length, servers) <- function(x) { +S7::method(length, class_servers) <- function(x) { length(x@url) } #' Coerce lists and character vectors to servers #' #' `as_servers()` turns an existing object into a `servers` object. This is in -#' contrast with [servers()], which builds a `servers` object from individual +#' contrast with [class_servers()], which builds a `servers` object from individual #' properties. #' #' @inheritParams rlang::args_dots_empty @@ -94,7 +94,7 @@ S7::method(length, servers) <- function(x) { #' and/or "url", or names that can be coerced to those names via #' [snakecase::to_snake_case()]. Extra names are ignored. #' -#' @return A `servers` object as returned by [servers()]. +#' @return A `servers` object as returned by [class_servers()]. #' @export #' #' @examples @@ -123,7 +123,7 @@ S7::method(as_servers, class_list) <- function(x, ..., call = caller_env()) { function(x) { .validate_for_as_class( x, - servers, + class_servers, x_arg = "x[[i]]", call = call ) @@ -133,7 +133,7 @@ S7::method(as_servers, class_list) <- function(x, ..., call = caller_env()) { x <- NULL } - servers( + class_servers( url = purrr::map_chr(x, "url"), description = .extract_along_chr(x, "description"), variables = as_server_variables(purrr::map(x, "variables")) @@ -144,5 +144,5 @@ S7::method(as_servers, class_any) <- function(x, ..., arg = caller_arg(x), call = caller_env()) { - as_api_object(x, servers, ..., arg = arg, call = call) + as_api_object(x, class_servers, ..., arg = arg, call = call) } diff --git a/R/zz-rapid.R b/R/zz-rapid.R index de50533..5c916c2 100644 --- a/R/zz-rapid.R +++ b/R/zz-rapid.R @@ -1,7 +1,7 @@ #' @include info.R #' @include servers.R #' @include components.R -#' @include security_requirements.R +#' @include security.R NULL #' R API description object @@ -9,12 +9,10 @@ NULL #' An object that represents an API. #' #' @inheritParams rlang::args_dots_empty -#' @param info An `info` object defined by [info()]. -#' @param servers A `servers` object defined by [servers()]. -#' @param components A `component_collection` object defined by -#' [component_collection()]. -#' @param security A `security_requirements` object defined by -#' [security_requirements()]. +#' @param info An `info` object defined by [class_info()]. +#' @param servers A `servers` object defined by [class_servers()]. +#' @param components A `components` object defined by [class_components()]. +#' @param security A `security` object defined by [class_security()]. #' #' @return A `rapid` S7 object, with properties `info`, `servers`, `components`, #' and `security`. @@ -23,16 +21,16 @@ NULL #' @seealso [as_rapid()] for coercing objects to `rapid`. #' #' @examples -#' rapid() -#' rapid( -#' info = info(title = "A", version = "1"), -#' servers = servers( +#' class_rapid() +#' class_rapid( +#' info = class_info(title = "A", version = "1"), +#' servers = class_servers( #' url = "https://development.gigantic-server.com/v1" #' ) #' ) -#' rapid( -#' info = info(title = "A", version = "1"), -#' servers = servers( +#' class_rapid( +#' info = class_info(title = "A", version = "1"), +#' servers = class_servers( #' url = c( #' "https://development.gigantic-server.com/v1", #' "https://staging.gigantic-server.com/v1", @@ -44,36 +42,36 @@ NULL #' "Production server" #' ) #' ), -#' components = component_collection( -#' security_schemes = security_scheme_collection( +#' components = class_components( +#' security_schemes = class_security_schemes( #' name = "a", -#' details = security_scheme_details( -#' api_key_security_scheme("parm", "query") +#' details = class_security_scheme_details( +#' class_api_key_security_scheme("parm", "query") #' ) #' ) #' ) #' ) -rapid <- S7::new_class( +class_rapid <- S7::new_class( "rapid", package = "rapid", properties = list( - info = info, - servers = servers, - components = component_collection, - security = security_requirements + info = class_info, + servers = class_servers, + components = class_components, + security = class_security ), - constructor = function(info = class_missing, + constructor = function(info = class_info(), ..., - servers = class_missing, - components = component_collection(), - security = security_requirements()) { + servers = class_servers(), + components = class_components(), + security = class_security()) { check_dots_empty() S7::new_object( S7::S7_object(), info = as_info(info), servers = as_servers(servers), - components = as_component_collection(components), - security = as_security_requirements(security) + components = as_components(components), + security = as_security(security) ) }, validator = function(self) { @@ -93,14 +91,14 @@ rapid <- S7::new_class( } ) -S7::method(length, rapid) <- function(x) { +S7::method(length, class_rapid) <- function(x) { length(x@info) } #' Coerce lists and urls to rapid objects #' #' `as_rapid()` turns an existing object into a `rapid` object. This is in -#' contrast with [rapid()], which builds a `rapid` object from individual +#' contrast with [class_rapid()], which builds a `rapid` object from individual #' properties. #' #' @inheritParams rlang::args_dots_empty @@ -110,7 +108,7 @@ S7::method(length, rapid) <- function(x) { #' [snakecase::to_snake_case()]. Extra names are ignored. [url()] objects are #' read with [jsonlite::fromJSON()] or [yaml::read_yaml()] before conversion. #' -#' @return A `rapid` object as returned by [rapid()]. +#' @return A `rapid` object as returned by [class_rapid()]. #' @export #' #' @examples @@ -135,7 +133,7 @@ S7::method(as_rapid, class_any) <- function(x, call = caller_env()) { rlang::try_fetch( { - x <- as_api_object(x, rapid, ..., arg = arg, call = call) + x <- as_api_object(x, class_rapid, ..., arg = arg, call = call) expand_servers(x) }, rapid_error_missing_names = function(cnd) { diff --git a/_pkgdown.yml b/_pkgdown.yml index 834992a..438ca8f 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -4,52 +4,52 @@ template: reference: - title: rapid class contents: - - rapid + - class_rapid - as_rapid - expand_servers - title: info class contents: - - info + - class_info - as_info - - contact + - class_contact - as_contact - - license + - class_license - as_license - class_origin - as_origin - title: servers class contents: - - servers + - class_servers - as_servers - - string_replacements + - class_string_replacements - as_string_replacements - - server_variables + - class_server_variables - as_server_variables - - title: component_collection class + - title: components class contents: - - component_collection - - as_component_collection - - security_scheme_collection - - as_security_scheme_collection + - class_components + - as_components + - class_security_schemes + - as_security_schemes - as_security_scheme - - security_scheme_details + - class_security_scheme_details - as_security_scheme_details - - api_key_security_scheme + - class_api_key_security_scheme - as_api_key_security_scheme - - oauth2_security_scheme + - class_oauth2_security_scheme - as_oauth2_security_scheme - - oauth2_authorization_code_flow + - class_oauth2_authorization_code_flow - as_oauth2_authorization_code_flow - - oauth2_implicit_flow + - class_oauth2_implicit_flow - as_oauth2_implicit_flow - - oauth2_token_flow + - class_oauth2_token_flow - as_oauth2_token_flow - - scopes + - class_scopes - as_scopes - - title: security_requirements class + - title: security class contents: - - security_requirements - - as_security_requirements + - class_security + - as_security - title: other contents: - as_api_object diff --git a/man/abstract_oauth2_flow.Rd b/man/abstract_oauth2_flow.Rd new file mode 100644 index 0000000..0233de9 --- /dev/null +++ b/man/abstract_oauth2_flow.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/components-security_scheme-oauth2-flow.R +\name{abstract_oauth2_flow} +\alias{abstract_oauth2_flow} +\title{OAuth2 flow object} +\usage{ +abstract_oauth2_flow(refresh_url = class_missing, scopes = class_missing) +} +\arguments{ +\item{refresh_url}{Character scalar (optional). The URL to be used for +obtaining refresh tokens. This must be in the form of a URL. The OAuth2 +standard requires the use of TLS.} + +\item{scopes}{An optional \code{\link[=class_scopes]{class_scopes()}} object with the available scopes +for the OAuth2 security scheme.} +} +\description{ +This is an abstract class that is used to define specific types of OAuth2 +flow objects. +} +\seealso{ +\code{\link[=class_oauth2_token_flow]{class_oauth2_token_flow()}}, \code{\link[=class_oauth2_implicit_flow]{class_oauth2_implicit_flow()}}, and +\code{\link[=class_oauth2_authorization_code_flow]{class_oauth2_authorization_code_flow()}} +} +\keyword{internal} diff --git a/man/security_scheme.Rd b/man/abstract_security_scheme.Rd similarity index 53% rename from man/security_scheme.Rd rename to man/abstract_security_scheme.Rd index baec7b1..ee5a9b0 100644 --- a/man/security_scheme.Rd +++ b/man/abstract_security_scheme.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components-security_scheme.R -\name{security_scheme} -\alias{security_scheme} +\name{abstract_security_scheme} +\alias{abstract_security_scheme} \title{Security scheme objects} \usage{ -security_scheme() +abstract_security_scheme() } \description{ This is an abstract class that is used to define specific types of security schemes. } \seealso{ -\code{\link[=api_key_security_scheme]{api_key_security_scheme()}}, \code{\link[=oauth2_security_scheme]{oauth2_security_scheme()}} +\code{\link[=class_api_key_security_scheme]{class_api_key_security_scheme()}}, \code{\link[=class_oauth2_security_scheme]{class_oauth2_security_scheme()}} } \keyword{internal} diff --git a/man/as_api_key_security_scheme.Rd b/man/as_api_key_security_scheme.Rd index 17fceed..b935c24 100644 --- a/man/as_api_key_security_scheme.Rd +++ b/man/as_api_key_security_scheme.Rd @@ -25,11 +25,11 @@ mentioned in error messages as the source of the error. See the } \value{ An \code{api_key_security_scheme} as returned by -\code{\link[=api_key_security_scheme]{api_key_security_scheme()}}. +\code{\link[=class_api_key_security_scheme]{class_api_key_security_scheme()}}. } \description{ \code{as_api_key_security_scheme()} turns an existing object into an \code{api_key_security_scheme}. This is in contrast with -\code{\link[=api_key_security_scheme]{api_key_security_scheme()}}, which builds an \code{api_key_security_scheme} from -individual properties. +\code{\link[=class_api_key_security_scheme]{class_api_key_security_scheme()}}, which builds an \code{api_key_security_scheme} +from individual properties. } diff --git a/man/as_component_collection.Rd b/man/as_components.Rd similarity index 76% rename from man/as_component_collection.Rd rename to man/as_components.Rd index 7cb423a..ed212da 100644 --- a/man/as_component_collection.Rd +++ b/man/as_components.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components.R -\name{as_component_collection} -\alias{as_component_collection} -\title{Coerce lists to component_collection objects} +\name{as_components} +\alias{as_components} +\title{Coerce lists to components objects} \usage{ -as_component_collection(x, ..., arg = caller_arg(x), call = caller_env()) +as_components(x, ..., arg = caller_arg(x), call = caller_env()) } \arguments{ \item{x}{The object to coerce. Must be empty or be a list containing a single @@ -24,18 +24,18 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -A \code{component_collection} object as returned by -\code{\link[=component_collection]{component_collection()}}. +A \code{components} object as returned by +\code{\link[=class_components]{class_components()}}. } \description{ -\code{as_component_collection()} turns an existing object into a -\code{component_collection} object. This is in contrast with -\code{\link[=component_collection]{component_collection()}}, which builds a \code{component_collection} from +\code{as_components()} turns an existing object into a +\code{components} object. This is in contrast with +\code{\link[=class_components]{class_components()}}, which builds a \code{components} from individual properties. } \examples{ -as_component_collection() -as_component_collection(list( +as_components() +as_components(list( securitySchemes = list( accountAuth = list( description = "Account JWT token", diff --git a/man/as_contact.Rd b/man/as_contact.Rd index 7d1aec5..d6432d3 100644 --- a/man/as_contact.Rd +++ b/man/as_contact.Rd @@ -24,11 +24,11 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -A \code{contact} as returned by \code{\link[=contact]{contact()}}. +A \code{contact} as returned by \code{\link[=class_contact]{class_contact()}}. } \description{ \code{as_contact()} turns an existing object into a \code{contact}. This is in contrast -with \code{\link[=contact]{contact()}}, which builds a \code{contact} from individual properties. +with \code{\link[=class_contact]{class_contact()}}, which builds a \code{contact} from individual properties. } \examples{ as_contact() diff --git a/man/as_info.Rd b/man/as_info.Rd index d3c9276..b966fce 100644 --- a/man/as_info.Rd +++ b/man/as_info.Rd @@ -26,11 +26,11 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -An \code{info} object as returned by \code{\link[=info]{info()}}. +An \code{info} object as returned by \code{\link[=class_info]{class_info()}}. } \description{ \code{as_info()} turns an existing object into an \code{info} object. This is in -contrast with \code{\link[=info]{info()}}, which builds an \code{info} from individual properties. +contrast with \code{\link[=class_info]{class_info()}}, which builds an \code{info} from individual properties. } \examples{ as_info() diff --git a/man/as_license.Rd b/man/as_license.Rd index baba2f1..b73a1f6 100644 --- a/man/as_license.Rd +++ b/man/as_license.Rd @@ -24,11 +24,11 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -A \code{license} as returned by \code{\link[=license]{license()}}. +A \code{license} as returned by \code{\link[=class_license]{class_license()}}. } \description{ \code{as_license()} turns an existing object into a \code{license}. This is in contrast -with \code{\link[=license]{license()}}, which builds a \code{license} from individual properties. +with \code{\link[=class_license]{class_license()}}, which builds a \code{license} from individual properties. } \examples{ as_license() diff --git a/man/as_oauth2_authorization_code_flow.Rd b/man/as_oauth2_authorization_code_flow.Rd index b55d0bd..3f4f40f 100644 --- a/man/as_oauth2_authorization_code_flow.Rd +++ b/man/as_oauth2_authorization_code_flow.Rd @@ -31,11 +31,11 @@ mentioned in error messages as the source of the error. See the } \value{ An \code{oauth2_authorization_code_flow} as returned by -\code{\link[=oauth2_authorization_code_flow]{oauth2_authorization_code_flow()}}. +\code{\link[=class_oauth2_authorization_code_flow]{class_oauth2_authorization_code_flow()}}. } \description{ \code{as_oauth2_authorization_code_flow()} turns an existing object into an \code{oauth2_authorization_code_flow}. This is in contrast with -\code{\link[=oauth2_authorization_code_flow]{oauth2_authorization_code_flow()}}, which builds an +\code{\link[=class_oauth2_authorization_code_flow]{class_oauth2_authorization_code_flow()}}, which builds an \code{oauth2_authorization_code_flow} from individual properties. } diff --git a/man/as_oauth2_implicit_flow.Rd b/man/as_oauth2_implicit_flow.Rd index c6136be..13e7533 100644 --- a/man/as_oauth2_implicit_flow.Rd +++ b/man/as_oauth2_implicit_flow.Rd @@ -25,10 +25,10 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -An \code{oauth2_implicit_flow} as returned by \code{\link[=oauth2_implicit_flow]{oauth2_implicit_flow()}}. +An \code{oauth2_implicit_flow} as returned by \code{\link[=class_oauth2_implicit_flow]{class_oauth2_implicit_flow()}}. } \description{ \code{as_oauth2_implicit_flow()} turns an existing object into an -\code{oauth2_implicit_flow}. This is in contrast with \code{\link[=oauth2_implicit_flow]{oauth2_implicit_flow()}}, +\code{oauth2_implicit_flow}. This is in contrast with \code{\link[=class_oauth2_implicit_flow]{class_oauth2_implicit_flow()}}, which builds an \code{oauth2_implicit_flow} from individual properties. } diff --git a/man/as_oauth2_security_scheme.Rd b/man/as_oauth2_security_scheme.Rd index 1e5df42..ca0a452 100644 --- a/man/as_oauth2_security_scheme.Rd +++ b/man/as_oauth2_security_scheme.Rd @@ -15,11 +15,11 @@ named "flows" or a name that can be coerced to "flows" via } \value{ An \code{oauth2_security_scheme} as returned by -\code{\link[=oauth2_security_scheme]{oauth2_security_scheme()}}. +\code{\link[=class_oauth2_security_scheme]{class_oauth2_security_scheme()}}. } \description{ \code{as_oauth2_security_scheme()} turns an existing object into an \code{oauth2_security_scheme}. This is in contrast with -\code{\link[=oauth2_security_scheme]{oauth2_security_scheme()}}, which builds an \code{oauth2_security_scheme} from -individual properties. +\code{\link[=class_oauth2_security_scheme]{class_oauth2_security_scheme()}}, which builds an \code{oauth2_security_scheme} +from individual properties. } diff --git a/man/as_oauth2_token_flow.Rd b/man/as_oauth2_token_flow.Rd index 5ccfcfa..157a46f 100644 --- a/man/as_oauth2_token_flow.Rd +++ b/man/as_oauth2_token_flow.Rd @@ -24,10 +24,10 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -An \code{oauth2_token_flow} as returned by \code{\link[=oauth2_token_flow]{oauth2_token_flow()}}. +An \code{oauth2_token_flow} as returned by \code{\link[=class_oauth2_token_flow]{class_oauth2_token_flow()}}. } \description{ \code{as_oauth2_token_flow()} turns an existing object into an -\code{oauth2_token_flow}. This is in contrast with \code{\link[=oauth2_token_flow]{oauth2_token_flow()}}, which +\code{oauth2_token_flow}. This is in contrast with \code{\link[=class_oauth2_token_flow]{class_oauth2_token_flow()}}, which builds an \code{oauth2_token_flow} from individual properties. } diff --git a/man/as_origin.Rd b/man/as_origin.Rd index ff53531..2745caf 100644 --- a/man/as_origin.Rd +++ b/man/as_origin.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/info-origin.R \name{as_origin} \alias{as_origin} -\title{Coerce lists and character vectors to class_origin} +\title{Coerce lists and character vectors to origin} \usage{ as_origin(x, ..., arg = caller_arg(x), call = caller_env()) } @@ -24,12 +24,11 @@ mentioned in error messages as the source of the error. See the \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.} } \value{ -A \code{class_origin} as returned by \code{\link[=class_origin]{class_origin()}}. +An \code{origin} as returned by \code{\link[=class_origin]{class_origin()}}. } \description{ -\code{as_origin()} turns an existing object into a \code{class_origin}. This is in -contrast with \code{\link[=class_origin]{class_origin()}}, which builds a \code{class_origin} from individual -properties. +\code{as_origin()} turns an existing object into an \code{origin}. This is in contrast +with \code{\link[=class_origin]{class_origin()}}, which builds an \code{origin} from individual properties. } \examples{ as_origin() diff --git a/man/as_rapid.Rd b/man/as_rapid.Rd index cfa4712..19b9373 100644 --- a/man/as_rapid.Rd +++ b/man/as_rapid.Rd @@ -15,11 +15,11 @@ read with \code{\link[jsonlite:fromJSON]{jsonlite::fromJSON()}} or \code{\link[y \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{rapid} object as returned by \code{\link[=rapid]{rapid()}}. +A \code{rapid} object as returned by \code{\link[=class_rapid]{class_rapid()}}. } \description{ \code{as_rapid()} turns an existing object into a \code{rapid} object. This is in -contrast with \code{\link[=rapid]{rapid()}}, which builds a \code{rapid} object from individual +contrast with \code{\link[=class_rapid]{class_rapid()}}, which builds a \code{rapid} object from individual properties. } \examples{ diff --git a/man/as_scopes.Rd b/man/as_scopes.Rd index 739eb79..fcce14a 100644 --- a/man/as_scopes.Rd +++ b/man/as_scopes.Rd @@ -12,9 +12,9 @@ as_scopes(x, ...) \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{scopes} as returned by \code{\link[=scopes]{scopes()}}. +A \code{scopes} as returned by \code{\link[=class_scopes]{class_scopes()}}. } \description{ \code{as_scopes()} turns an existing object into a \code{scopes}. This is in contrast -with \code{\link[=scopes]{scopes()}}, which builds a \code{scopes} from individual properties. +with \code{\link[=class_scopes]{class_scopes()}}, which builds a \code{scopes} from individual properties. } diff --git a/man/as_security.Rd b/man/as_security.Rd new file mode 100644 index 0000000..e8070f4 --- /dev/null +++ b/man/as_security.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/security.R +\name{as_security} +\alias{as_security} +\title{Coerce lists to as_security objects} +\usage{ +as_security(x, ...) +} +\arguments{ +\item{x}{The object to coerce. Must be empty or be a list containing a single +list named "security_schemes", or a name that can be coerced to +"security_schemes" via \code{\link[snakecase:caseconverter]{snakecase::to_snake_case()}}. Additional names are +ignored.} + +\item{...}{These dots are for future extensions and must be empty.} +} +\value{ +A \code{security} object as returned by \code{\link[=class_security]{class_security()}}. +} +\description{ +\code{as_security()} turns an existing object into a \code{security} object. This is in +contrast with \code{\link[=class_security]{class_security()}}, which builds a \code{security} from individual +properties. +} +\examples{ +as_security() +as_security( + list( + list( + oauth2 = c("user", "user:email", "user:follow") + ), + list(internalApiKey = list()) + ) +) +} diff --git a/man/as_security_requirements.Rd b/man/as_security_requirements.Rd deleted file mode 100644 index d8c7789..0000000 --- a/man/as_security_requirements.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/security_requirements.R -\name{as_security_requirements} -\alias{as_security_requirements} -\title{Coerce lists to as_security_requirements objects} -\usage{ -as_security_requirements(x, ...) -} -\arguments{ -\item{x}{The object to coerce. Must be empty or be a list containing a single -list named "security_schemes", or a name that can be coerced to -"security_schemes" via \code{\link[snakecase:caseconverter]{snakecase::to_snake_case()}}. Additional names are -ignored.} - -\item{...}{These dots are for future extensions and must be empty.} -} -\value{ -A \code{security_requirements} object as returned by -\code{\link[=security_requirements]{security_requirements()}}. -} -\description{ -\code{as_security_requirements()} turns an existing object into a -\code{security_requirements} object. This is in contrast with -\code{\link[=security_requirements]{security_requirements()}}, which builds a \code{security_requirements} from -individual properties. -} -\examples{ -as_security_requirements() -as_security_requirements( - list( - list( - oauth2 = c("user", "user:email", "user:follow") - ), - list(internalApiKey = list()) - ) -) -} diff --git a/man/as_security_scheme.Rd b/man/as_security_scheme.Rd index 640eb98..cb8aa0d 100644 --- a/man/as_security_scheme.Rd +++ b/man/as_security_scheme.Rd @@ -15,8 +15,8 @@ or "oauth_2".} \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{security_scheme} object as returned by \code{\link[=api_key_security_scheme]{api_key_security_scheme()}} -or \code{\link[=oauth2_security_scheme]{oauth2_security_scheme()}}. +A \code{security_scheme} object as returned by +\code{\link[=class_api_key_security_scheme]{class_api_key_security_scheme()}} or \code{\link[=class_oauth2_security_scheme]{class_oauth2_security_scheme()}}. } \description{ \code{as_security_scheme()} turns an existing object into a \code{security_scheme} diff --git a/man/as_security_scheme_details.Rd b/man/as_security_scheme_details.Rd index 782d9d8..1db5853 100644 --- a/man/as_security_scheme_details.Rd +++ b/man/as_security_scheme_details.Rd @@ -15,13 +15,13 @@ security schemes for a single API.} } \value{ A \code{security_scheme_details} object as returned by -\code{\link[=security_scheme_details]{security_scheme_details()}}. +\code{\link[=class_security_scheme_details]{class_security_scheme_details()}}. } \description{ \code{as_security_scheme_details()} turns an existing object into a \code{security_scheme_details} object. This is in contrast with -\code{\link[=security_scheme_details]{security_scheme_details()}}, which builds a \code{security_scheme_details} from -individual properties. +\code{\link[=class_security_scheme_details]{class_security_scheme_details()}}, which builds a \code{security_scheme_details} +from individual properties. } \examples{ as_security_scheme_details() diff --git a/man/as_security_scheme_collection.Rd b/man/as_security_schemes.Rd similarity index 65% rename from man/as_security_scheme_collection.Rd rename to man/as_security_schemes.Rd index 2bda7f4..cced3fe 100644 --- a/man/as_security_scheme_collection.Rd +++ b/man/as_security_schemes.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/components-security_scheme_collection.R -\name{as_security_scheme_collection} -\alias{as_security_scheme_collection} -\title{Coerce lists to security_scheme_collection objects} +% Please edit documentation in R/components-security_schemes.R +\name{as_security_schemes} +\alias{as_security_schemes} +\title{Coerce lists to security_schemes objects} \usage{ -as_security_scheme_collection(x, ...) +as_security_schemes(x, ...) } \arguments{ \item{x}{The object to coerce. Must be empty or be a named list, where each @@ -14,18 +14,17 @@ security schemes for a single API.} \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{security_scheme_collection} object as returned by -\code{\link[=security_scheme_collection]{security_scheme_collection()}}. +A \code{security_schemes} object as returned by +\code{\link[=class_security_schemes]{class_security_schemes()}}. } \description{ -\code{as_security_scheme_collection()} turns an existing object into a -\code{security_scheme_collection} object. This is in contrast with -\code{\link[=security_scheme_collection]{security_scheme_collection()}}, which builds a \code{security_scheme_collection} -from individual properties. +\code{as_security_schemes()} turns an existing object into a \code{security_schemes} +object. This is in contrast with \code{\link[=class_security_schemes]{class_security_schemes()}}, which builds a +\code{security_schemes} from individual properties. } \examples{ -as_security_scheme_collection() -as_security_scheme_collection( +as_security_schemes() +as_security_schemes( list( accountAuth = list( description = "Account JWT token", diff --git a/man/as_server_variables.Rd b/man/as_server_variables.Rd index 314c340..c86d983 100644 --- a/man/as_server_variables.Rd +++ b/man/as_server_variables.Rd @@ -13,11 +13,11 @@ be coerced to \code{string_replacements} objects via \code{\link[=as_string_repl \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{server_variables} object as returned by \code{\link[=server_variables]{server_variables()}}. +A \code{server_variables} object as returned by \code{\link[=class_server_variables]{class_server_variables()}}. } \description{ \code{as_server_variables()} turns an existing object into a \code{server_variables} -object. This is in contrast with \code{\link[=server_variables]{server_variables()}}, which builds a +object. This is in contrast with \code{\link[=class_server_variables]{class_server_variables()}}, which builds a \code{server_variables} object from individual properties. } \examples{ diff --git a/man/as_servers.Rd b/man/as_servers.Rd index f510016..4535a05 100644 --- a/man/as_servers.Rd +++ b/man/as_servers.Rd @@ -14,11 +14,11 @@ and/or "url", or names that can be coerced to those names via \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{servers} object as returned by \code{\link[=servers]{servers()}}. +A \code{servers} object as returned by \code{\link[=class_servers]{class_servers()}}. } \description{ \code{as_servers()} turns an existing object into a \code{servers} object. This is in -contrast with \code{\link[=servers]{servers()}}, which builds a \code{servers} object from individual +contrast with \code{\link[=class_servers]{class_servers()}}, which builds a \code{servers} object from individual properties. } \examples{ diff --git a/man/as_string_replacements.Rd b/man/as_string_replacements.Rd index db2f4c8..6fa459e 100644 --- a/man/as_string_replacements.Rd +++ b/man/as_string_replacements.Rd @@ -15,12 +15,13 @@ are ignored.} \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{string_replacements} as returned by \code{\link[=string_replacements]{string_replacements()}}. +A \code{string_replacements} as returned by \code{\link[=class_string_replacements]{class_string_replacements()}}. } \description{ \code{as_string_replacements()} turns an existing object into a -\code{string_replacements}. This is in contrast with \code{\link[=string_replacements]{string_replacements()}}, -which builds a \code{string_replacements} from individual properties. +\code{string_replacements}. This is in contrast with +\code{\link[=class_string_replacements]{class_string_replacements()}}, which builds a \code{string_replacements} from +individual properties. } \examples{ as_string_replacements() diff --git a/man/api_key_security_scheme.Rd b/man/class_api_key_security_scheme.Rd similarity index 77% rename from man/api_key_security_scheme.Rd rename to man/class_api_key_security_scheme.Rd index f1cc65b..4a873c6 100644 --- a/man/api_key_security_scheme.Rd +++ b/man/class_api_key_security_scheme.Rd @@ -1,10 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components-security_scheme-api_key.R -\name{api_key_security_scheme} -\alias{api_key_security_scheme} +\name{class_api_key_security_scheme} +\alias{class_api_key_security_scheme} \title{API key security schemes} \usage{ -api_key_security_scheme(parameter_name = character(), location = character()) +class_api_key_security_scheme( + parameter_name = character(), + location = character() +) } \arguments{ \item{parameter_name}{Character vector (required). The names of the header, @@ -21,7 +24,7 @@ and \code{location}. Defines an API key security scheme that can be used by the operations. } \examples{ -api_key_security_scheme( +class_api_key_security_scheme( parameter_name = "Authorization", location = "header" ) diff --git a/man/component_collection.Rd b/man/class_components.Rd similarity index 50% rename from man/component_collection.Rd rename to man/class_components.Rd index db239eb..275c3fe 100644 --- a/man/component_collection.Rd +++ b/man/class_components.Rd @@ -1,39 +1,39 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components.R -\name{component_collection} -\alias{component_collection} +\name{class_components} +\alias{class_components} \title{An element to hold various schemas for the API} \usage{ -component_collection(..., security_schemes = security_scheme_collection()) +class_components(..., security_schemes = class_security_schemes()) } \arguments{ \item{...}{These dots are for future extensions and must be empty.} \item{security_schemes}{An object to hold reusable security scheme objects -created by \code{\link[=security_scheme_collection]{security_scheme_collection()}}.} +created by \code{\link[=class_security_schemes]{class_security_schemes()}}.} } \value{ -A \code{component_collection} S7 object with various schemas for the API. +A \code{components} S7 object with various schemas for the API. } \description{ Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. We currently only support the security_schemes object within the components -object (see \code{\link[=security_scheme_collection]{security_scheme_collection()}}). +object (see \code{\link[=class_security_schemes]{class_security_schemes()}}). } \examples{ -component_collection() -component_collection( - security_schemes = security_scheme_collection( +class_components() +class_components( + security_schemes = class_security_schemes( name = "a", - details = security_scheme_details( - api_key_security_scheme("parm", "query") + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query") ) ) ) } \seealso{ -\code{\link[=as_component_collection]{as_component_collection()}} for coercing objects to -\code{component_collection} objects. +\code{\link[=as_components]{as_components()}} for coercing objects to +\code{components} objects. } diff --git a/man/contact.Rd b/man/class_contact.Rd similarity index 86% rename from man/contact.Rd rename to man/class_contact.Rd index e9b5639..5c743cc 100644 --- a/man/contact.Rd +++ b/man/class_contact.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/info-contact.R -\name{contact} -\alias{contact} +\name{class_contact} +\alias{class_contact} \title{Contact information for the API} \usage{ -contact(name = class_missing, email = class_missing, url = class_missing) +class_contact(name = class_missing, email = class_missing, url = class_missing) } \arguments{ \item{name}{Character scalar (optional). The identifying name of the contact @@ -24,7 +24,7 @@ the API, with fields \code{name}, \code{email}, and \code{url}. A \code{contact} object provides contact information for the API. } \examples{ -contact( +class_contact( "API Support", "support@example.com", "https://www.example.com/support" diff --git a/man/info.Rd b/man/class_info.Rd similarity index 90% rename from man/info.Rd rename to man/class_info.Rd index 87c335e..2772c0e 100644 --- a/man/info.Rd +++ b/man/class_info.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/info.R -\name{info} -\alias{info} +\name{class_info} +\alias{class_info} \title{Information about the API} \usage{ -info( +class_info( title = character(), version = character(), ..., - contact = class_missing, + contact = class_contact(), description = character(), - license = class_missing, + license = class_license(), summary = character(), terms_of_service = character(), origin = class_origin() @@ -27,7 +27,7 @@ version). Required when the object is not empty.} \item{...}{These dots are for future extensions and must be empty.} \item{contact}{The contact information for the exposed API, generated via -\code{\link[=contact]{contact()}}.} +\code{\link[=class_contact]{class_contact()}}.} \item{description}{Character scalar (optional). A description of the API. \href{https://spec.commonmark.org/}{CommonMark syntax} may be used for rich text @@ -55,16 +55,16 @@ clients if needed, and may be presented in editing or documentation generation tools for convenience. } \examples{ -info() -info( +class_info() +class_info( title = "My Cool API", version = "1.0.2", - license = license( + license = class_license( name = "Apache 2.0", url = "https://opensource.org/license/apache-2-0/" ) ) -info( +class_info( title = "My Abbreviated API", version = "2.0.0", origin = "https://root.url" diff --git a/man/license.Rd b/man/class_license.Rd similarity index 87% rename from man/license.Rd rename to man/class_license.Rd index 134a45e..a67f34a 100644 --- a/man/license.Rd +++ b/man/class_license.Rd @@ -1,10 +1,15 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/info-license.R -\name{license} -\alias{license} +\name{class_license} +\alias{class_license} \title{License information for the API} \usage{ -license(name = character(), ..., identifier = character(), url = character()) +class_license( + name = character(), + ..., + identifier = character(), + url = character() +) } \arguments{ \item{name}{Character scalar (optional). The license name used for the API.} @@ -29,11 +34,11 @@ A \code{license} object provides license information for the API to describe how the API can be used. } \examples{ -license( +class_license( "Apache 2.0", identifier = "Apache-2.0" ) -license( +class_license( "Apache 2.0", url = "https://opensource.org/license/apache-2-0/" ) diff --git a/man/oauth2_authorization_code_flow.Rd b/man/class_oauth2_authorization_code_flow.Rd similarity index 79% rename from man/oauth2_authorization_code_flow.Rd rename to man/class_oauth2_authorization_code_flow.Rd index e636893..22f23ce 100644 --- a/man/oauth2_authorization_code_flow.Rd +++ b/man/class_oauth2_authorization_code_flow.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in % R/components-security_scheme-oauth2-authorization_code_flow.R -\name{oauth2_authorization_code_flow} -\alias{oauth2_authorization_code_flow} +\name{class_oauth2_authorization_code_flow} +\alias{class_oauth2_authorization_code_flow} \title{OAuth2 authorization code flow object} \usage{ -oauth2_authorization_code_flow( +class_oauth2_authorization_code_flow( authorization_url = character(), token_url = character(), ..., refresh_url = character(), - scopes = character() + scopes = class_scopes() ) } \arguments{ @@ -28,8 +28,8 @@ the use of TLS.} obtaining refresh tokens. This must be in the form of a URL. The OAuth2 standard requires the use of TLS.} -\item{scopes}{An optional \code{\link[=scopes]{scopes()}} object with the available scopes for the -OAuth2 security scheme.} +\item{scopes}{An optional \code{\link[=class_scopes]{class_scopes()}} object with the available scopes +for the OAuth2 security scheme.} } \description{ An \code{oauth2_authorization_code_flow} object describes the configuration for @@ -37,11 +37,11 @@ the OAuth Authorization Code flow. Previously called \code{accessCode} in OpenAP 2.0. } \examples{ -oauth2_authorization_code_flow( +class_oauth2_authorization_code_flow( authorization_url = "https://example.com/authorize", token_url = "https://example.com/token", refresh_url = "https://example.com/refresh", - scopes = scopes( + scopes = class_scopes( name = c("server:read", "server:write"), description = c("Read server settings", "Write server settings") ) diff --git a/man/oauth2_implicit_flow.Rd b/man/class_oauth2_implicit_flow.Rd similarity index 76% rename from man/oauth2_implicit_flow.Rd rename to man/class_oauth2_implicit_flow.Rd index 401f5c5..51f9146 100644 --- a/man/oauth2_implicit_flow.Rd +++ b/man/class_oauth2_implicit_flow.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in % R/components-security_scheme-oauth2-implicit_flow.R -\name{oauth2_implicit_flow} -\alias{oauth2_implicit_flow} +\name{class_oauth2_implicit_flow} +\alias{class_oauth2_implicit_flow} \title{OAuth2 implicit flow object} \usage{ -oauth2_implicit_flow( +class_oauth2_implicit_flow( authorization_url = character(), ..., refresh_url = character(), - scopes = character() + scopes = class_scopes() ) } \arguments{ @@ -23,15 +23,15 @@ standard requires the use of TLS.} obtaining refresh tokens. This must be in the form of a URL. The OAuth2 standard requires the use of TLS.} -\item{scopes}{An optional \code{\link[=scopes]{scopes()}} object with the available scopes for the -OAuth2 security scheme.} +\item{scopes}{An optional \code{\link[=class_scopes]{class_scopes()}} object with the available scopes +for the OAuth2 security scheme.} } \description{ An \code{oauth2_implicit_flow} object describes the configuration for the OAuth Implicit flow. } \examples{ -oauth2_implicit_flow( +class_oauth2_implicit_flow( authorization_url = "https://example.com/authorize", refresh_url = "https://example.com/refresh" ) diff --git a/man/class_oauth2_security_scheme.Rd b/man/class_oauth2_security_scheme.Rd new file mode 100644 index 0000000..3022b2e --- /dev/null +++ b/man/class_oauth2_security_scheme.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/components-security_scheme-oauth2.R +\name{class_oauth2_security_scheme} +\alias{class_oauth2_security_scheme} +\title{OAuth2 security schemes} +\usage{ +class_oauth2_security_scheme( + ..., + implicit_flow = class_oauth2_implicit_flow(), + password_flow = class_oauth2_token_flow(), + client_credentials_flow = class_oauth2_token_flow(), + authorization_code_flow = class_oauth2_authorization_code_flow() +) +} +\arguments{ +\item{...}{These dots are for future extensions and must be empty.} + +\item{implicit_flow}{An \code{oauth2_implicit_flow} object created with +\code{\link[=class_oauth2_implicit_flow]{class_oauth2_implicit_flow()}}.} + +\item{password_flow, client_credentials_flow}{An \code{oauth2_token_flow} object created with +\code{\link[=class_oauth2_token_flow]{class_oauth2_token_flow()}}.} + +\item{authorization_code_flow}{An \code{oauth2_authorization_code_flow} object +created with \code{\link[=class_oauth2_authorization_code_flow]{class_oauth2_authorization_code_flow()}}.} +} +\value{ +An \code{oauth2_security_scheme} S7 object, with fields \code{implicit_flow}, +\code{password_flow}, \code{client_credentials_flow}, and \code{authorization_code_flow}. +} +\description{ +Defines an OAuth2 security scheme that can be used by the operations. +} +\examples{ +class_oauth2_security_scheme() +class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow(token_url = "/tokens/passwords") +) +} diff --git a/man/oauth2_token_flow.Rd b/man/class_oauth2_token_flow.Rd similarity index 79% rename from man/oauth2_token_flow.Rd rename to man/class_oauth2_token_flow.Rd index 1ccc62e..6fb5795 100644 --- a/man/oauth2_token_flow.Rd +++ b/man/class_oauth2_token_flow.Rd @@ -1,14 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components-security_scheme-oauth2-token_flow.R -\name{oauth2_token_flow} -\alias{oauth2_token_flow} +\name{class_oauth2_token_flow} +\alias{class_oauth2_token_flow} \title{OAuth2 token flow object} \usage{ -oauth2_token_flow( +class_oauth2_token_flow( token_url = character(), ..., refresh_url = character(), - scopes = character() + scopes = class_scopes() ) } \arguments{ @@ -22,8 +22,8 @@ the use of TLS.} obtaining refresh tokens. This must be in the form of a URL. The OAuth2 standard requires the use of TLS.} -\item{scopes}{An optional \code{\link[=scopes]{scopes()}} object with the available scopes for the -OAuth2 security scheme.} +\item{scopes}{An optional \code{\link[=class_scopes]{class_scopes()}} object with the available scopes +for the OAuth2 security scheme.} } \value{ An \code{oauth2_token_flow} object. @@ -34,10 +34,10 @@ Resource Owner Password flow or the OAuth Client Credentials flow (previously called application in OpenAPI 2.0). } \examples{ -oauth2_token_flow( +class_oauth2_token_flow( token_url = "https://example.com/token", refresh_url = "https://example.com/refresh", - scopes = scopes( + scopes = class_scopes( name = c("server:read", "server:write"), description = c("Read server settings", "Write server settings") ) diff --git a/man/class_origin.Rd b/man/class_origin.Rd index 2b188fb..31fbc34 100644 --- a/man/class_origin.Rd +++ b/man/class_origin.Rd @@ -27,12 +27,12 @@ will be "3.0" (as in "OpenAPI Specification version 3.0"), "3.1", or a patch version of those.} } \value{ -A \code{class_origin} S7 object describing where to find the API -description, with fields \code{url}, \code{format}, and \code{version}. +An \code{origin} S7 object describing where to find the API description, +with fields \code{url}, \code{format}, and \code{version}. } \description{ -A \code{class_origin} object provides information about the primary source -document(s) used to build an API. +An \code{origin} object provides information about the primary source document(s) +used to build an API. } \examples{ class_origin( @@ -42,5 +42,5 @@ class_origin( ) } \seealso{ -\code{\link[=as_origin]{as_origin()}} for coercing objects to \code{class_origin}. +\code{\link[=as_origin]{as_origin()}} for coercing objects to \code{origin}. } diff --git a/man/class_rapid.Rd b/man/class_rapid.Rd new file mode 100644 index 0000000..39ae461 --- /dev/null +++ b/man/class_rapid.Rd @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zz-rapid.R +\name{class_rapid} +\alias{class_rapid} +\title{R API description object} +\usage{ +class_rapid( + info = class_info(), + ..., + servers = class_servers(), + components = class_components(), + security = class_security() +) +} +\arguments{ +\item{info}{An \code{info} object defined by \code{\link[=class_info]{class_info()}}.} + +\item{...}{These dots are for future extensions and must be empty.} + +\item{servers}{A \code{servers} object defined by \code{\link[=class_servers]{class_servers()}}.} + +\item{components}{A \code{components} object defined by \code{\link[=class_components]{class_components()}}.} + +\item{security}{A \code{security} object defined by \code{\link[=class_security]{class_security()}}.} +} +\value{ +A \code{rapid} S7 object, with properties \code{info}, \code{servers}, \code{components}, +and \code{security}. +} +\description{ +An object that represents an API. +} +\examples{ +class_rapid() +class_rapid( + info = class_info(title = "A", version = "1"), + servers = class_servers( + url = "https://development.gigantic-server.com/v1" + ) +) +class_rapid( + info = class_info(title = "A", version = "1"), + servers = class_servers( + url = c( + "https://development.gigantic-server.com/v1", + "https://staging.gigantic-server.com/v1", + "https://api.gigantic-server.com/v1" + ), + description = c( + "Development server", + "Staging server", + "Production server" + ) + ), + components = class_components( + security_schemes = class_security_schemes( + name = "a", + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query") + ) + ) + ) +) +} +\seealso{ +\code{\link[=as_rapid]{as_rapid()}} for coercing objects to \code{rapid}. +} diff --git a/man/scopes.Rd b/man/class_scopes.Rd similarity index 92% rename from man/scopes.Rd rename to man/class_scopes.Rd index 60b844d..46f3655 100644 --- a/man/scopes.Rd +++ b/man/class_scopes.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/components-security_scheme-oauth2-scopes.R -\name{scopes} -\alias{scopes} +\name{class_scopes} +\alias{class_scopes} \title{OAuth2 flow scopes objects} \usage{ -scopes(name = character(), description = character()) +class_scopes(name = character(), description = character()) } \arguments{ \item{name}{Character vector (required). The name of the scope.} @@ -19,7 +19,7 @@ A \code{scopes} S7 object, with fields \code{name} and \code{description}. The available scopes for an OAuth2 flow. } \examples{ -scopes( +class_scopes( name = c( "https://www.googleapis.com/auth/youtube", "https://www.googleapis.com/auth/youtube.channel-memberships.creator", diff --git a/man/security_requirements.Rd b/man/class_security.Rd similarity index 66% rename from man/security_requirements.Rd rename to man/class_security.Rd index 63dd1af..e31ee5a 100644 --- a/man/security_requirements.Rd +++ b/man/class_security.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/security_requirements.R -\name{security_requirements} -\alias{security_requirements} +% Please edit documentation in R/security.R +\name{class_security} +\alias{class_security} \title{Security schemes required to execute an operation} \usage{ -security_requirements(name = character(), ..., required_scopes = list()) +class_security(name = character(), ..., required_scopes = list()) } \arguments{ \item{name}{Character vector (required). The names must correspond to security schemes declared in the \code{security_schemes} property of a -\code{\link[=component_collection]{component_collection()}}.} +\code{\link[=class_components]{class_components()}}.} \item{...}{These dots are for future extensions and must be empty.} @@ -18,16 +18,16 @@ the scopes required for this security scheme. The vector corresponding to a given \code{name} can be empty.} } \value{ -A \code{security_requirements} S7 object with references of security -required for operations. +A \code{security} S7 object with references of security required for +operations. } \description{ The object lists the required security schemes to execute an operation or operations. } \examples{ -security_requirements() -security_requirements( +class_security() +class_security( name = c("oauth2", "internalApiKey"), required_scopes = list( c("user", "user:email", "user:follow"), diff --git a/man/class_security_scheme_details.Rd b/man/class_security_scheme_details.Rd new file mode 100644 index 0000000..fbd857a --- /dev/null +++ b/man/class_security_scheme_details.Rd @@ -0,0 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/components-security_scheme_details.R +\name{class_security_scheme_details} +\alias{class_security_scheme_details} +\title{Details of API security schemes} +\usage{ +class_security_scheme_details(...) +} +\arguments{ +\item{...}{One or more \code{\link[=abstract_security_scheme]{abstract_security_scheme()}} objects or a list of such +objects. These objects must be generated by +\code{\link[=class_api_key_security_scheme]{class_api_key_security_scheme()}} or \code{\link[=class_oauth2_security_scheme]{class_oauth2_security_scheme()}} +(\code{http_security_scheme()} and \code{open_id_connect_security_scheme()} coming +soon).} +} +\value{ +A \code{security_scheme_details} object, which is a validated list of +\code{\link[=abstract_security_scheme]{abstract_security_scheme()}} objects. +} +\description{ +The object provides a list of details of security schemes for the API. Each +element within the list is a \code{\link[=abstract_security_scheme]{abstract_security_scheme()}} object. +} +\examples{ +class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( + token_url = "/account/authorization", + scopes = class_scopes( + name = c("Catalog", "Commerce", "Playback", "Settings"), + description = c( + "Access all read-only content", + "Perform account-level transactions", + "Allow playback of restricted content", + "Modify account settings" + ) + ) + ) + ), + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( + token_url = "/account/profile/authorization", + scopes = class_scopes( + name = "Catalog", + description = "Modify profile preferences and activity" + ) + ) + ), + class_api_key_security_scheme( + parameter_name = "authorization", + location = "header" + ), + class_api_key_security_scheme( + parameter_name = "authorization", + location = "header" + ) +) +} diff --git a/man/security_scheme_collection.Rd b/man/class_security_schemes.Rd similarity index 68% rename from man/security_scheme_collection.Rd rename to man/class_security_schemes.Rd index 154a323..5d18a14 100644 --- a/man/security_scheme_collection.Rd +++ b/man/class_security_schemes.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/components-security_scheme_collection.R -\name{security_scheme_collection} -\alias{security_scheme_collection} +% Please edit documentation in R/components-security_schemes.R +\name{class_security_schemes} +\alias{class_security_schemes} \title{Reusable security schemes for an API} \usage{ -security_scheme_collection( +class_security_schemes( name = character(), - details = security_scheme_details(), + details = class_security_scheme_details(), ..., description = character() ) @@ -16,7 +16,7 @@ security_scheme_collection( be referenced.} \item{details}{The details of each security scheme, as a -\code{\link[=security_scheme_details]{security_scheme_details()}} object.} +\code{\link[=class_security_scheme_details]{class_security_scheme_details()}} object.} \item{...}{These dots are for future extensions and must be empty.} @@ -25,8 +25,8 @@ security schemes. \href{https://spec.commonmark.org/}{CommonMark syntax} may be used for rich text representation.} } \value{ -A \code{security_scheme_collection} S7 object with details about security -available for operations. +A \code{security_schemes} S7 object with details about security available +for operations. } \description{ The object provides reusable security schemes for the API. These schemes may @@ -34,17 +34,17 @@ be referenced by name in the top-level \code{security} object or within \code{pa objects. } \examples{ -security_scheme_collection() -security_scheme_collection( +class_security_schemes() +class_security_schemes( name = c( "accountAuth", "resetPasswordAuth" ), - details = security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( + details = class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -55,7 +55,7 @@ security_scheme_collection( ) ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) diff --git a/man/class_server_variables.Rd b/man/class_server_variables.Rd new file mode 100644 index 0000000..12b0a5a --- /dev/null +++ b/man/class_server_variables.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/servers-server_variables.R +\name{class_server_variables} +\alias{class_server_variables} +\title{A collection of string replacements for multiple servers} +\usage{ +class_server_variables(...) +} +\arguments{ +\item{...}{One or more \code{\link[=class_string_replacements]{class_string_replacements()}} objects, or a list of +\code{\link[=class_string_replacements]{class_string_replacements()}} objects.} +} +\value{ +A \code{server_variables} S7 object, which is a validated list of +\code{\link[=class_string_replacements]{class_string_replacements()}} objects. +} +\description{ +A list of string replacements objects, each of which is constructed with +\code{\link[=class_string_replacements]{class_string_replacements()}}. +} +\examples{ +class_server_variables( + list(class_string_replacements(), class_string_replacements()) +) +} +\seealso{ +\code{\link[=as_server_variables]{as_server_variables()}} for coercing objects to \code{server_variables}. +} diff --git a/man/servers.Rd b/man/class_servers.Rd similarity index 76% rename from man/servers.Rd rename to man/class_servers.Rd index eb00067..b28b34e 100644 --- a/man/servers.Rd +++ b/man/class_servers.Rd @@ -1,25 +1,25 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/servers.R -\name{servers} -\alias{servers} +\name{class_servers} +\alias{class_servers} \title{An object representing a collection of servers} \usage{ -servers( +class_servers( url = character(), description = character(), - variables = server_variables() + variables = class_server_variables() ) } \arguments{ \item{url}{Character vector (required). The urls of the target hosts. These -urls support \code{\link[=string_replacements]{string_replacements()}}. Variable substitutions will be made -when a variable is named in \{brackets\}.} +urls support \code{\link[=class_string_replacements]{class_string_replacements()}}. Variable substitutions will be +made when a variable is named in \{brackets\}.} \item{description}{Character vector (optional). Strings describing the hosts designated by \code{url}. \href{https://spec.commonmark.org/}{CommonMark syntax} may be used for rich text representation.} -\item{variables}{A \code{\link[=server_variables]{server_variables()}} object.} +\item{variables}{A \code{\link[=class_server_variables]{class_server_variables()}} object.} } \value{ A \code{servers} S7 object, with properties \code{url}, \code{description}, and @@ -30,7 +30,7 @@ The object provides connectivity information for the API. The described servers are intended to be used as the base urls for calls to the API. } \examples{ -servers( +class_servers( url = c( "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", @@ -42,10 +42,10 @@ servers( "Production server" ) ) -servers( +class_servers( url = "https://{username}.gigantic-server.com:{port}/{basePath}", description = "The production API server", - variables = server_variables(string_replacements( + variables = class_server_variables(class_string_replacements( name = c("username", "port", "basePath"), default = c("demo", "8443", "v2"), description = c( diff --git a/man/string_replacements.Rd b/man/class_string_replacements.Rd similarity index 86% rename from man/string_replacements.Rd rename to man/class_string_replacements.Rd index b155347..a2141a4 100644 --- a/man/string_replacements.Rd +++ b/man/class_string_replacements.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/servers-string_replacements.R -\name{string_replacements} -\alias{string_replacements} +\name{class_string_replacements} +\alias{class_string_replacements} \title{A set of variables for server URL template substitution} \usage{ -string_replacements( +class_string_replacements( name = character(), default = character(), ..., @@ -42,7 +42,7 @@ A \code{string_replacements} object describes server variable properties used fo substitution in a single server’s URL template. } \examples{ -string_replacements( +class_string_replacements( "username", "demo", enum = c("demo", "other"), @@ -51,6 +51,6 @@ string_replacements( } \seealso{ \code{\link[=as_string_replacements]{as_string_replacements()}} for coercing objects to -\code{string_replacements}, and \code{\link[=server_variables]{server_variables()}} for creating collections of -\code{string_replacements}. +\code{string_replacements}, and \code{\link[=class_server_variables]{class_server_variables()}} for creating +collections of \code{string_replacements}. } diff --git a/man/expand_servers.Rd b/man/expand_servers.Rd index 6c24ee9..6723e63 100644 --- a/man/expand_servers.Rd +++ b/man/expand_servers.Rd @@ -12,7 +12,7 @@ expand_servers(x, ...) \item{...}{These dots are for future extensions and must be empty.} } \value{ -A \code{rapid} object as returned by \code{\link[=rapid]{rapid()}}, with absolute server +A \code{rapid} object as returned by \code{\link[=class_rapid]{class_rapid()}}, with absolute server paths. } \description{ diff --git a/man/oauth2_flow.Rd b/man/oauth2_flow.Rd deleted file mode 100644 index 8f7a31f..0000000 --- a/man/oauth2_flow.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/components-security_scheme-oauth2-flow.R -\name{oauth2_flow} -\alias{oauth2_flow} -\title{OAuth2 flow object} -\usage{ -oauth2_flow(refresh_url = class_missing, scopes = class_missing) -} -\arguments{ -\item{refresh_url}{Character scalar (optional). The URL to be used for -obtaining refresh tokens. This must be in the form of a URL. The OAuth2 -standard requires the use of TLS.} - -\item{scopes}{An optional \code{\link[=scopes]{scopes()}} object with the available scopes for the -OAuth2 security scheme.} -} -\description{ -This is an abstract class that is used to define specific types of OAuth2 -flow objects. -} -\seealso{ -\code{\link[=oauth2_token_flow]{oauth2_token_flow()}}, \code{\link[=oauth2_implicit_flow]{oauth2_implicit_flow()}}, and -\code{\link[=oauth2_authorization_code_flow]{oauth2_authorization_code_flow()}} -} -\keyword{internal} diff --git a/man/oauth2_security_scheme.Rd b/man/oauth2_security_scheme.Rd deleted file mode 100644 index 5f695e6..0000000 --- a/man/oauth2_security_scheme.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/components-security_scheme-oauth2.R -\name{oauth2_security_scheme} -\alias{oauth2_security_scheme} -\title{OAuth2 security schemes} -\usage{ -oauth2_security_scheme( - ..., - implicit_flow = oauth2_implicit_flow(), - password_flow = oauth2_token_flow(), - client_credentials_flow = oauth2_token_flow(), - authorization_code_flow = oauth2_authorization_code_flow() -) -} -\arguments{ -\item{...}{These dots are for future extensions and must be empty.} - -\item{implicit_flow}{An \code{oauth2_implicit_flow} object created with -\code{\link[=oauth2_implicit_flow]{oauth2_implicit_flow()}}.} - -\item{password_flow}{An \code{oauth2_token_flow} object created with -\code{\link[=oauth2_token_flow]{oauth2_token_flow()}}.} - -\item{client_credentials_flow}{An \code{oauth2_token_flow} object created with -\code{\link[=oauth2_token_flow]{oauth2_token_flow()}}.} - -\item{authorization_code_flow}{An \code{oauth2_authorization_code_flow} object -created with \code{\link[=oauth2_authorization_code_flow]{oauth2_authorization_code_flow()}}.} -} -\value{ -An \code{oauth2_security_scheme} S7 object, with fields \code{implicit_flow}, -\code{password_flow}, \code{client_credentials_flow}, and \code{authorization_code_flow}. -} -\description{ -Defines an OAuth2 security scheme that can be used by the operations. -} -\examples{ -oauth2_security_scheme() -oauth2_security_scheme( - password_flow = oauth2_token_flow(token_url = "/tokens/passwords") -) -} diff --git a/man/rapid.Rd b/man/rapid.Rd deleted file mode 100644 index 6deed5a..0000000 --- a/man/rapid.Rd +++ /dev/null @@ -1,69 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zz-rapid.R -\name{rapid} -\alias{rapid} -\title{R API description object} -\usage{ -rapid( - info = class_missing, - ..., - servers = class_missing, - components = component_collection(), - security = security_requirements() -) -} -\arguments{ -\item{info}{An \code{info} object defined by \code{\link[=info]{info()}}.} - -\item{...}{These dots are for future extensions and must be empty.} - -\item{servers}{A \code{servers} object defined by \code{\link[=servers]{servers()}}.} - -\item{components}{A \code{component_collection} object defined by -\code{\link[=component_collection]{component_collection()}}.} - -\item{security}{A \code{security_requirements} object defined by -\code{\link[=security_requirements]{security_requirements()}}.} -} -\value{ -A \code{rapid} S7 object, with properties \code{info}, \code{servers}, \code{components}, -and \code{security}. -} -\description{ -An object that represents an API. -} -\examples{ -rapid() -rapid( - info = info(title = "A", version = "1"), - servers = servers( - url = "https://development.gigantic-server.com/v1" - ) -) -rapid( - info = info(title = "A", version = "1"), - servers = servers( - url = c( - "https://development.gigantic-server.com/v1", - "https://staging.gigantic-server.com/v1", - "https://api.gigantic-server.com/v1" - ), - description = c( - "Development server", - "Staging server", - "Production server" - ) - ), - components = component_collection( - security_schemes = security_scheme_collection( - name = "a", - details = security_scheme_details( - api_key_security_scheme("parm", "query") - ) - ) - ) -) -} -\seealso{ -\code{\link[=as_rapid]{as_rapid()}} for coercing objects to \code{rapid}. -} diff --git a/man/security_scheme_details.Rd b/man/security_scheme_details.Rd deleted file mode 100644 index e3cb919..0000000 --- a/man/security_scheme_details.Rd +++ /dev/null @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/components-security_scheme_details.R -\name{security_scheme_details} -\alias{security_scheme_details} -\title{Details of API security schemes} -\usage{ -security_scheme_details(...) -} -\arguments{ -\item{...}{One or more \code{\link[=security_scheme]{security_scheme()}} objects or a list of such objects. -These objects must be generated by \code{\link[=api_key_security_scheme]{api_key_security_scheme()}} or -\code{\link[=oauth2_security_scheme]{oauth2_security_scheme()}} (\code{http_security_scheme()} and -\code{open_id_connect_security_scheme()} coming soon).} -} -\value{ -A \code{\link[=security_scheme_details]{security_scheme_details()}} object, which is a validated list of -\code{\link[=security_scheme]{security_scheme()}} objects. -} -\description{ -The object provides a list of details of security schemes for the API. Each -element within the list is a -} -\examples{ -security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( - token_url = "/account/authorization", - scopes = scopes( - name = c("Catalog", "Commerce", "Playback", "Settings"), - description = c( - "Access all read-only content", - "Perform account-level transactions", - "Allow playback of restricted content", - "Modify account settings" - ) - ) - ) - ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( - token_url = "/account/profile/authorization", - scopes = scopes( - name = "Catalog", - description = "Modify profile preferences and activity" - ) - ) - ), - api_key_security_scheme( - parameter_name = "authorization", - location = "header" - ), - api_key_security_scheme( - parameter_name = "authorization", - location = "header" - ) -) -} diff --git a/man/server_variables.Rd b/man/server_variables.Rd deleted file mode 100644 index 378b1b9..0000000 --- a/man/server_variables.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/servers-server_variables.R -\name{server_variables} -\alias{server_variables} -\title{A collection of string replacements for multiple servers} -\usage{ -server_variables(...) -} -\arguments{ -\item{...}{One or more \code{\link[=string_replacements]{string_replacements()}} objects, or a list of -\code{\link[=string_replacements]{string_replacements()}} objects.} -} -\value{ -A \code{server_variables} S7 object, which is a validated list of -\code{\link[=string_replacements]{string_replacements()}} objects. -} -\description{ -A list of string replacements objects, each of which is constructed with -\code{\link[=string_replacements]{string_replacements()}}. -} -\examples{ -server_variables( - list(string_replacements(), string_replacements()) -) -} -\seealso{ -\code{\link[=as_server_variables]{as_server_variables()}} for coercing objects to \code{server_variables}. -} diff --git a/principles.md b/principles.md index f6e1fcf..8803b74 100644 --- a/principles.md +++ b/principles.md @@ -10,6 +10,11 @@ I also belatedly noticed that I had `server()` (singular) where the OAS specific I have updated that. Be careful to match the class names to the pluralization in the specification! +Update: Arguments that match function names (which are then called) are no bueno. +I'm using `class_{class}` for the constructor functions, similar to `class_character()`, etc, from S7. +I am doing this strictly, even for plural objects. +I hate the idea of having both singular and plural versions of objects, but I think it's worth it in order to match the schema fairly closely. + ## Specification extensions OAS allows for [Specification Extensions](https://spec.openapis.org/oas/v3.1.0#specificationExtensions), which are extra fields that begin with "x-". diff --git a/tests/testthat/_snaps/components-security_scheme-api_key.md b/tests/testthat/_snaps/components-security_scheme-api_key.md index b44a5d9..b4ade7b 100644 --- a/tests/testthat/_snaps/components-security_scheme-api_key.md +++ b/tests/testthat/_snaps/components-security_scheme-api_key.md @@ -1,17 +1,18 @@ -# api_key_security_scheme() requires that location is valid +# class_api_key_security_scheme() requires that location is valid Code - api_key_security_scheme(location = "invalid place", parameter_name = "parm1") + class_api_key_security_scheme(location = "invalid place", parameter_name = "parm1") Condition Error: ! object is invalid: - `location` must be one of the designated values. - "invalid place" is not in "query", "header", and "cookie". -# api_key_security_scheme() works with valid objects +# class_api_key_security_scheme() works with valid objects Code - test_result <- api_key_security_scheme(location = "query", parameter_name = "parm1") + test_result <- class_api_key_security_scheme(location = "query", + parameter_name = "parm1") test_result Output diff --git a/tests/testthat/_snaps/components-security_scheme-oauth2-authorization_code_flow.md b/tests/testthat/_snaps/components-security_scheme-oauth2-authorization_code_flow.md index d11cd5f..56c02d1 100644 --- a/tests/testthat/_snaps/components-security_scheme-oauth2-authorization_code_flow.md +++ b/tests/testthat/_snaps/components-security_scheme-oauth2-authorization_code_flow.md @@ -1,7 +1,7 @@ -# oauth2_authorization_code_flow() requires compatible lengths +# class_oauth2_authorization_code_flow() requires compatible lengths Code - oauth2_authorization_code_flow("a") + class_oauth2_authorization_code_flow("a") Condition Error: ! object is invalid: @@ -12,7 +12,7 @@ --- Code - oauth2_authorization_code_flow(token_url = "a") + class_oauth2_authorization_code_flow(token_url = "a") Condition Error: ! object is invalid: @@ -22,7 +22,7 @@ --- Code - oauth2_authorization_code_flow(refresh_url = "a") + class_oauth2_authorization_code_flow(refresh_url = "a") Condition Error: ! object is invalid: @@ -32,17 +32,17 @@ --- Code - oauth2_authorization_code_flow(scopes = c(a = "a")) + class_oauth2_authorization_code_flow(scopes = c(a = "a")) Condition Error: ! object is invalid: - When `authorization_url` is not defined, `scopes` must be empty. - `scopes` has 1 value. -# oauth2_authorization_code_flow() returns empty +# class_oauth2_authorization_code_flow() returns empty Code - oauth2_authorization_code_flow() + class_oauth2_authorization_code_flow() Output @ refresh_url : chr(0) @@ -52,12 +52,12 @@ @ authorization_url: chr(0) @ token_url : chr(0) -# oauth2_authorization_code_flow() requires names for optionals +# class_oauth2_authorization_code_flow() requires names for optionals Code - oauth2_authorization_code_flow("a", "b", "c") + class_oauth2_authorization_code_flow("a", "b", "c") Condition - Error in `oauth2_authorization_code_flow()`: + Error in `class_oauth2_authorization_code_flow()`: ! `...` must be empty. x Problematic argument: * ..1 = "c" @@ -66,50 +66,50 @@ --- Code - oauth2_authorization_code_flow("a", "b", refresh_url = "c", c(d = "d")) + class_oauth2_authorization_code_flow("a", "b", refresh_url = "c", c(d = "d")) Condition - Error in `oauth2_authorization_code_flow()`: + Error in `class_oauth2_authorization_code_flow()`: ! `...` must be empty. x Problematic argument: * ..1 = c(d = "d") i Did you forget to name an argument? -# oauth2_authorization_code_flow() errors for bad classes +# class_oauth2_authorization_code_flow() errors for bad classes Code - oauth2_authorization_code_flow(mean, mean) + class_oauth2_authorization_code_flow(mean, mean) Condition - Error in `oauth2_authorization_code_flow()`: + Error in `class_oauth2_authorization_code_flow()`: ! Can't coerce `authorization_url` to . --- Code - oauth2_authorization_code_flow("a", mean) + class_oauth2_authorization_code_flow("a", mean) Condition - Error in `oauth2_authorization_code_flow()`: + Error in `class_oauth2_authorization_code_flow()`: ! Can't coerce `token_url` to . --- Code - oauth2_authorization_code_flow("a", "b", refresh_url = mean) + class_oauth2_authorization_code_flow("a", "b", refresh_url = mean) Condition - Error in `oauth2_authorization_code_flow()`: + Error in `class_oauth2_authorization_code_flow()`: ! Can't coerce `refresh_url` to . --- Code - oauth2_authorization_code_flow("a", "b", refresh_url = "c", scopes = "d") + class_oauth2_authorization_code_flow("a", "b", refresh_url = "c", scopes = "d") Condition Error in `as_scopes()`: ! `scopes` must be a named character vector. -# oauth2_authorization_code_flow() returns expected objects +# class_oauth2_authorization_code_flow() returns expected objects Code - test_result <- oauth2_authorization_code_flow(authorization_url = "https://auth.ebay.com/oauth2/authorize", + test_result <- class_oauth2_authorization_code_flow(authorization_url = "https://auth.ebay.com/oauth2/authorize", token_url = "https://api.ebay.com/identity/v1/oauth2/token", scopes = c( sell.account = "View and manage your account settings", sell.account.readonly = "View your account settings"), refresh_url = "https://api.ebay.com/identity/v1/oauth2/refresh") diff --git a/tests/testthat/_snaps/components-security_scheme-oauth2-implicit_flow.md b/tests/testthat/_snaps/components-security_scheme-oauth2-implicit_flow.md index 61f6638..4c3a62c 100644 --- a/tests/testthat/_snaps/components-security_scheme-oauth2-implicit_flow.md +++ b/tests/testthat/_snaps/components-security_scheme-oauth2-implicit_flow.md @@ -1,7 +1,7 @@ -# oauth2_implicit_flow() requires compatible lengths +# class_oauth2_implicit_flow() requires compatible lengths Code - oauth2_implicit_flow(refresh_url = "a") + class_oauth2_implicit_flow(refresh_url = "a") Condition Error: ! object is invalid: @@ -11,17 +11,17 @@ --- Code - oauth2_implicit_flow(scopes = c(a = "a")) + class_oauth2_implicit_flow(scopes = c(a = "a")) Condition Error: ! object is invalid: - When `authorization_url` is not defined, `scopes` must be empty. - `scopes` has 1 value. -# oauth2_implicit_flow() returns an empty oauth2_implicit_flow +# class_oauth2_implicit_flow() returns an empty oauth2_implicit_flow Code - oauth2_implicit_flow() + class_oauth2_implicit_flow() Output @ refresh_url : chr(0) @@ -30,12 +30,12 @@ .. @ description: chr(0) @ authorization_url: chr(0) -# oauth2_implicit_flow() requires names for optionals +# class_oauth2_implicit_flow() requires names for optionals Code - oauth2_implicit_flow("a", "b", "c") + class_oauth2_implicit_flow("a", "b", "c") Condition - Error in `oauth2_implicit_flow()`: + Error in `class_oauth2_implicit_flow()`: ! `...` must be empty. x Problematic arguments: * ..1 = "b" @@ -45,42 +45,42 @@ --- Code - oauth2_implicit_flow("a", refresh_url = "c", c(d = "d")) + class_oauth2_implicit_flow("a", refresh_url = "c", c(d = "d")) Condition - Error in `oauth2_implicit_flow()`: + Error in `class_oauth2_implicit_flow()`: ! `...` must be empty. x Problematic argument: * ..1 = c(d = "d") i Did you forget to name an argument? -# oauth2_implicit_flow() errors informatively for bad classes +# class_oauth2_implicit_flow() errors informatively for bad classes Code - oauth2_implicit_flow(mean) + class_oauth2_implicit_flow(mean) Condition - Error in `oauth2_implicit_flow()`: + Error in `class_oauth2_implicit_flow()`: ! Can't coerce `authorization_url` to . --- Code - oauth2_implicit_flow("a", refresh_url = mean) + class_oauth2_implicit_flow("a", refresh_url = mean) Condition - Error in `oauth2_implicit_flow()`: + Error in `class_oauth2_implicit_flow()`: ! Can't coerce `refresh_url` to . --- Code - oauth2_implicit_flow("a", refresh_url = "c", scopes = "d") + class_oauth2_implicit_flow("a", refresh_url = "c", scopes = "d") Condition Error in `as_scopes()`: ! `scopes` must be a named character vector. -# oauth2_implicit_flow() returns expected objects +# class_oauth2_implicit_flow() returns expected objects Code - test_result <- oauth2_implicit_flow(authorization_url = "https://auth.ebay.com/oauth2/authorize", + test_result <- class_oauth2_implicit_flow(authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c(sell.account = "View and manage your account settings", sell.account.readonly = "View your account settings"), refresh_url = "https://api.ebay.com/identity/v1/oauth2/refresh") test_result diff --git a/tests/testthat/_snaps/components-security_scheme-oauth2-scopes.md b/tests/testthat/_snaps/components-security_scheme-oauth2-scopes.md index b21f9fc..f59c2c9 100644 --- a/tests/testthat/_snaps/components-security_scheme-oauth2-scopes.md +++ b/tests/testthat/_snaps/components-security_scheme-oauth2-scopes.md @@ -1,7 +1,7 @@ -# scopes() requires that description matches name +# class_scopes() requires that description matches name Code - scopes("a") + class_scopes("a") Condition Error: ! object is invalid: @@ -12,7 +12,7 @@ --- Code - scopes("a", letters) + class_scopes("a", letters) Condition Error: ! object is invalid: @@ -23,7 +23,7 @@ --- Code - scopes(letters, "a") + class_scopes(letters, "a") Condition Error: ! object is invalid: @@ -34,7 +34,7 @@ --- Code - scopes(character(), "a") + class_scopes(character(), "a") Condition Error: ! object is invalid: @@ -44,7 +44,7 @@ --- Code - scopes("a", character()) + class_scopes("a", character()) Condition Error: ! object is invalid: @@ -52,10 +52,10 @@ - `name` has 1 value. - `description` has no values. -# scopes() works with equal-length name/descript +# class_scopes() works with equal-length name/descript Code - test_result <- scopes("a", "b") + test_result <- class_scopes("a", "b") test_result Output diff --git a/tests/testthat/_snaps/components-security_scheme-oauth2-token_flow.md b/tests/testthat/_snaps/components-security_scheme-oauth2-token_flow.md index ce1cc59..b56e913 100644 --- a/tests/testthat/_snaps/components-security_scheme-oauth2-token_flow.md +++ b/tests/testthat/_snaps/components-security_scheme-oauth2-token_flow.md @@ -1,7 +1,7 @@ -# oauth2_token_flow() requires compatible lengths +# class_oauth2_token_flow() requires compatible lengths Code - oauth2_token_flow(refresh_url = "a") + class_oauth2_token_flow(refresh_url = "a") Condition Error: ! object is invalid: @@ -11,17 +11,17 @@ --- Code - oauth2_token_flow(scopes = c(a = "a")) + class_oauth2_token_flow(scopes = c(a = "a")) Condition Error: ! object is invalid: - When `token_url` is not defined, `scopes` must be empty. - `scopes` has 1 value. -# oauth2_token_flow() returns an empty oauth2_token_flow +# class_oauth2_token_flow() returns an empty oauth2_token_flow Code - oauth2_token_flow() + class_oauth2_token_flow() Output @ refresh_url: chr(0) @@ -30,12 +30,12 @@ .. @ description: chr(0) @ token_url : chr(0) -# oauth2_token_flow() requires names for optionals +# class_oauth2_token_flow() requires names for optionals Code - oauth2_token_flow("a", "b", "c") + class_oauth2_token_flow("a", "b", "c") Condition - Error in `oauth2_token_flow()`: + Error in `class_oauth2_token_flow()`: ! `...` must be empty. x Problematic arguments: * ..1 = "b" @@ -45,18 +45,18 @@ --- Code - oauth2_token_flow("a", refresh_url = "c", c(d = "d")) + class_oauth2_token_flow("a", refresh_url = "c", c(d = "d")) Condition - Error in `oauth2_token_flow()`: + Error in `class_oauth2_token_flow()`: ! `...` must be empty. x Problematic argument: * ..1 = c(d = "d") i Did you forget to name an argument? -# oauth2_token_flow() errors informatively for bad classes +# class_oauth2_token_flow() errors informatively for bad classes Code - oauth2_token_flow(mean) + class_oauth2_token_flow(mean) Condition Error: ! object properties are invalid: @@ -65,23 +65,23 @@ --- Code - oauth2_token_flow("a", refresh_url = mean) + class_oauth2_token_flow("a", refresh_url = mean) Condition - Error in `oauth2_token_flow()`: + Error in `class_oauth2_token_flow()`: ! Can't coerce `refresh_url` to . --- Code - oauth2_token_flow("a", refresh_url = "c", scopes = "d") + class_oauth2_token_flow("a", refresh_url = "c", scopes = "d") Condition Error in `as_scopes()`: ! `scopes` must be a named character vector. -# oauth2_token_flow() returns expected objects +# class_oauth2_token_flow() returns expected objects Code - test_result <- oauth2_token_flow(token_url = "https://auth.ebay.com/oauth2/token", + test_result <- class_oauth2_token_flow(token_url = "https://auth.ebay.com/oauth2/token", scopes = c(sell.account = "View and manage your account settings", sell.account.readonly = "View your account settings"), refresh_url = "https://api.ebay.com/identity/v1/oauth2/refresh") test_result diff --git a/tests/testthat/_snaps/components-security_scheme-oauth2.md b/tests/testthat/_snaps/components-security_scheme-oauth2.md index 13af8dd..ed10689 100644 --- a/tests/testthat/_snaps/components-security_scheme-oauth2.md +++ b/tests/testthat/_snaps/components-security_scheme-oauth2.md @@ -1,50 +1,50 @@ -# oauth2_security_scheme() requires names +# class_oauth2_security_scheme() requires names Code - oauth2_security_scheme(oauth2_token_flow()) + class_oauth2_security_scheme(class_oauth2_token_flow()) Condition - Error in `oauth2_security_scheme()`: + Error in `class_oauth2_security_scheme()`: ! `...` must be empty. x Problematic argument: - * ..1 = oauth2_token_flow() + * ..1 = class_oauth2_token_flow() i Did you forget to name an argument? -# oauth2_security_scheme() requires the right types of flows +# class_oauth2_security_scheme() requires the right types of flows Code - oauth2_security_scheme(implicit_flow = oauth2_token_flow()) + class_oauth2_security_scheme(implicit_flow = class_oauth2_token_flow()) Condition - Error in `oauth2_security_scheme()`: + Error in `class_oauth2_security_scheme()`: ! Can't coerce `implicit_flow` to . --- Code - oauth2_security_scheme(password_flow = oauth2_implicit_flow()) + class_oauth2_security_scheme(password_flow = class_oauth2_implicit_flow()) Condition - Error in `oauth2_security_scheme()`: + Error in `class_oauth2_security_scheme()`: ! Can't coerce `password_flow` to . --- Code - oauth2_security_scheme(client_credentials_flow = oauth2_implicit_flow()) + class_oauth2_security_scheme(client_credentials_flow = class_oauth2_implicit_flow()) Condition - Error in `oauth2_security_scheme()`: + Error in `class_oauth2_security_scheme()`: ! Can't coerce `client_credentials_flow` to . --- Code - oauth2_security_scheme(authorization_code_flow = oauth2_implicit_flow()) + class_oauth2_security_scheme(authorization_code_flow = class_oauth2_implicit_flow()) Condition - Error in `oauth2_security_scheme()`: + Error in `class_oauth2_security_scheme()`: ! Can't coerce `authorization_code_flow` to . -# oauth2_security_scheme() works with valid objects +# class_oauth2_security_scheme() works with valid objects Code - test_result <- oauth2_security_scheme(password_flow = oauth2_token_flow( + test_result <- class_oauth2_security_scheme(password_flow = class_oauth2_token_flow( token_url = "/tokens/passwords")) test_result Output diff --git a/tests/testthat/_snaps/components-security_scheme_collection.md b/tests/testthat/_snaps/components-security_scheme_collection.md deleted file mode 100644 index 2f58c7d..0000000 --- a/tests/testthat/_snaps/components-security_scheme_collection.md +++ /dev/null @@ -1,82 +0,0 @@ -# security_scheme_collection() requires name for description - - Code - security_scheme_collection("a", details = NULL, "description") - Condition - Error in `security_scheme_collection()`: - ! `...` must be empty. - x Problematic argument: - * ..1 = "description" - i Did you forget to name an argument? - -# security_scheme_collection() requires required parameters - - Code - security_scheme_collection("a") - Condition - Error: - ! object is invalid: - - `details` must have the same length as `name` - - `name` has 1 value. - - `details` has no values. - Code - security_scheme_collection(details = security_scheme_details( - api_key_security_scheme("parm", "query"))) - Condition - Error: - ! object is invalid: - - When `name` is not defined, `details` must be empty. - - `details` has 1 value. - -# security_scheme_collection() -> empty security_scheme_collection - - Code - test_result <- security_scheme_collection() - test_result - Output - - @ name : chr(0) - @ details : list() - @ description: chr(0) - -# as_security_scheme_collection() errors for unnamed input - - Code - as_security_scheme_collection(as.list(letters)) - Condition - Error in `as_security_scheme_collection()`: - ! `as.list(letters)` must have names. - -# as_security_scheme_collection() errors for bad classes - - Code - as_security_scheme_collection(letters) - Condition - Error in `as_security_scheme_collection()`: - ! `letters` must have names "name", "details", or "description". - * Any other names are ignored. - ---- - - Code - as_security_scheme_collection(1:2) - Condition - Error in `as_security_scheme_collection()`: - ! Can't coerce `1:2` to . - ---- - - Code - as_security_scheme_collection(mean) - Condition - Error in `as_security_scheme_collection()`: - ! Can't coerce `mean` to . - ---- - - Code - as_security_scheme_collection(TRUE) - Condition - Error in `as_security_scheme_collection()`: - ! Can't coerce `TRUE` to . - diff --git a/tests/testthat/_snaps/components-security_scheme_details.md b/tests/testthat/_snaps/components-security_scheme_details.md index 66fa90d..c2cb05e 100644 --- a/tests/testthat/_snaps/components-security_scheme_details.md +++ b/tests/testthat/_snaps/components-security_scheme_details.md @@ -1,7 +1,7 @@ -# security_scheme_details() errors informatively for bad contents +# class_security_scheme_details() errors informatively for bad contents Code - security_scheme_details(letters) + class_security_scheme_details(letters) Condition Error: ! object is invalid: @@ -11,7 +11,7 @@ --- Code - security_scheme_details(list(letters, letters)) + class_security_scheme_details(list(letters, letters)) Condition Error: ! object is invalid: @@ -21,25 +21,25 @@ --- Code - security_scheme_details(api_key_security_scheme(), letters, - oauth2_security_scheme(), letters) + class_security_scheme_details(class_api_key_security_scheme(), letters, + class_oauth2_security_scheme(), letters) Condition Error: ! object is invalid: - All values must be objects. - Bad values at 2 and 4. -# security_scheme_details() returns empty security_scheme_details +# class_security_scheme_details() returns empty security_scheme_details Code - security_scheme_details() + class_security_scheme_details() Output list() -# security_scheme_details() accepts bare security_schemes +# class_security_scheme_details() accepts bare security_schemes Code - security_scheme_details(api_key_security_scheme()) + class_security_scheme_details(class_api_key_security_scheme()) Output List of 1 $ : @@ -49,7 +49,8 @@ --- Code - security_scheme_details(api_key_security_scheme(), oauth2_security_scheme()) + class_security_scheme_details(class_api_key_security_scheme(), + class_oauth2_security_scheme()) Output List of 2 $ : @@ -82,10 +83,10 @@ .. .. @ authorization_url: chr(0) .. .. @ token_url : chr(0) -# security_scheme_details() accepts lists of security_schemes +# class_security_scheme_details() accepts lists of security_schemes Code - security_scheme_details(list(api_key_security_scheme())) + class_security_scheme_details(list(class_api_key_security_scheme())) Output List of 1 $ : @@ -95,7 +96,8 @@ --- Code - security_scheme_details(list(api_key_security_scheme(), oauth2_security_scheme())) + class_security_scheme_details(list(class_api_key_security_scheme(), + class_oauth2_security_scheme())) Output List of 2 $ : diff --git a/tests/testthat/_snaps/components-security_schemes.md b/tests/testthat/_snaps/components-security_schemes.md new file mode 100644 index 0000000..7812367 --- /dev/null +++ b/tests/testthat/_snaps/components-security_schemes.md @@ -0,0 +1,82 @@ +# class_security_schemes() requires name for description + + Code + class_security_schemes("a", details = NULL, "description") + Condition + Error in `class_security_schemes()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = "description" + i Did you forget to name an argument? + +# class_security_schemes() requires required parameters + + Code + class_security_schemes("a") + Condition + Error: + ! object is invalid: + - `details` must have the same length as `name` + - `name` has 1 value. + - `details` has no values. + Code + class_security_schemes(details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query"))) + Condition + Error: + ! object is invalid: + - When `name` is not defined, `details` must be empty. + - `details` has 1 value. + +# class_security_schemes() -> empty security_schemes + + Code + test_result <- class_security_schemes() + test_result + Output + + @ name : chr(0) + @ details : list() + @ description: chr(0) + +# as_security_schemes() errors for unnamed input + + Code + as_security_schemes(as.list(letters)) + Condition + Error in `as_security_schemes()`: + ! `as.list(letters)` must have names. + +# as_security_schemes() errors for bad classes + + Code + as_security_schemes(letters) + Condition + Error in `as_security_schemes()`: + ! `letters` must have names "name", "details", or "description". + * Any other names are ignored. + +--- + + Code + as_security_schemes(1:2) + Condition + Error in `as_security_schemes()`: + ! Can't coerce `1:2` to . + +--- + + Code + as_security_schemes(mean) + Condition + Error in `as_security_schemes()`: + ! Can't coerce `mean` to . + +--- + + Code + as_security_schemes(TRUE) + Condition + Error in `as_security_schemes()`: + ! Can't coerce `TRUE` to . + diff --git a/tests/testthat/_snaps/components.md b/tests/testthat/_snaps/components.md index 67de1d0..1d48880 100644 --- a/tests/testthat/_snaps/components.md +++ b/tests/testthat/_snaps/components.md @@ -1,19 +1,19 @@ -# component_collection() returns an empty component_collection +# class_components() returns an empty components Code - test_result <- component_collection() + test_result <- class_components() test_result Output - - @ security_schemes: + + @ security_schemes: .. @ name : chr(0) .. @ details : list() .. @ description: chr(0) -# as_component_collection() errors for unnamed input +# as_components() errors for unnamed input Code - as_component_collection(as.list(letters)) + as_components(as.list(letters)) Condition Error: ! `as.list(letters)` must have names "security_schemes". @@ -22,33 +22,33 @@ --- Code - as_component_collection(list("My Cool API")) + as_components(list("My Cool API")) Condition Error: ! `list("My Cool API")` must have names "security_schemes". * Any other names are ignored. -# as_component_collection() errors informatively for bad classes +# as_components() errors informatively for bad classes Code - as_component_collection(1:2) + as_components(1:2) Condition Error: - ! Can't coerce `1:2` to . + ! Can't coerce `1:2` to . --- Code - as_component_collection(mean) + as_components(mean) Condition Error: - ! Can't coerce `mean` to . + ! Can't coerce `mean` to . --- Code - as_component_collection(TRUE) + as_components(TRUE) Condition Error: - ! Can't coerce `TRUE` to . + ! Can't coerce `TRUE` to . diff --git a/tests/testthat/_snaps/info-contact.md b/tests/testthat/_snaps/info-contact.md index 7482fa2..934f6e1 100644 --- a/tests/testthat/_snaps/info-contact.md +++ b/tests/testthat/_snaps/info-contact.md @@ -1,51 +1,51 @@ -# contact() errors informatively for bad name +# class_contact() errors informatively for bad name Code - contact(name = mean) + class_contact(name = mean) Condition - Error in `contact()`: + Error in `class_contact()`: ! Can't coerce `name` to . --- Code - contact(name = c("A", "B")) + class_contact(name = c("A", "B")) Condition - Error in `contact()`: + Error in `class_contact()`: ! `name` must be a single . x `name` has 2 values. -# contact() errors informatively for bad email +# class_contact() errors informatively for bad email Code - contact(name = "A", url = "https://example.com", email = mean) + class_contact(name = "A", url = "https://example.com", email = mean) Condition - Error in `contact()`: + Error in `class_contact()`: ! Can't coerce `email` to . --- Code - contact(name = "A", url = "https://example.com", email = c("A", "B")) + class_contact(name = "A", url = "https://example.com", email = c("A", "B")) Condition - Error in `contact()`: + Error in `class_contact()`: ! `email` must be a single . x `email` has 2 values. --- Code - contact(name = "A", url = "https://example.com", email = "not a real email") + class_contact(name = "A", url = "https://example.com", email = "not a real email") Condition - Error in `contact()`: + Error in `class_contact()`: ! `email` must match the provided regex pattern. x Some values do not match. * Locations: 1 -# contact() returns a contact when everything is ok +# class_contact() returns a contact when everything is ok Code - test_result <- contact(name = "A", url = "https://example.com", email = "real.email@address.place") + test_result <- class_contact(name = "A", url = "https://example.com", email = "real.email@address.place") test_result Output @@ -53,10 +53,10 @@ @ email: chr "real.email@address.place" @ url : chr "https://example.com" -# contact() without args returns an empty contact +# class_contact() without args returns an empty contact Code - test_result <- contact() + test_result <- class_contact() test_result Output diff --git a/tests/testthat/_snaps/info-license.md b/tests/testthat/_snaps/info-license.md index dbd5788..78356d4 100644 --- a/tests/testthat/_snaps/info-license.md +++ b/tests/testthat/_snaps/info-license.md @@ -1,67 +1,67 @@ -# license() errors informatively for bad name +# class_license() errors informatively for bad name Code - license(name = mean) + class_license(name = mean) Condition - Error in `license()`: + Error in `class_license()`: ! Can't coerce `name` to . --- Code - license(name = c("A", "B")) + class_license(name = c("A", "B")) Condition - Error in `license()`: + Error in `class_license()`: ! `name` must be a single . x `name` has 2 values. -# license() errors informatively for bad url +# class_license() errors informatively for bad url Code - license(name = "A", url = mean) + class_license(name = "A", url = mean) Condition - Error in `license()`: + Error in `class_license()`: ! Can't coerce `url` to . --- Code - license(name = "A", url = c("A", "B")) + class_license(name = "A", url = c("A", "B")) Condition - Error in `license()`: + Error in `class_license()`: ! `url` must be a single . x `url` has 2 values. -# license() errors informatively for bad identifier +# class_license() errors informatively for bad identifier Code - license(name = "A", identifier = mean) + class_license(name = "A", identifier = mean) Condition - Error in `license()`: + Error in `class_license()`: ! Can't coerce `identifier` to . --- Code - license(name = "A", identifier = c("A", "B")) + class_license(name = "A", identifier = c("A", "B")) Condition - Error in `license()`: + Error in `class_license()`: ! `identifier` must be a single . x `identifier` has 2 values. -# license() errors when both url and identifier are supplied +# class_license() errors when both url and identifier are supplied Code - license(name = "A", identifier = "A", url = "https://example.com") + class_license(name = "A", identifier = "A", url = "https://example.com") Condition Error: ! object is invalid: - At most one of @identifier and @url must be supplied. -# license() fails when name is missing +# class_license() fails when name is missing Code - license(identifier = "A") + class_license(identifier = "A") Condition Error: ! object is invalid: @@ -71,28 +71,28 @@ --- Code - license(url = "https://example.com") + class_license(url = "https://example.com") Condition Error: ! object is invalid: - When `name` is not defined, `url` must be empty. - `url` has 1 value. -# license() doesn't match identifier by position +# class_license() doesn't match identifier by position Code - license(name = "A", "https://example.com") + class_license(name = "A", "https://example.com") Condition - Error in `license()`: + Error in `class_license()`: ! `...` must be empty. x Problematic argument: * ..1 = "https://example.com" i Did you forget to name an argument? -# license() returns a license when everything is ok +# class_license() returns a license when everything is ok Code - test_result <- license(name = "A", url = "https://example.com") + test_result <- class_license(name = "A", url = "https://example.com") test_result Output @@ -103,7 +103,7 @@ --- Code - test_result <- license(name = "A", identifier = "technically these have a fancy required format") + test_result <- class_license(name = "A", identifier = "technically these have a fancy required format") test_result Output diff --git a/tests/testthat/_snaps/info.md b/tests/testthat/_snaps/info.md index 2f1bc80..69c3613 100644 --- a/tests/testthat/_snaps/info.md +++ b/tests/testthat/_snaps/info.md @@ -1,7 +1,7 @@ -# info() validates property length. +# class_info() validates property length. Code - info(title = "My API") + class_info(title = "My API") Condition Error: ! object is invalid: @@ -12,7 +12,7 @@ --- Code - info(version = "My API") + class_info(version = "My API") Condition Error: ! object is invalid: @@ -22,17 +22,17 @@ --- Code - info(summary = "My API") + class_info(summary = "My API") Condition Error: ! object is invalid: - When `title` is not defined, `summary` must be empty. - `summary` has 1 value. -# info() returns an empty info +# class_info() returns an empty info Code - test_result <- info() + test_result <- class_info() test_result Output @@ -49,7 +49,7 @@ .. @ url : chr(0) @ summary : chr(0) @ terms_of_service: chr(0) - @ origin : + @ origin : .. @ url : chr(0) .. @ format : chr(0) .. @ version: chr(0) diff --git a/tests/testthat/_snaps/security.md b/tests/testthat/_snaps/security.md new file mode 100644 index 0000000..4b87067 --- /dev/null +++ b/tests/testthat/_snaps/security.md @@ -0,0 +1,45 @@ +# class_security() requires parallel parameters + + Code + class_security(required_scopes = "a") + Condition + Error: + ! object is invalid: + - When `name` is not defined, `required_scopes` must be empty. + - `required_scopes` has 1 value. + +# class_security() rapid_class_requirement field is fixed + + Code + test_result <- class_security() + test_result + Output + + @ name : chr(0) + @ required_scopes : list() + @ rapid_class_requirement: chr "security_scheme" + +# as_security() fails for bad classes + + Code + as_security(x) + Condition + Error in `as_security()`: + ! Can't coerce `x` to . + +--- + + Code + as_security(x) + Condition + Error in `as_security()`: + ! Can't coerce `x` to . + +--- + + Code + as_security(x) + Condition + Error in `as_security()`: + ! Can't coerce `x` to . + diff --git a/tests/testthat/_snaps/security_requirements.md b/tests/testthat/_snaps/security_requirements.md deleted file mode 100644 index 4400867..0000000 --- a/tests/testthat/_snaps/security_requirements.md +++ /dev/null @@ -1,45 +0,0 @@ -# security_requirements() requires parallel parameters - - Code - security_requirements(required_scopes = "a") - Condition - Error: - ! object is invalid: - - When `name` is not defined, `required_scopes` must be empty. - - `required_scopes` has 1 value. - -# security_requirements() rapid_class_requirement field is fixed - - Code - test_result <- security_requirements() - test_result - Output - - @ name : chr(0) - @ required_scopes : list() - @ rapid_class_requirement: chr "security_scheme" - -# as_security_requirements() fails for bad classes - - Code - as_security_requirements(x) - Condition - Error in `as_security_requirements()`: - ! Can't coerce `x` to . - ---- - - Code - as_security_requirements(x) - Condition - Error in `as_security_requirements()`: - ! Can't coerce `x` to . - ---- - - Code - as_security_requirements(x) - Condition - Error in `as_security_requirements()`: - ! Can't coerce `x` to . - diff --git a/tests/testthat/_snaps/servers-server_variables.md b/tests/testthat/_snaps/servers-server_variables.md index 12a8e6e..e217b44 100644 --- a/tests/testthat/_snaps/servers-server_variables.md +++ b/tests/testthat/_snaps/servers-server_variables.md @@ -1,7 +1,7 @@ -# server_variables() errors informatively for bad contents +# class_server_variables() errors informatively for bad contents Code - server_variables(letters) + class_server_variables(letters) Condition Error: ! object is invalid: @@ -11,7 +11,7 @@ --- Code - server_variables(list(letters, letters)) + class_server_variables(list(letters, letters)) Condition Error: ! object is invalid: @@ -21,24 +21,25 @@ --- Code - server_variables(string_replacements(), letters, string_replacements(), letters) + class_server_variables(class_string_replacements(), letters, + class_string_replacements(), letters) Condition Error: ! object is invalid: - All values must be objects. - Bad values at 2 and 4. -# server_variables() returns an empty server_variables +# class_server_variables() returns an empty server_variables Code - server_variables() + class_server_variables() Output list() -# server_variables() accepts bare string_replacements +# class_server_variables() accepts bare string_replacements Code - server_variables(string_replacements()) + class_server_variables(class_string_replacements()) Output List of 1 $ : @@ -50,7 +51,7 @@ --- Code - server_variables(string_replacements(), string_replacements()) + class_server_variables(class_string_replacements(), class_string_replacements()) Output List of 2 $ : @@ -64,10 +65,10 @@ ..@ enum : list() ..@ description: chr(0) -# server_variables() accepts lists of string_replacements +# class_server_variables() accepts lists of string_replacements Code - server_variables(list(string_replacements())) + class_server_variables(list(class_string_replacements())) Output List of 1 $ : @@ -79,7 +80,8 @@ --- Code - server_variables(list(string_replacements(), string_replacements())) + class_server_variables(list(class_string_replacements(), + class_string_replacements())) Output List of 2 $ : diff --git a/tests/testthat/_snaps/servers-string_replacements.md b/tests/testthat/_snaps/servers-string_replacements.md index c3d03b1..5e3f41a 100644 --- a/tests/testthat/_snaps/servers-string_replacements.md +++ b/tests/testthat/_snaps/servers-string_replacements.md @@ -1,18 +1,18 @@ -# string_replacements() requires names for optional args +# class_string_replacements() requires names for optional args Code - string_replacements("a", "b", "c") + class_string_replacements("a", "b", "c") Condition - Error in `string_replacements()`: + Error in `class_string_replacements()`: ! `...` must be empty. x Problematic argument: * ..1 = "c" i Did you forget to name an argument? -# string_replacements() requires that default matches name +# class_string_replacements() requires that default matches name Code - string_replacements("a") + class_string_replacements("a") Condition Error: ! object is invalid: @@ -23,7 +23,7 @@ --- Code - string_replacements("a", letters) + class_string_replacements("a", letters) Condition Error: ! object is invalid: @@ -34,7 +34,7 @@ --- Code - string_replacements(letters, "a") + class_string_replacements(letters, "a") Condition Error: ! object is invalid: @@ -45,17 +45,17 @@ --- Code - string_replacements(character(), "a") + class_string_replacements(character(), "a") Condition Error: ! object is invalid: - When `name` is not defined, `default` must be empty. - `default` has 1 value. -# string_replacements() works with equal-length name/default +# class_string_replacements() works with equal-length name/default Code - test_result <- string_replacements("a", "b") + test_result <- class_string_replacements("a", "b") test_result Output @@ -64,10 +64,10 @@ @ enum : list() @ description: chr(0) -# string_replacements() requires optional args are empty or match +# class_string_replacements() requires optional args are empty or match Code - string_replacements("a", "b", enum = list("a", "b")) + class_string_replacements("a", "b", enum = list("a", "b")) Condition Error: ! object is invalid: @@ -78,7 +78,7 @@ --- Code - string_replacements("a", "b", description = c("a", "b")) + class_string_replacements("a", "b", description = c("a", "b")) Condition Error: ! object is invalid: @@ -86,10 +86,10 @@ - `name` has 1 value. - `description` has 2 values. -# string_replacements() requires default is in enum when given +# class_string_replacements() requires default is in enum when given Code - string_replacements(name = "a", default = "b", enum = "a") + class_string_replacements(name = "a", default = "b", enum = "a") Condition Error: ! object is invalid: @@ -99,20 +99,21 @@ --- Code - string_replacements(name = c("a", "b"), default = c("b", "a"), enum = list("a", - "a")) + class_string_replacements(name = c("a", "b"), default = c("b", "a"), enum = list( + "a", "a")) Condition Error: ! object is invalid: - `default` must be in `enum`. - "b" is not in "a". -# string_replacements() works for a full object +# class_string_replacements() works for a full object Code - test_result <- string_replacements(name = c("username", "port", "basePath"), - default = c("demo", "8443", "v2"), description = c("The active user's folder.", - NA, NA), enum = list(NULL, c("8443", "443"), NULL)) + test_result <- class_string_replacements(name = c("username", "port", + "basePath"), default = c("demo", "8443", "v2"), description = c( + "The active user's folder.", NA, NA), enum = list(NULL, c("8443", "443"), + NULL)) test_result Output diff --git a/tests/testthat/_snaps/servers.md b/tests/testthat/_snaps/servers.md index 288ad4c..deb931e 100644 --- a/tests/testthat/_snaps/servers.md +++ b/tests/testthat/_snaps/servers.md @@ -1,7 +1,7 @@ -# servers() returns an empty server +# class_servers() returns an empty server Code - test_result <- servers() + test_result <- class_servers() test_result Output diff --git a/tests/testthat/_snaps/zz-rapid.md b/tests/testthat/_snaps/zz-rapid.md index a427f3b..6a638e9 100644 --- a/tests/testthat/_snaps/zz-rapid.md +++ b/tests/testthat/_snaps/zz-rapid.md @@ -1,15 +1,16 @@ -# rapid() requires info objects for info +# class_rapid() requires info objects for info Code - rapid(info = mean) + class_rapid(info = mean) Condition - Error in `rapid()`: + Error in `class_rapid()`: ! Can't coerce `info` to . -# rapid() requires info when anything is defined +# class_rapid() requires info when anything is defined Code - rapid(servers = servers(url = c("https://development.gigantic-server.com/v1", + class_rapid(servers = class_servers(url = c( + "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", "https://api.gigantic-server.com/v1"), description = c("Development server", "Staging server", "Production server"))) @@ -22,20 +23,20 @@ # security must reference components@security_schemes Code - rapid(info = info(title = "A", version = "1"), components = component_collection( - security_schemes = security_scheme_collection(name = "the_defined_one", - details = security_scheme_details(api_key_security_scheme("this_one", - location = "header")))), security = security_requirements(name = "an_undefined_one")) + class_rapid(info = class_info(title = "A", version = "1"), components = class_components( + security_schemes = class_security_schemes(name = "the_defined_one", details = class_security_scheme_details( + class_api_key_security_scheme("this_one", location = "header")))), + security = class_security(name = "an_undefined_one")) Condition Error: ! object is invalid: - `security` must be one of the `security_schemes` defined in `components`. - "an_undefined_one" is not in "the_defined_one". -# rapid() returns an empty rapid +# class_rapid() returns an empty rapid Code - test_result <- rapid() + test_result <- class_rapid() test_result Output @@ -53,7 +54,7 @@ .. .. @ url : chr(0) .. @ summary : chr(0) .. @ terms_of_service: chr(0) - .. @ origin : + .. @ origin : .. .. @ url : chr(0) .. .. @ format : chr(0) .. .. @ version: chr(0) @@ -61,12 +62,12 @@ .. @ url : chr(0) .. @ description: chr(0) .. @ variables : list() - @ components: - .. @ security_schemes: + @ components: + .. @ security_schemes: .. .. @ name : chr(0) .. .. @ details : list() .. .. @ description: chr(0) - @ security : + @ security : .. @ name : chr(0) .. @ required_scopes : list() .. @ rapid_class_requirement: chr "security_scheme" @@ -137,7 +138,7 @@ .. .. @ url : chr "http://www.apache.org/licenses/" .. @ summary : chr(0) .. @ terms_of_service: chr "https://aws.amazon.com/service-terms/" - .. @ origin : + .. @ origin : .. .. @ url : chr "https://raw.githubusercontent.com/aws/aws-sdk-js/master/apis/AWSMigrationHub-2017-05-31.normal.json" .. .. @ format : chr(0) .. .. @ version: chr(0) @@ -169,15 +170,15 @@ .. .. ..@ enum :List of 1 .. .. .. .. $ : chr [1:2] "cn-north-1" "cn-northwest-1" .. .. ..@ description: chr "The AWS region" - @ components: - .. @ security_schemes: + @ components: + .. @ security_schemes: .. .. @ name : chr "hmac" .. .. @ details : List of 1 .. .. .. $ : .. .. .. ..@ parameter_name: chr "Authorization" .. .. .. ..@ location : chr "header" .. .. @ description: chr "Amazon Signature authorization v4" - @ security : + @ security : .. @ name : chr "hmac" .. @ required_scopes :List of 1 .. .. $ : chr(0) @@ -203,7 +204,7 @@ .. .. @ url : chr "http://www.apache.org/licenses/" .. @ summary : chr(0) .. @ terms_of_service: chr "https://aws.amazon.com/service-terms/" - .. @ origin : + .. @ origin : .. .. @ url : chr "https://raw.githubusercontent.com/aws/aws-sdk-js/master/apis/AWSMigrationHub-2017-05-31.normal.json" .. .. @ format : chr(0) .. .. @ version: chr(0) @@ -235,15 +236,15 @@ .. .. ..@ enum :List of 1 .. .. .. .. $ : chr [1:2] "cn-north-1" "cn-northwest-1" .. .. ..@ description: chr "The AWS region" - @ components: - .. @ security_schemes: + @ components: + .. @ security_schemes: .. .. @ name : chr "hmac" .. .. @ details : List of 1 .. .. .. $ : .. .. .. ..@ parameter_name: chr "Authorization" .. .. .. ..@ location : chr "header" .. .. @ description: chr "Amazon Signature authorization v4" - @ security : + @ security : .. @ name : chr "hmac" .. @ required_scopes :List of 1 .. .. $ : chr(0) @@ -269,7 +270,7 @@ .. .. @ url : chr(0) .. @ summary : chr(0) .. @ terms_of_service: chr(0) - .. @ origin : + .. @ origin : .. .. @ url : chr "https://api.open.fec.gov/swagger/" .. .. @ format : chr(0) .. .. @ version: chr(0) @@ -277,12 +278,12 @@ .. @ url : chr(0) .. @ description: chr(0) .. @ variables : list() - @ components: - .. @ security_schemes: + @ components: + .. @ security_schemes: .. .. @ name : chr(0) .. .. @ details : list() .. .. @ description: chr(0) - @ security : + @ security : .. @ name : chr [1:3] "ApiKeyHeaderAuth" "ApiKeyQueryAuth" "apiKey" .. @ required_scopes :List of 3 .. .. $ : chr(0) @@ -310,7 +311,7 @@ .. .. @ url : chr(0) .. @ summary : chr(0) .. @ terms_of_service: chr(0) - .. @ origin : + .. @ origin : .. .. @ url : chr "https://api.open.fec.gov/swagger/" .. .. @ format : chr "openapi" .. .. @ version: chr "3.0" @@ -318,8 +319,8 @@ .. @ url : chr "https://api.open.fec.gov/v1" .. @ description: chr(0) .. @ variables : list() - @ components: - .. @ security_schemes: + @ components: + .. @ security_schemes: .. .. @ name : chr [1:3] "ApiKeyHeaderAuth" "ApiKeyQueryAuth" "apiKey" .. .. @ details : List of 3 .. .. .. $ : @@ -332,7 +333,7 @@ .. .. .. ..@ parameter_name: chr "api_key" .. .. .. ..@ location : chr "query" .. .. @ description: chr(0) - @ security : + @ security : .. @ name : chr [1:3] "ApiKeyHeaderAuth" "ApiKeyQueryAuth" "apiKey" .. @ required_scopes :List of 3 .. .. $ : chr(0) diff --git a/tests/testthat/test-components-security_scheme-api_key.R b/tests/testthat/test-components-security_scheme-api_key.R index 2cd2eec..608b344 100644 --- a/tests/testthat/test-components-security_scheme-api_key.R +++ b/tests/testthat/test-components-security_scheme-api_key.R @@ -1,6 +1,6 @@ -test_that("api_key_security_scheme() requires that location is valid", { +test_that("class_api_key_security_scheme() requires that location is valid", { expect_snapshot( - api_key_security_scheme( + class_api_key_security_scheme( location = "invalid place", parameter_name = "parm1" ), @@ -8,9 +8,9 @@ test_that("api_key_security_scheme() requires that location is valid", { ) }) -test_that("api_key_security_scheme() works with valid objects", { +test_that("class_api_key_security_scheme() works with valid objects", { expect_snapshot({ - test_result <- api_key_security_scheme( + test_result <- class_api_key_security_scheme( location = "query", parameter_name = "parm1" ) @@ -32,10 +32,10 @@ test_that("api_key_security_scheme() works with valid objects", { }) test_that("length() of a api_key_security_scheme reports the proper length", { - expect_equal(length(api_key_security_scheme()), 0) + expect_equal(length(class_api_key_security_scheme()), 0) expect_equal( length( - api_key_security_scheme(location = "header", parameter_name = "parm2") + class_api_key_security_scheme(location = "header", parameter_name = "parm2") ), 1 ) @@ -84,7 +84,7 @@ test_that("as_api_key_security_scheme() returns expected objects", { `x-amazon-apigateway-authtype` = "awsSigv4" ) )), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "Authorization", location = "header" ) @@ -96,7 +96,7 @@ test_that("as_api_key_security_scheme() returns expected objects", { `in` = "cookie" ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "X-APISETU-CLIENTID", location = "cookie" ) @@ -108,7 +108,7 @@ test_that("as_api_key_security_scheme() returns expected objects", { location = "query" ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "X-APISETU-APIKEY", location = "query" ) @@ -116,13 +116,13 @@ test_that("as_api_key_security_scheme() returns expected objects", { expect_identical( as_api_key_security_scheme(list()), - api_key_security_scheme() + class_api_key_security_scheme() ) }) test_that("as_api_key_security_scheme() works for api_key_security_scheme", { expect_identical( - as_api_key_security_scheme(api_key_security_scheme()), - api_key_security_scheme() + as_api_key_security_scheme(class_api_key_security_scheme()), + class_api_key_security_scheme() ) }) diff --git a/tests/testthat/test-components-security_scheme-oauth2-authorization_code_flow.R b/tests/testthat/test-components-security_scheme-oauth2-authorization_code_flow.R index 205b4e8..93f1c48 100644 --- a/tests/testthat/test-components-security_scheme-oauth2-authorization_code_flow.R +++ b/tests/testthat/test-components-security_scheme-oauth2-authorization_code_flow.R @@ -1,59 +1,59 @@ -test_that("oauth2_authorization_code_flow() requires compatible lengths", { +test_that("class_oauth2_authorization_code_flow() requires compatible lengths", { expect_snapshot( - oauth2_authorization_code_flow("a"), + class_oauth2_authorization_code_flow("a"), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow(token_url = "a"), + class_oauth2_authorization_code_flow(token_url = "a"), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow(refresh_url = "a"), + class_oauth2_authorization_code_flow(refresh_url = "a"), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow(scopes = c("a" = "a")), + class_oauth2_authorization_code_flow(scopes = c("a" = "a")), error = TRUE ) }) -test_that("oauth2_authorization_code_flow() returns empty", { - expect_snapshot(oauth2_authorization_code_flow()) +test_that("class_oauth2_authorization_code_flow() returns empty", { + expect_snapshot(class_oauth2_authorization_code_flow()) }) -test_that("oauth2_authorization_code_flow() requires names for optionals", { +test_that("class_oauth2_authorization_code_flow() requires names for optionals", { expect_snapshot( - oauth2_authorization_code_flow("a", "b", "c"), + class_oauth2_authorization_code_flow("a", "b", "c"), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow("a", "b", refresh_url = "c", c("d" = "d")), + class_oauth2_authorization_code_flow("a", "b", refresh_url = "c", c("d" = "d")), error = TRUE ) }) -test_that("oauth2_authorization_code_flow() errors for bad classes", { +test_that("class_oauth2_authorization_code_flow() errors for bad classes", { expect_snapshot( - oauth2_authorization_code_flow(mean, mean), + class_oauth2_authorization_code_flow(mean, mean), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow("a", mean), + class_oauth2_authorization_code_flow("a", mean), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow("a", "b", refresh_url = mean), + class_oauth2_authorization_code_flow("a", "b", refresh_url = mean), error = TRUE ) expect_snapshot( - oauth2_authorization_code_flow("a", "b", refresh_url = "c", scopes = "d"), + class_oauth2_authorization_code_flow("a", "b", refresh_url = "c", scopes = "d"), error = TRUE ) }) -test_that("oauth2_authorization_code_flow() returns expected objects", { +test_that("class_oauth2_authorization_code_flow() returns expected objects", { expect_snapshot({ - test_result <- oauth2_authorization_code_flow( + test_result <- class_oauth2_authorization_code_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", token_url = "https://api.ebay.com/identity/v1/oauth2/token", scopes = c( @@ -80,11 +80,11 @@ test_that("oauth2_authorization_code_flow() returns expected objects", { }) test_that("length() of oauth2_authorization_code_flow reports overall length", { - expect_equal(length(oauth2_authorization_code_flow()), 0) - expect_equal(length(oauth2_authorization_code_flow("A", "B")), 1) + expect_equal(length(class_oauth2_authorization_code_flow()), 0) + expect_equal(length(class_oauth2_authorization_code_flow("A", "B")), 1) expect_equal( length( - oauth2_authorization_code_flow("A", "B", scopes = c("a" = "a", "b" = "b")) + class_oauth2_authorization_code_flow("A", "B", scopes = c("a" = "a", "b" = "b")) ), 1 ) @@ -124,7 +124,7 @@ test_that("as_oauth2_authorization_code_flow() returns expected objects", { token_url = "https://api.ebay.com/identity/v1/oauth2/token" ) ), - oauth2_authorization_code_flow( + class_oauth2_authorization_code_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c( sell.account = "View and manage your account settings", @@ -136,12 +136,12 @@ test_that("as_oauth2_authorization_code_flow() returns expected objects", { expect_identical( as_oauth2_authorization_code_flow(list()), - oauth2_authorization_code_flow() + class_oauth2_authorization_code_flow() ) expect_identical( as_oauth2_authorization_code_flow(character()), - oauth2_authorization_code_flow() + class_oauth2_authorization_code_flow() ) }) @@ -157,7 +157,7 @@ test_that("as_oauth2_authorization_code_flow() works for alternate names", { tokenUrl = "https://api.ebay.com/identity/v1/oauth2/token" ) ), - oauth2_authorization_code_flow( + class_oauth2_authorization_code_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c( sell.account = "View and manage your account settings", @@ -170,7 +170,7 @@ test_that("as_oauth2_authorization_code_flow() works for alternate names", { test_that("as_oauth2_authorization_code_flow() works w/ itself", { expect_identical( - as_oauth2_authorization_code_flow(oauth2_authorization_code_flow()), - oauth2_authorization_code_flow() + as_oauth2_authorization_code_flow(class_oauth2_authorization_code_flow()), + class_oauth2_authorization_code_flow() ) }) diff --git a/tests/testthat/test-components-security_scheme-oauth2-implicit_flow.R b/tests/testthat/test-components-security_scheme-oauth2-implicit_flow.R index bd29db8..b7ed577 100644 --- a/tests/testthat/test-components-security_scheme-oauth2-implicit_flow.R +++ b/tests/testthat/test-components-security_scheme-oauth2-implicit_flow.R @@ -1,47 +1,47 @@ -test_that("oauth2_implicit_flow() requires compatible lengths", { +test_that("class_oauth2_implicit_flow() requires compatible lengths", { expect_snapshot( - oauth2_implicit_flow(refresh_url = "a"), + class_oauth2_implicit_flow(refresh_url = "a"), error = TRUE ) expect_snapshot( - oauth2_implicit_flow(scopes = c("a" = "a")), + class_oauth2_implicit_flow(scopes = c("a" = "a")), error = TRUE ) }) -test_that("oauth2_implicit_flow() returns an empty oauth2_implicit_flow", { - expect_snapshot(oauth2_implicit_flow()) +test_that("class_oauth2_implicit_flow() returns an empty oauth2_implicit_flow", { + expect_snapshot(class_oauth2_implicit_flow()) }) -test_that("oauth2_implicit_flow() requires names for optionals", { +test_that("class_oauth2_implicit_flow() requires names for optionals", { expect_snapshot( - oauth2_implicit_flow("a", "b", "c"), + class_oauth2_implicit_flow("a", "b", "c"), error = TRUE ) expect_snapshot( - oauth2_implicit_flow("a", refresh_url = "c", c("d" = "d")), + class_oauth2_implicit_flow("a", refresh_url = "c", c("d" = "d")), error = TRUE ) }) -test_that("oauth2_implicit_flow() errors informatively for bad classes", { +test_that("class_oauth2_implicit_flow() errors informatively for bad classes", { expect_snapshot( - oauth2_implicit_flow(mean), + class_oauth2_implicit_flow(mean), error = TRUE ) expect_snapshot( - oauth2_implicit_flow("a", refresh_url = mean), + class_oauth2_implicit_flow("a", refresh_url = mean), error = TRUE ) expect_snapshot( - oauth2_implicit_flow("a", refresh_url = "c", scopes = "d"), + class_oauth2_implicit_flow("a", refresh_url = "c", scopes = "d"), error = TRUE ) }) -test_that("oauth2_implicit_flow() returns expected objects", { +test_that("class_oauth2_implicit_flow() returns expected objects", { expect_snapshot({ - test_result <- oauth2_implicit_flow( + test_result <- class_oauth2_implicit_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c( sell.account = "View and manage your account settings", @@ -67,10 +67,10 @@ test_that("oauth2_implicit_flow() returns expected objects", { }) test_that("length() of an oauth2_implicit_flow reports the overall length", { - expect_equal(length(oauth2_implicit_flow()), 0) - expect_equal(length(oauth2_implicit_flow("A")), 1) + expect_equal(length(class_oauth2_implicit_flow()), 0) + expect_equal(length(class_oauth2_implicit_flow("A")), 1) expect_equal( - length(oauth2_implicit_flow("A", scopes = c("a" = "a", "b" = "b"))), + length(class_oauth2_implicit_flow("A", scopes = c("a" = "a", "b" = "b"))), 1 ) }) @@ -109,7 +109,7 @@ test_that("as_oauth2_implicit_flow() returns expected objects", { refresh_url = "https://api.ebay.com/identity/v1/oauth2/refresh" ) ), - oauth2_implicit_flow( + class_oauth2_implicit_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c( sell.account = "View and manage your account settings", @@ -121,12 +121,12 @@ test_that("as_oauth2_implicit_flow() returns expected objects", { expect_identical( as_oauth2_implicit_flow(list()), - oauth2_implicit_flow() + class_oauth2_implicit_flow() ) expect_identical( as_oauth2_implicit_flow(character()), - oauth2_implicit_flow() + class_oauth2_implicit_flow() ) }) @@ -142,7 +142,7 @@ test_that("as_oauth2_implicit_flow() works for alternate names", { refreshUrl = "https://api.ebay.com/identity/v1/oauth2/refresh" ) ), - oauth2_implicit_flow( + class_oauth2_implicit_flow( authorization_url = "https://auth.ebay.com/oauth2/authorize", scopes = c( sell.account = "View and manage your account settings", @@ -155,7 +155,7 @@ test_that("as_oauth2_implicit_flow() works for alternate names", { test_that("as_oauth2_implicit_flow() works for oauth2_implicit_flow", { expect_identical( - as_oauth2_implicit_flow(oauth2_implicit_flow()), - oauth2_implicit_flow() + as_oauth2_implicit_flow(class_oauth2_implicit_flow()), + class_oauth2_implicit_flow() ) }) diff --git a/tests/testthat/test-components-security_scheme-oauth2-scopes.R b/tests/testthat/test-components-security_scheme-oauth2-scopes.R index 01d41bc..525bcc3 100644 --- a/tests/testthat/test-components-security_scheme-oauth2-scopes.R +++ b/tests/testthat/test-components-security_scheme-oauth2-scopes.R @@ -1,29 +1,29 @@ -test_that("scopes() requires that description matches name", { +test_that("class_scopes() requires that description matches name", { expect_snapshot( - scopes("a"), + class_scopes("a"), error = TRUE ) expect_snapshot( - scopes("a", letters), + class_scopes("a", letters), error = TRUE ) expect_snapshot( - scopes(letters, "a"), + class_scopes(letters, "a"), error = TRUE ) expect_snapshot( - scopes(character(), "a"), + class_scopes(character(), "a"), error = TRUE ) expect_snapshot( - scopes("a", character()), + class_scopes("a", character()), error = TRUE ) }) -test_that("scopes() works with equal-length name/descript", { +test_that("class_scopes() works with equal-length name/descript", { expect_snapshot({ - test_result <- scopes("a", "b") + test_result <- class_scopes("a", "b") test_result }) expect_s3_class( @@ -38,9 +38,9 @@ test_that("scopes() works with equal-length name/descript", { }) test_that("length() of a scopes reports the overall length", { - expect_equal(length(scopes()), 0) - expect_equal(length(scopes(name = "A", description = "A")), 1) - expect_equal(length(scopes(name = letters, description = LETTERS)), 26) + expect_equal(length(class_scopes()), 0) + expect_equal(length(class_scopes(name = "A", description = "A")), 1) + expect_equal(length(class_scopes(name = letters, description = LETTERS)), 26) }) test_that("as_scopes() errors informatively for unnamed input", { @@ -80,7 +80,7 @@ test_that("as_scopes() returns expected objects", { b = "bb" ) ), - scopes( + class_scopes( name = c("a", "b"), description = c("aa", "bb") ) @@ -92,7 +92,7 @@ test_that("as_scopes() returns expected objects", { b = "bb" ) ), - scopes( + class_scopes( name = c("a", "b"), description = c("aa", "bb") ) @@ -100,18 +100,18 @@ test_that("as_scopes() returns expected objects", { expect_identical( as_scopes(list()), - scopes() + class_scopes() ) expect_identical( as_scopes(character()), - scopes() + class_scopes() ) }) test_that("as_scopes() works for scopes", { expect_identical( - as_scopes(scopes()), - scopes() + as_scopes(class_scopes()), + class_scopes() ) }) diff --git a/tests/testthat/test-components-security_scheme-oauth2-token_flow.R b/tests/testthat/test-components-security_scheme-oauth2-token_flow.R index f3eac2f..a04d0e2 100644 --- a/tests/testthat/test-components-security_scheme-oauth2-token_flow.R +++ b/tests/testthat/test-components-security_scheme-oauth2-token_flow.R @@ -1,47 +1,47 @@ -test_that("oauth2_token_flow() requires compatible lengths", { +test_that("class_oauth2_token_flow() requires compatible lengths", { expect_snapshot( - oauth2_token_flow(refresh_url = "a"), + class_oauth2_token_flow(refresh_url = "a"), error = TRUE ) expect_snapshot( - oauth2_token_flow(scopes = c("a" = "a")), + class_oauth2_token_flow(scopes = c("a" = "a")), error = TRUE ) }) -test_that("oauth2_token_flow() returns an empty oauth2_token_flow", { - expect_snapshot(oauth2_token_flow()) +test_that("class_oauth2_token_flow() returns an empty oauth2_token_flow", { + expect_snapshot(class_oauth2_token_flow()) }) -test_that("oauth2_token_flow() requires names for optionals", { +test_that("class_oauth2_token_flow() requires names for optionals", { expect_snapshot( - oauth2_token_flow("a", "b", "c"), + class_oauth2_token_flow("a", "b", "c"), error = TRUE ) expect_snapshot( - oauth2_token_flow("a", refresh_url = "c", c("d" = "d")), + class_oauth2_token_flow("a", refresh_url = "c", c("d" = "d")), error = TRUE ) }) -test_that("oauth2_token_flow() errors informatively for bad classes", { +test_that("class_oauth2_token_flow() errors informatively for bad classes", { expect_snapshot( - oauth2_token_flow(mean), + class_oauth2_token_flow(mean), error = TRUE ) expect_snapshot( - oauth2_token_flow("a", refresh_url = mean), + class_oauth2_token_flow("a", refresh_url = mean), error = TRUE ) expect_snapshot( - oauth2_token_flow("a", refresh_url = "c", scopes = "d"), + class_oauth2_token_flow("a", refresh_url = "c", scopes = "d"), error = TRUE ) }) -test_that("oauth2_token_flow() returns expected objects", { +test_that("class_oauth2_token_flow() returns expected objects", { expect_snapshot({ - test_result <- oauth2_token_flow( + test_result <- class_oauth2_token_flow( token_url = "https://auth.ebay.com/oauth2/token", scopes = c( sell.account = "View and manage your account settings", @@ -67,10 +67,10 @@ test_that("oauth2_token_flow() returns expected objects", { }) test_that("length() of an oauth2_token_flow reports the overall length", { - expect_equal(length(oauth2_token_flow()), 0) - expect_equal(length(oauth2_token_flow("A")), 1) + expect_equal(length(class_oauth2_token_flow()), 0) + expect_equal(length(class_oauth2_token_flow("A")), 1) expect_equal( - length(oauth2_token_flow("A", scopes = c("a" = "a", "b" = "b"))), + length(class_oauth2_token_flow("A", scopes = c("a" = "a", "b" = "b"))), 1 ) }) @@ -109,7 +109,7 @@ test_that("as_oauth2_token_flow() returns expected objects", { refresh_url = "https://api.ebay.com/identity/v1/oauth2/refresh" ) ), - oauth2_token_flow( + class_oauth2_token_flow( token_url = "https://auth.ebay.com/oauth2/token", scopes = c( sell.account = "View and manage your account settings", @@ -121,12 +121,12 @@ test_that("as_oauth2_token_flow() returns expected objects", { expect_identical( as_oauth2_token_flow(list()), - oauth2_token_flow() + class_oauth2_token_flow() ) expect_identical( as_oauth2_token_flow(character()), - oauth2_token_flow() + class_oauth2_token_flow() ) }) @@ -142,7 +142,7 @@ test_that("as_oauth2_token_flow() works for alternate names", { refreshUrl = "https://api.ebay.com/identity/v1/oauth2/refresh" ) ), - oauth2_token_flow( + class_oauth2_token_flow( token_url = "https://auth.ebay.com/oauth2/token", scopes = c( sell.account = "View and manage your account settings", @@ -155,7 +155,7 @@ test_that("as_oauth2_token_flow() works for alternate names", { test_that("as_oauth2_token_flow() works for oauth2_token_flow", { expect_identical( - as_oauth2_token_flow(oauth2_token_flow()), - oauth2_token_flow() + as_oauth2_token_flow(class_oauth2_token_flow()), + class_oauth2_token_flow() ) }) diff --git a/tests/testthat/test-components-security_scheme-oauth2.R b/tests/testthat/test-components-security_scheme-oauth2.R index 987d3f5..3bc3d51 100644 --- a/tests/testthat/test-components-security_scheme-oauth2.R +++ b/tests/testthat/test-components-security_scheme-oauth2.R @@ -1,41 +1,41 @@ -test_that("oauth2_security_scheme() requires names", { +test_that("class_oauth2_security_scheme() requires names", { expect_snapshot( - oauth2_security_scheme(oauth2_token_flow()), + class_oauth2_security_scheme(class_oauth2_token_flow()), error = TRUE ) }) -test_that("oauth2_security_scheme() requires the right types of flows", { +test_that("class_oauth2_security_scheme() requires the right types of flows", { expect_snapshot( - oauth2_security_scheme( - implicit_flow = oauth2_token_flow() + class_oauth2_security_scheme( + implicit_flow = class_oauth2_token_flow() ), error = TRUE ) expect_snapshot( - oauth2_security_scheme( - password_flow = oauth2_implicit_flow() + class_oauth2_security_scheme( + password_flow = class_oauth2_implicit_flow() ), error = TRUE ) expect_snapshot( - oauth2_security_scheme( - client_credentials_flow = oauth2_implicit_flow() + class_oauth2_security_scheme( + client_credentials_flow = class_oauth2_implicit_flow() ), error = TRUE ) expect_snapshot( - oauth2_security_scheme( - authorization_code_flow = oauth2_implicit_flow() + class_oauth2_security_scheme( + authorization_code_flow = class_oauth2_implicit_flow() ), error = TRUE ) }) -test_that("oauth2_security_scheme() works with valid objects", { +test_that("class_oauth2_security_scheme() works with valid objects", { expect_snapshot({ - test_result <- oauth2_security_scheme( - password_flow = oauth2_token_flow(token_url = "/tokens/passwords") + test_result <- class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow(token_url = "/tokens/passwords") ) test_result }) @@ -58,11 +58,11 @@ test_that("oauth2_security_scheme() works with valid objects", { }) test_that("length() of a oauth2_security_scheme reports the proper length", { - expect_equal(length(oauth2_security_scheme()), 0) + expect_equal(length(class_oauth2_security_scheme()), 0) expect_equal( length( - oauth2_security_scheme( - password_flow = oauth2_token_flow(token_url = "/tokens/passwords") + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow(token_url = "/tokens/passwords") ) ), 1 @@ -116,18 +116,18 @@ test_that("as_oauth2_security_scheme() returns expected objects", { type = "oauth2" ) ), - oauth2_security_scheme( - implicit_flow = oauth2_implicit_flow( + class_oauth2_security_scheme( + implicit_flow = class_oauth2_implicit_flow( authorization_url = "https://api.gettyimages.com/v4/oauth2/auth" ), - password_flow = oauth2_token_flow( + password_flow = class_oauth2_token_flow( token_url = "https://api.gettyimages.com/v4/oauth2/token", refresh_url = "https://api.gettyimages.com/v4/oauth2/token" ), - client_credentials_flow = oauth2_token_flow( + client_credentials_flow = class_oauth2_token_flow( token_url = "https://api.gettyimages.com/v4/oauth2/token" ), - authorization_code_flow = oauth2_authorization_code_flow( + authorization_code_flow = class_oauth2_authorization_code_flow( token_url = "https://api.gettyimages.com/v4/oauth2/token", refresh_url = "https://api.gettyimages.com/v4/oauth2/token", authorization_url = "https://api.gettyimages.com/v4/oauth2/auth" @@ -137,13 +137,13 @@ test_that("as_oauth2_security_scheme() returns expected objects", { expect_identical( as_oauth2_security_scheme(list()), - oauth2_security_scheme() + class_oauth2_security_scheme() ) }) test_that("as_oauth2_security_scheme() works for oauth2_security_scheme", { expect_identical( - as_oauth2_security_scheme(oauth2_security_scheme()), - oauth2_security_scheme() + as_oauth2_security_scheme(class_oauth2_security_scheme()), + class_oauth2_security_scheme() ) }) diff --git a/tests/testthat/test-components-security_scheme.R b/tests/testthat/test-components-security_scheme.R index 0421f07..6b53ad6 100644 --- a/tests/testthat/test-components-security_scheme.R +++ b/tests/testthat/test-components-security_scheme.R @@ -15,12 +15,12 @@ test_that("as_security_scheme() errors informatively for bad classes", { test_that("as_security_scheme() works for security_schemes", { expect_identical( - as_security_scheme(oauth2_security_scheme()), - oauth2_security_scheme() + as_security_scheme(class_oauth2_security_scheme()), + class_oauth2_security_scheme() ) expect_identical( - as_security_scheme(api_key_security_scheme()), - api_key_security_scheme() + as_security_scheme(class_api_key_security_scheme()), + class_api_key_security_scheme() ) }) @@ -43,10 +43,10 @@ test_that("as_security_scheme() returns expected objects", { type = "oauth2" ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -74,10 +74,10 @@ test_that("as_security_scheme() returns expected objects", { type = "oauth2" ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/profile/authorization", - scopes = scopes( + scopes = class_scopes( name = "Catalog", description = "Modify profile preferences and activity" ) @@ -100,7 +100,7 @@ test_that("as_security_scheme() works for re-named parameters", { type = "apiKey" ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) diff --git a/tests/testthat/test-components-security_scheme_details.R b/tests/testthat/test-components-security_scheme_details.R index bf84837..a1177a5 100644 --- a/tests/testthat/test-components-security_scheme_details.R +++ b/tests/testthat/test-components-security_scheme_details.R @@ -1,39 +1,42 @@ -test_that("security_scheme_details() errors informatively for bad contents", { +test_that("class_security_scheme_details() errors informatively for bad contents", { expect_snapshot( - security_scheme_details(letters), + class_security_scheme_details(letters), error = TRUE ) expect_snapshot( - security_scheme_details(list(letters, letters)), + class_security_scheme_details(list(letters, letters)), error = TRUE ) expect_snapshot( - security_scheme_details( - api_key_security_scheme(), + class_security_scheme_details( + class_api_key_security_scheme(), letters, - oauth2_security_scheme(), + class_oauth2_security_scheme(), letters ), error = TRUE ) }) -test_that("security_scheme_details() returns empty security_scheme_details", { - expect_snapshot(security_scheme_details()) +test_that("class_security_scheme_details() returns empty security_scheme_details", { + expect_snapshot(class_security_scheme_details()) }) -test_that("security_scheme_details() accepts bare security_schemes", { - expect_snapshot(security_scheme_details(api_key_security_scheme())) +test_that("class_security_scheme_details() accepts bare security_schemes", { + expect_snapshot(class_security_scheme_details(class_api_key_security_scheme())) expect_snapshot( - security_scheme_details(api_key_security_scheme(), oauth2_security_scheme()) + class_security_scheme_details( + class_api_key_security_scheme(), + class_oauth2_security_scheme() + ) ) }) -test_that("security_scheme_details() accepts lists of security_schemes", { - expect_snapshot(security_scheme_details(list(api_key_security_scheme()))) +test_that("class_security_scheme_details() accepts lists of security_schemes", { + expect_snapshot(class_security_scheme_details(list(class_api_key_security_scheme()))) expect_snapshot( - security_scheme_details(list( - api_key_security_scheme(), oauth2_security_scheme() + class_security_scheme_details(list( + class_api_key_security_scheme(), class_oauth2_security_scheme() )) ) }) @@ -55,8 +58,8 @@ test_that("as_security_scheme_details() errors informatively for bad classes", { test_that("as_security_scheme_details() works for security_scheme_details", { expect_identical( - as_security_scheme_details(security_scheme_details()), - security_scheme_details() + as_security_scheme_details(class_security_scheme_details()), + class_security_scheme_details() ) }) @@ -103,11 +106,11 @@ test_that("as_security_scheme_details() returns expected objects", { ) ) ), - security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -118,20 +121,20 @@ test_that("as_security_scheme_details() returns expected objects", { ) ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/profile/authorization", - scopes = scopes( + scopes = class_scopes( name = "Catalog", description = "Modify profile preferences and activity" ) ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) @@ -139,6 +142,6 @@ test_that("as_security_scheme_details() returns expected objects", { ) expect_identical( as_security_scheme_details(list()), - security_scheme_details() + class_security_scheme_details() ) }) diff --git a/tests/testthat/test-components-security_scheme_collection.R b/tests/testthat/test-components-security_schemes.R similarity index 58% rename from tests/testthat/test-components-security_scheme_collection.R rename to tests/testthat/test-components-security_schemes.R index ead059b..fa38909 100644 --- a/tests/testthat/test-components-security_scheme_collection.R +++ b/tests/testthat/test-components-security_schemes.R @@ -1,21 +1,21 @@ -test_that("security_scheme_collection() requires name for description", { +test_that("class_security_schemes() requires name for description", { expect_error( - security_scheme_collection("a", details = NULL, "description"), + class_security_schemes("a", details = NULL, "description"), class = "rlib_error_dots_nonempty" ) expect_snapshot( - security_scheme_collection("a", details = NULL, "description"), + class_security_schemes("a", details = NULL, "description"), error = TRUE ) }) -test_that("security_scheme_collection() requires required parameters", { +test_that("class_security_schemes() requires required parameters", { expect_snapshot( { - security_scheme_collection("a") - security_scheme_collection( - details = security_scheme_details( - api_key_security_scheme("parm", "query") + class_security_schemes("a") + class_security_schemes( + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query") ) ) }, @@ -23,14 +23,14 @@ test_that("security_scheme_collection() requires required parameters", { ) }) -test_that("security_scheme_collection() -> empty security_scheme_collection", { +test_that("class_security_schemes() -> empty security_schemes", { expect_snapshot({ - test_result <- security_scheme_collection() + test_result <- class_security_schemes() test_result }) expect_s3_class( test_result, - class = c("rapid::security_scheme_collection", "S7_object"), + class = c("rapid::security_schemes", "S7_object"), exact = TRUE ) expect_identical( @@ -43,14 +43,14 @@ test_that("security_scheme_collection() -> empty security_scheme_collection", { ) }) -test_that("length() of security_scheme_collection reports the overall length", { - expect_equal(length(security_scheme_collection()), 0) +test_that("length() of security_schemes reports the overall length", { + expect_equal(length(class_security_schemes()), 0) expect_equal( length( - security_scheme_collection( + class_security_schemes( name = "a", - details = security_scheme_details( - api_key_security_scheme("parm", "query") + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query") ) ) ), @@ -58,11 +58,11 @@ test_that("length() of security_scheme_collection reports the overall length", { ) expect_equal( length( - security_scheme_collection( + class_security_schemes( name = c("a", "b"), - details = security_scheme_details( - api_key_security_scheme("parm", "query"), - api_key_security_scheme("parm", "query") + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query"), + class_api_key_security_scheme("parm", "query") ) ) ), @@ -70,35 +70,35 @@ test_that("length() of security_scheme_collection reports the overall length", { ) }) -test_that("as_security_scheme_collection() errors for unnamed input", { +test_that("as_security_schemes() errors for unnamed input", { expect_snapshot( - as_security_scheme_collection(as.list(letters)), + as_security_schemes(as.list(letters)), error = TRUE ) }) -test_that("as_security_scheme_collection() errors for bad classes", { +test_that("as_security_schemes() errors for bad classes", { expect_snapshot( - as_security_scheme_collection(letters), + as_security_schemes(letters), error = TRUE ) expect_snapshot( - as_security_scheme_collection(1:2), + as_security_schemes(1:2), error = TRUE ) expect_snapshot( - as_security_scheme_collection(mean), + as_security_schemes(mean), error = TRUE ) expect_snapshot( - as_security_scheme_collection(TRUE), + as_security_schemes(TRUE), error = TRUE ) }) -test_that("as_security_scheme_collection() returns expected objects", { +test_that("as_security_schemes() returns expected objects", { expect_identical( - as_security_scheme_collection( + as_security_schemes( list( accountAuth = list( description = "Account JWT token", @@ -139,18 +139,18 @@ test_that("as_security_scheme_collection() returns expected objects", { ) ) ), - security_scheme_collection( + class_security_schemes( name = c( "accountAuth", "profileAuth", "resetPasswordAuth", "verifyEmailAuth" ), - details = security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( + details = class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -161,20 +161,20 @@ test_that("as_security_scheme_collection() returns expected objects", { ) ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/profile/authorization", - scopes = scopes( + scopes = class_scopes( name = "Catalog", description = "Modify profile preferences and activity" ) ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) @@ -183,14 +183,14 @@ test_that("as_security_scheme_collection() returns expected objects", { ) ) expect_identical( - as_security_scheme_collection(list()), - security_scheme_collection() + as_security_schemes(list()), + class_security_schemes() ) }) -test_that("as_security_scheme_collection() ok w security_scheme_collections", { +test_that("as_security_schemes() ok w security_schemes", { expect_identical( - as_security_scheme_collection(security_scheme_collection()), - security_scheme_collection() + as_security_schemes(class_security_schemes()), + class_security_schemes() ) }) diff --git a/tests/testthat/test-components.R b/tests/testthat/test-components.R index 9a69ea7..1ed61e7 100644 --- a/tests/testthat/test-components.R +++ b/tests/testthat/test-components.R @@ -1,11 +1,11 @@ -test_that("component_collection() returns an empty component_collection", { +test_that("class_components() returns an empty components", { expect_snapshot({ - test_result <- component_collection() + test_result <- class_components() test_result }) expect_s3_class( test_result, - class = c("rapid::component_collection", "S7_object"), + class = c("rapid::components", "S7_object"), exact = TRUE ) expect_identical( @@ -15,14 +15,14 @@ test_that("component_collection() returns an empty component_collection", { }) test_that("length() of an security_schemes reports the overall length", { - expect_equal(length(component_collection()), 0) + expect_equal(length(class_components()), 0) expect_equal( length( - component_collection( - security_schemes = security_scheme_collection( + class_components( + security_schemes = class_security_schemes( name = "a", - details = security_scheme_details( - api_key_security_scheme("parm", "query") + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query") ) ) ) @@ -31,12 +31,12 @@ test_that("length() of an security_schemes reports the overall length", { ) expect_equal( length( - component_collection( - security_schemes = security_scheme_collection( + class_components( + security_schemes = class_security_schemes( name = c("a", "b"), - details = security_scheme_details( - api_key_security_scheme("parm", "query"), - api_key_security_scheme("parm", "query") + details = class_security_scheme_details( + class_api_key_security_scheme("parm", "query"), + class_api_key_security_scheme("parm", "query") ) ) ) @@ -45,35 +45,35 @@ test_that("length() of an security_schemes reports the overall length", { ) }) -test_that("as_component_collection() errors for unnamed input", { +test_that("as_components() errors for unnamed input", { expect_snapshot( - as_component_collection(as.list(letters)), + as_components(as.list(letters)), error = TRUE ) expect_snapshot( - as_component_collection(list("My Cool API")), + as_components(list("My Cool API")), error = TRUE ) }) -test_that("as_component_collection() errors informatively for bad classes", { +test_that("as_components() errors informatively for bad classes", { expect_snapshot( - as_component_collection(1:2), + as_components(1:2), error = TRUE ) expect_snapshot( - as_component_collection(mean), + as_components(mean), error = TRUE ) expect_snapshot( - as_component_collection(TRUE), + as_components(TRUE), error = TRUE ) }) -test_that("as_component_collection() returns expected objects", { +test_that("as_components() returns expected objects", { expect_identical( - as_component_collection(list( + as_components(list( security_schemes = list( accountAuth = list( description = "Account JWT token", @@ -114,19 +114,19 @@ test_that("as_component_collection() returns expected objects", { ) ) )), - component_collection( - security_schemes = security_scheme_collection( + class_components( + security_schemes = class_security_schemes( name = c( "accountAuth", "profileAuth", "resetPasswordAuth", "verifyEmailAuth" ), - details = security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( + details = class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -137,20 +137,20 @@ test_that("as_component_collection() returns expected objects", { ) ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/profile/authorization", - scopes = scopes( + scopes = class_scopes( name = "Catalog", description = "Modify profile preferences and activity" ) ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) @@ -161,14 +161,14 @@ test_that("as_component_collection() returns expected objects", { ) expect_identical( - as_component_collection(list()), - component_collection() + as_components(list()), + class_components() ) }) -test_that("as_component_collection() works with camelCase", { +test_that("as_components() works with camelCase", { expect_identical( - as_component_collection(list( + as_components(list( securitySchemes = list( accountAuth = list( description = "Account JWT token", @@ -209,19 +209,19 @@ test_that("as_component_collection() works with camelCase", { ) ) )), - component_collection( - security_schemes = security_scheme_collection( + class_components( + security_schemes = class_security_schemes( name = c( "accountAuth", "profileAuth", "resetPasswordAuth", "verifyEmailAuth" ), - details = security_scheme_details( - oauth2_security_scheme( - password_flow = oauth2_token_flow( + details = class_security_scheme_details( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/authorization", - scopes = scopes( + scopes = class_scopes( name = c("Catalog", "Commerce", "Playback", "Settings"), description = c( "Access all read-only content", @@ -232,20 +232,20 @@ test_that("as_component_collection() works with camelCase", { ) ) ), - oauth2_security_scheme( - password_flow = oauth2_token_flow( + class_oauth2_security_scheme( + password_flow = class_oauth2_token_flow( token_url = "/account/profile/authorization", - scopes = scopes( + scopes = class_scopes( name = "Catalog", description = "Modify profile preferences and activity" ) ) ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ), - api_key_security_scheme( + class_api_key_security_scheme( parameter_name = "authorization", location = "header" ) @@ -256,9 +256,9 @@ test_that("as_component_collection() works with camelCase", { ) }) -test_that("as_component_collection() works for component_collections", { +test_that("as_components() works for components", { expect_identical( - as_component_collection(component_collection()), - component_collection() + as_components(class_components()), + class_components() ) }) diff --git a/tests/testthat/test-info-contact.R b/tests/testthat/test-info-contact.R index 87cfff7..218bbce 100644 --- a/tests/testthat/test-info-contact.R +++ b/tests/testthat/test-info-contact.R @@ -1,25 +1,25 @@ -test_that("contact() errors informatively for bad name", { +test_that("class_contact() errors informatively for bad name", { expect_snapshot( - contact(name = mean), + class_contact(name = mean), error = TRUE ) expect_snapshot( - contact(name = c("A", "B")), + class_contact(name = c("A", "B")), error = TRUE ) }) -test_that("contact() errors informatively for bad email", { +test_that("class_contact() errors informatively for bad email", { expect_snapshot( - contact(name = "A", url = "https://example.com", email = mean), + class_contact(name = "A", url = "https://example.com", email = mean), error = TRUE ) expect_snapshot( - contact(name = "A", url = "https://example.com", email = c("A", "B")), + class_contact(name = "A", url = "https://example.com", email = c("A", "B")), error = TRUE ) expect_snapshot( - contact( + class_contact( name = "A", url = "https://example.com", email = "not a real email" @@ -28,9 +28,9 @@ test_that("contact() errors informatively for bad email", { ) }) -test_that("contact() returns a contact when everything is ok", { +test_that("class_contact() returns a contact when everything is ok", { expect_snapshot({ - test_result <- contact( + test_result <- class_contact( name = "A", url = "https://example.com", email = "real.email@address.place" @@ -48,9 +48,9 @@ test_that("contact() returns a contact when everything is ok", { ) }) -test_that("contact() without args returns an empty contact", { +test_that("class_contact() without args returns an empty contact", { expect_snapshot({ - test_result <- contact() + test_result <- class_contact() test_result }) expect_s3_class( @@ -65,8 +65,8 @@ test_that("contact() without args returns an empty contact", { }) test_that("length() of a contact reports the overall length", { - expect_equal(length(contact()), 0) - expect_equal(length(contact(name = "A")), 1) + expect_equal(length(class_contact()), 0) + expect_equal(length(class_contact(name = "A")), 1) }) test_that("as_contact() errors informatively for unnamed input", { @@ -108,7 +108,7 @@ test_that("as_contact() returns expected objects", { url = "https://jonthegeek.com" ) ), - contact( + class_contact( name = "Jon", email = "jonthegeek@gmail.com", url = "https://jonthegeek.com" @@ -121,7 +121,7 @@ test_that("as_contact() returns expected objects", { email = "jonthegeek@gmail.com" ) ), - contact( + class_contact( name = "Jon", email = "jonthegeek@gmail.com" ) @@ -133,7 +133,7 @@ test_that("as_contact() returns expected objects", { name = "Jon" ) ), - contact( + class_contact( name = "Jon", email = "jonthegeek@gmail.com" ) @@ -145,20 +145,20 @@ test_that("as_contact() returns expected objects", { email = "jonthegeek@gmail.com" ) ), - contact( + class_contact( name = "Jon", email = "jonthegeek@gmail.com" ) ) expect_identical( as_contact(list()), - contact() + class_contact() ) }) test_that("as_contact() works for contacts", { expect_identical( - as_contact(contact()), - contact() + as_contact(class_contact()), + class_contact() ) }) diff --git a/tests/testthat/test-info-license.R b/tests/testthat/test-info-license.R index 13bc9dd..02f1832 100644 --- a/tests/testthat/test-info-license.R +++ b/tests/testthat/test-info-license.R @@ -1,63 +1,63 @@ -test_that("license() errors informatively for bad name", { +test_that("class_license() errors informatively for bad name", { expect_snapshot( - license(name = mean), + class_license(name = mean), error = TRUE ) expect_snapshot( - license(name = c("A", "B")), + class_license(name = c("A", "B")), error = TRUE ) }) -test_that("license() errors informatively for bad url", { +test_that("class_license() errors informatively for bad url", { expect_snapshot( - license(name = "A", url = mean), + class_license(name = "A", url = mean), error = TRUE ) expect_snapshot( - license(name = "A", url = c("A", "B")), + class_license(name = "A", url = c("A", "B")), error = TRUE ) }) -test_that("license() errors informatively for bad identifier", { +test_that("class_license() errors informatively for bad identifier", { expect_snapshot( - license(name = "A", identifier = mean), + class_license(name = "A", identifier = mean), error = TRUE ) expect_snapshot( - license(name = "A", identifier = c("A", "B")), + class_license(name = "A", identifier = c("A", "B")), error = TRUE ) }) -test_that("license() errors when both url and identifier are supplied", { +test_that("class_license() errors when both url and identifier are supplied", { expect_snapshot( - license(name = "A", identifier = "A", url = "https://example.com"), + class_license(name = "A", identifier = "A", url = "https://example.com"), error = TRUE ) }) -test_that("license() fails when name is missing", { +test_that("class_license() fails when name is missing", { expect_snapshot( - license(identifier = "A"), + class_license(identifier = "A"), error = TRUE ) expect_snapshot( - license(url = "https://example.com"), + class_license(url = "https://example.com"), error = TRUE ) }) -test_that("license() doesn't match identifier by position", { +test_that("class_license() doesn't match identifier by position", { expect_snapshot( - license(name = "A", "https://example.com"), + class_license(name = "A", "https://example.com"), error = TRUE ) }) -test_that("license() returns a license when everything is ok", { +test_that("class_license() returns a license when everything is ok", { expect_snapshot({ - test_result <- license( + test_result <- class_license( name = "A", url = "https://example.com" ) @@ -74,7 +74,7 @@ test_that("license() returns a license when everything is ok", { ) expect_snapshot({ - test_result <- license( + test_result <- class_license( name = "A", identifier = "technically these have a fancy required format" ) @@ -92,8 +92,8 @@ test_that("license() returns a license when everything is ok", { }) test_that("length() of a license reports the overall length", { - expect_equal(length(license()), 0) - expect_equal(length(license(name = "A")), 1) + expect_equal(length(class_license()), 0) + expect_equal(length(class_license(name = "A")), 1) }) test_that("as_license() errors informatively for unnamed input", { @@ -124,7 +124,7 @@ test_that("as_license() returns expected objects", { name = "Apache 2.0", identifier = "Apache-2.0" )), - license( + class_license( name = "Apache 2.0", identifier = "Apache-2.0" ) @@ -145,7 +145,7 @@ test_that("as_license() returns expected objects", { x = "https://jonthegeek.com" )) ), - license( + class_license( name = "Apache 2.0", identifier = "Apache-2.0" ) @@ -153,13 +153,13 @@ test_that("as_license() returns expected objects", { expect_identical( as_license(list()), - license() + class_license() ) }) test_that("as_license() works for licenses", { expect_identical( - as_license(license()), - license() + as_license(class_license()), + class_license() ) }) diff --git a/tests/testthat/test-info.R b/tests/testthat/test-info.R index 3b4612a..9fcc08c 100644 --- a/tests/testthat/test-info.R +++ b/tests/testthat/test-info.R @@ -1,21 +1,21 @@ -test_that("info() validates property length.", { +test_that("class_info() validates property length.", { expect_snapshot( - info(title = "My API"), + class_info(title = "My API"), error = TRUE ) expect_snapshot( - info(version = "My API"), + class_info(version = "My API"), error = TRUE ) expect_snapshot( - info(summary = "My API"), + class_info(summary = "My API"), error = TRUE ) }) -test_that("info() returns an empty info", { +test_that("class_info() returns an empty info", { expect_snapshot({ - test_result <- info() + test_result <- class_info() test_result }) expect_s3_class( @@ -39,13 +39,13 @@ test_that("info() returns an empty info", { }) test_that("length() of an info reports the overall length", { - expect_equal(length(info()), 0) + expect_equal(length(class_info()), 0) expect_equal( length( - info( + class_info( title = "My Cool API", version = "one", - license = license( + license = class_license( name = "Apache 2.0", url = "https://opensource.org/license/apache-2-0/" ) @@ -87,7 +87,7 @@ test_that("as_info() returns expected objects", { title = "My API", version = "1" )), - info( + class_info( title = "My API", version = "1" ) @@ -105,14 +105,14 @@ test_that("as_info() returns expected objects", { identifier = "Apache-2.0" ) )), - info( + class_info( title = "My API", version = "1", - contact = contact( + contact = class_contact( name = "Jon", email = "jonthegeek@gmail.com" ), - license = license( + license = class_license( name = "Apache 2.0", identifier = "Apache-2.0" ) @@ -120,14 +120,14 @@ test_that("as_info() returns expected objects", { ) expect_identical( as_info(list()), - info() + class_info() ) }) test_that("as_info() works for infos", { expect_identical( - as_info(info()), - info() + as_info(class_info()), + class_info() ) }) @@ -138,7 +138,7 @@ test_that("as_info() converts x-origin to origin", { version = "1", x_origin = "https://root.url" )), - info( + class_info( title = "My API", version = "1", origin = class_origin("https://root.url") diff --git a/tests/testthat/test-security.R b/tests/testthat/test-security.R new file mode 100644 index 0000000..1304e43 --- /dev/null +++ b/tests/testthat/test-security.R @@ -0,0 +1,109 @@ +test_that("class_security() requires parallel parameters", { + expect_error( + class_security(required_scopes = "a"), + "must be empty" + ) + expect_snapshot( + class_security(required_scopes = "a"), + error = TRUE + ) +}) + +test_that("class_security() rapid_class_requirement field is fixed", { + expect_snapshot({ + test_result <- class_security() + test_result + }) + expect_error( + test_result@rapid_class_requirement <- "a", + "Can't set read-only property" + ) + expect_identical( + test_result@rapid_class_requirement, + "security_scheme" + ) +}) + +test_that("class_security have expected lengths", { + expect_equal(length(class_security()), 0) + expect_equal(length(class_security(letters)), 26) + expect_equal( + length(class_security("a", required_scopes = list(letters))), + 1 + ) +}) + +test_that("as_security() fails for bad classes", { + x <- 1:2 + expect_error( + as_security(x), + class = "rapid_error_unknown_coercion" + ) + expect_snapshot( + as_security(x), + error = TRUE + ) + x <- mean + expect_error( + as_security(x), + class = "rapid_error_unknown_coercion" + ) + expect_snapshot( + as_security(x), + error = TRUE + ) + x <- TRUE + expect_error( + as_security(x), + class = "rapid_error_unknown_coercion" + ) + expect_snapshot( + as_security(x), + error = TRUE + ) +}) + +test_that("as_security() works for security", { + expect_identical( + as_security(class_security()), + class_security() + ) +}) + +test_that("as_security() works for empties", { + expect_identical( + as_security(NULL), + class_security() + ) + expect_identical( + as_security(), + class_security() + ) +}) + +test_that("as_security() works for the simplest case", { + x <- list(list(schemeName = list())) + expect_identical( + as_security(x), + class_security("schemeName") + ) +}) + +test_that("as_security() works for complex cases", { + x <- list( + list( + oauth2 = c("user", "user:email", "user:follow") + ), + list(internalApiKey = list()) + ) + expect_identical( + as_security(x), + class_security( + name = c("oauth2", "internalApiKey"), + required_scopes = list( + c("user", "user:email", "user:follow"), + character() + ) + ) + ) +}) diff --git a/tests/testthat/test-security_requirements.R b/tests/testthat/test-security_requirements.R deleted file mode 100644 index a2fab70..0000000 --- a/tests/testthat/test-security_requirements.R +++ /dev/null @@ -1,109 +0,0 @@ -test_that("security_requirements() requires parallel parameters", { - expect_error( - security_requirements(required_scopes = "a"), - "must be empty" - ) - expect_snapshot( - security_requirements(required_scopes = "a"), - error = TRUE - ) -}) - -test_that("security_requirements() rapid_class_requirement field is fixed", { - expect_snapshot({ - test_result <- security_requirements() - test_result - }) - expect_error( - test_result@rapid_class_requirement <- "a", - "Can't set read-only property" - ) - expect_identical( - test_result@rapid_class_requirement, - "security_scheme" - ) -}) - -test_that("security_requirements have expected lengths", { - expect_equal(length(security_requirements()), 0) - expect_equal(length(security_requirements(letters)), 26) - expect_equal( - length(security_requirements("a", required_scopes = list(letters))), - 1 - ) -}) - -test_that("as_security_requirements() fails for bad classes", { - x <- 1:2 - expect_error( - as_security_requirements(x), - class = "rapid_error_unknown_coercion" - ) - expect_snapshot( - as_security_requirements(x), - error = TRUE - ) - x <- mean - expect_error( - as_security_requirements(x), - class = "rapid_error_unknown_coercion" - ) - expect_snapshot( - as_security_requirements(x), - error = TRUE - ) - x <- TRUE - expect_error( - as_security_requirements(x), - class = "rapid_error_unknown_coercion" - ) - expect_snapshot( - as_security_requirements(x), - error = TRUE - ) -}) - -test_that("as_security_requirements() works for security_requirements", { - expect_identical( - as_security_requirements(security_requirements()), - security_requirements() - ) -}) - -test_that("as_security_requirements() works for empties", { - expect_identical( - as_security_requirements(NULL), - security_requirements() - ) - expect_identical( - as_security_requirements(), - security_requirements() - ) -}) - -test_that("as_security_requirements() works for the simplest case", { - x <- list(list(schemeName = list())) - expect_identical( - as_security_requirements(x), - security_requirements("schemeName") - ) -}) - -test_that("as_security_requirements() works for complex cases", { - x <- list( - list( - oauth2 = c("user", "user:email", "user:follow") - ), - list(internalApiKey = list()) - ) - expect_identical( - as_security_requirements(x), - security_requirements( - name = c("oauth2", "internalApiKey"), - required_scopes = list( - c("user", "user:email", "user:follow"), - character() - ) - ) - ) -}) diff --git a/tests/testthat/test-servers-server_variables.R b/tests/testthat/test-servers-server_variables.R index 9362a6a..54797ce 100644 --- a/tests/testthat/test-servers-server_variables.R +++ b/tests/testthat/test-servers-server_variables.R @@ -1,38 +1,43 @@ -test_that("server_variables() errors informatively for bad contents", { +test_that("class_server_variables() errors informatively for bad contents", { expect_snapshot( - server_variables(letters), + class_server_variables(letters), error = TRUE ) expect_snapshot( - server_variables(list(letters, letters)), + class_server_variables(list(letters, letters)), error = TRUE ) expect_snapshot( - server_variables( - string_replacements(), + class_server_variables( + class_string_replacements(), letters, - string_replacements(), + class_string_replacements(), letters ), error = TRUE ) }) -test_that("server_variables() returns an empty server_variables", { - expect_snapshot(server_variables()) +test_that("class_server_variables() returns an empty server_variables", { + expect_snapshot(class_server_variables()) }) -test_that("server_variables() accepts bare string_replacements", { - expect_snapshot(server_variables(string_replacements())) +test_that("class_server_variables() accepts bare string_replacements", { + expect_snapshot(class_server_variables(class_string_replacements())) expect_snapshot( - server_variables(string_replacements(), string_replacements()) + class_server_variables( + class_string_replacements(), + class_string_replacements() + ) ) }) -test_that("server_variables() accepts lists of string_replacements", { - expect_snapshot(server_variables(list(string_replacements()))) +test_that("class_server_variables() accepts lists of string_replacements", { + expect_snapshot(class_server_variables(list(class_string_replacements()))) expect_snapshot( - server_variables(list(string_replacements(), string_replacements())) + class_server_variables( + list(class_string_replacements(), class_string_replacements()) + ) ) }) @@ -60,8 +65,8 @@ test_that("as_server_variables() returns expected objects", { ) ) ), - server_variables( - string_replacements( + class_server_variables( + class_string_replacements( name = "username", default = "demo", description = "Name of the user." @@ -87,13 +92,13 @@ test_that("as_server_variables() returns expected objects", { ) ) ), - server_variables( - string_replacements( + class_server_variables( + class_string_replacements( name = "username", default = "demo", description = "Name of the user." ), - string_replacements( + class_string_replacements( name = c("username", "port"), default = c("demo", 8443), description = c("Name of the user.", NA), @@ -103,13 +108,13 @@ test_that("as_server_variables() returns expected objects", { ) expect_identical( as_server_variables(list()), - server_variables() + class_server_variables() ) }) test_that("as_server_variables() works for server_variables", { expect_identical( - as_server_variables(server_variables()), - server_variables() + as_server_variables(class_server_variables()), + class_server_variables() ) }) diff --git a/tests/testthat/test-servers-string_replacements.R b/tests/testthat/test-servers-string_replacements.R index 81df748..7029934 100644 --- a/tests/testthat/test-servers-string_replacements.R +++ b/tests/testthat/test-servers-string_replacements.R @@ -1,32 +1,32 @@ -test_that("string_replacements() requires names for optional args", { +test_that("class_string_replacements() requires names for optional args", { expect_snapshot( - string_replacements("a", "b", "c"), + class_string_replacements("a", "b", "c"), error = TRUE ) }) -test_that("string_replacements() requires that default matches name", { +test_that("class_string_replacements() requires that default matches name", { expect_snapshot( - string_replacements("a"), + class_string_replacements("a"), error = TRUE ) expect_snapshot( - string_replacements("a", letters), + class_string_replacements("a", letters), error = TRUE ) expect_snapshot( - string_replacements(letters, "a"), + class_string_replacements(letters, "a"), error = TRUE ) expect_snapshot( - string_replacements(character(), "a"), + class_string_replacements(character(), "a"), error = TRUE ) }) -test_that("string_replacements() works with equal-length name/default", { +test_that("class_string_replacements() works with equal-length name/default", { expect_snapshot({ - test_result <- string_replacements("a", "b") + test_result <- class_string_replacements("a", "b") test_result }) expect_s3_class( @@ -40,24 +40,24 @@ test_that("string_replacements() works with equal-length name/default", { ) }) -test_that("string_replacements() requires optional args are empty or match", { +test_that("class_string_replacements() requires optional args are empty or match", { expect_snapshot( - string_replacements("a", "b", enum = list("a", "b")), + class_string_replacements("a", "b", enum = list("a", "b")), error = TRUE ) expect_snapshot( - string_replacements("a", "b", description = c("a", "b")), + class_string_replacements("a", "b", description = c("a", "b")), error = TRUE ) }) -test_that("string_replacements() requires default is in enum when given", { +test_that("class_string_replacements() requires default is in enum when given", { expect_snapshot( - string_replacements(name = "a", default = "b", enum = "a"), + class_string_replacements(name = "a", default = "b", enum = "a"), error = TRUE ) expect_snapshot( - string_replacements( + class_string_replacements( name = c("a", "b"), default = c("b", "a"), enum = list("a", "a") @@ -66,9 +66,9 @@ test_that("string_replacements() requires default is in enum when given", { ) }) -test_that("string_replacements() works for a full object", { +test_that("class_string_replacements() works for a full object", { expect_snapshot({ - test_result <- string_replacements( + test_result <- class_string_replacements( name = c("username", "port", "basePath"), default = c("demo", "8443", "v2"), description = c( @@ -95,8 +95,8 @@ test_that("string_replacements() works for a full object", { }) test_that("length() of a string_replacements reports the overall length", { - expect_equal(length(string_replacements()), 0) - expect_equal(length(string_replacements(name = "A", default = "A")), 1) + expect_equal(length(class_string_replacements()), 0) + expect_equal(length(class_string_replacements(name = "A", default = "A")), 1) }) test_that("as_string_replacements() errors for unnamed input", { @@ -139,7 +139,7 @@ test_that("as_string_replacements() returns expected objects", { ) ) ), - string_replacements( + class_string_replacements( name = "username", default = "demo", description = "Name of the user." @@ -155,7 +155,7 @@ test_that("as_string_replacements() returns expected objects", { ) ) ), - string_replacements( + class_string_replacements( name = "username", default = "demo", description = "Name of the user." @@ -175,7 +175,7 @@ test_that("as_string_replacements() returns expected objects", { ) ) ), - string_replacements( + class_string_replacements( name = c("username", "port"), default = c("demo", 8443), enum = list(NULL, c(8443, 443)), @@ -185,13 +185,13 @@ test_that("as_string_replacements() returns expected objects", { expect_identical( as_string_replacements(list()), - string_replacements() + class_string_replacements() ) }) test_that("as_string_replacements() works for string_replacements", { expect_identical( - as_string_replacements(string_replacements()), - string_replacements() + as_string_replacements(class_string_replacements()), + class_string_replacements() ) }) diff --git a/tests/testthat/test-servers.R b/tests/testthat/test-servers.R index e941861..ea4dcca 100644 --- a/tests/testthat/test-servers.R +++ b/tests/testthat/test-servers.R @@ -1,6 +1,6 @@ -test_that("servers() returns an empty server", { +test_that("class_servers() returns an empty server", { expect_snapshot({ - test_result <- servers() + test_result <- class_servers() test_result }) expect_s3_class( @@ -19,10 +19,10 @@ test_that("servers() returns an empty server", { }) test_that("length() of a servers reports the overall length", { - expect_equal(length(servers()), 0) + expect_equal(length(class_servers()), 0) expect_equal( length( - servers( + class_servers( url = c( "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", @@ -39,10 +39,10 @@ test_that("length() of a servers reports the overall length", { ) expect_equal( length( - servers( + class_servers( url = "https://{username}.gigantic-server.com:{port}/{basePath}", description = "The production API server", - variables = server_variables(string_replacements( + variables = class_server_variables(class_string_replacements( name = c("username", "port", "basePath"), default = c("demo", "8443", "v2"), description = c( @@ -93,7 +93,7 @@ test_that("as_servers() returns expected objects", { ) ) ), - servers( + class_servers( url = "https://example.com", description = "The only server." ) @@ -115,11 +115,11 @@ test_that("as_servers() returns expected objects", { ) ) ), - servers( + class_servers( url = "https://{username}.gigantic-server.com:{port}/{basePath}", description = "The production API server", - variables = server_variables( - string_replacements( + variables = class_server_variables( + class_string_replacements( name = c("username", "port", "basePath"), description = c( "this value is assigned by the service provider", @@ -133,13 +133,13 @@ test_that("as_servers() returns expected objects", { ) expect_identical( as_servers(list()), - servers() + class_servers() ) }) test_that("as_servers() works for servers", { expect_identical( - as_servers(servers()), - servers() + as_servers(class_servers()), + class_servers() ) }) diff --git a/tests/testthat/test-zz-rapid.R b/tests/testthat/test-zz-rapid.R index 8742513..409bb15 100644 --- a/tests/testthat/test-zz-rapid.R +++ b/tests/testthat/test-zz-rapid.R @@ -1,17 +1,17 @@ # I'm building this as I have pieces ready, so the tests will change as I add # more sub-objects. -test_that("rapid() requires info objects for info", { +test_that("class_rapid() requires info objects for info", { expect_snapshot( - rapid(info = mean), + class_rapid(info = mean), error = TRUE ) }) -test_that("rapid() requires info when anything is defined", { +test_that("class_rapid() requires info when anything is defined", { expect_snapshot( - rapid( - servers = servers( + class_rapid( + servers = class_servers( url = c( "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", @@ -30,17 +30,17 @@ test_that("rapid() requires info when anything is defined", { test_that("security must reference components@security_schemes", { expect_snapshot( - rapid( - info = info(title = "A", version = "1"), - components = component_collection( - security_schemes = security_scheme_collection( + class_rapid( + info = class_info(title = "A", version = "1"), + components = class_components( + security_schemes = class_security_schemes( name = "the_defined_one", - details = security_scheme_details( - api_key_security_scheme("this_one", location = "header") + details = class_security_scheme_details( + class_api_key_security_scheme("this_one", location = "header") ) ) ), - security = security_requirements( + security = class_security( name = "an_undefined_one" ) ), @@ -48,9 +48,9 @@ test_that("security must reference components@security_schemes", { ) }) -test_that("rapid() returns an empty rapid", { +test_that("class_rapid() returns an empty rapid", { expect_snapshot({ - test_result <- rapid() + test_result <- class_rapid() test_result }) expect_s3_class( @@ -65,12 +65,12 @@ test_that("rapid() returns an empty rapid", { }) test_that("length() of a rapid reports the overall length", { - expect_equal(length(rapid()), 0) + expect_equal(length(class_rapid()), 0) expect_equal( length( - rapid( - info = info(title = "A", version = "1"), - servers = servers( + class_rapid( + info = class_info(title = "A", version = "1"), + servers = class_servers( url = "https://development.gigantic-server.com/v1" ) ) @@ -79,9 +79,9 @@ test_that("length() of a rapid reports the overall length", { ) expect_equal( length( - rapid( - info = info(title = "A", version = "1"), - servers = servers( + class_rapid( + info = class_info(title = "A", version = "1"), + servers = class_servers( url = c( "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", @@ -101,16 +101,16 @@ test_that("length() of a rapid reports the overall length", { test_that("as_rapid() works for rapid, missing, and empty", { expect_identical( - as_rapid(rapid()), - rapid() + as_rapid(class_rapid()), + class_rapid() ) expect_identical( as_rapid(), - rapid() + class_rapid() ) expect_identical( as_rapid(NULL), - rapid() + class_rapid() ) }) @@ -176,24 +176,24 @@ test_that("as_rapid() works for lists", { ) ) ), - rapid( - info = info( + class_rapid( + info = class_info( title = "Sample Pet Store App", summary = "A pet store manager.", description = "This is a sample server for a pet store.", terms_of_service = "https://example.com/terms/", - contact = contact( + contact = class_contact( name = "API Support", url = "https://www.example.com/support", email = "support@example.com" ), - license = license( + license = class_license( name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0.html" ), version = "1.0.1" ), - servers = servers( + servers = class_servers( url = c( "https://development.gigantic-server.com/v1", "https://staging.gigantic-server.com/v1", @@ -209,7 +209,7 @@ test_that("as_rapid() works for lists", { ) expect_identical( as_rapid(list()), - rapid() + class_rapid() ) })