as_schema()
turns an existing object into a schema
. This is in contrast
with class_schema()
, which builds a schema
from individual properties.
Usage
as_schema(x, ..., arg = caller_arg(x), call = caller_env())
Arguments
- x
The object to coerce. Must be empty or have names "type", "nullable", "description", and/or "format", or names that can be coerced to those names via
snakecase::to_snake_case()
. Extra names are ignored. This object should describe a single schema.- ...
These dots are for future extensions and must be empty.
- arg
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.
- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.
Value
A schema
as returned by class_schema()
.
See also
schema objects
class_schema()
components object
as_api_key_security_scheme()
,
as_components()
,
as_oauth2_authorization_code_flow()
,
as_oauth2_implicit_flow()
,
as_oauth2_security_scheme()
,
as_oauth2_token_flow()
,
as_reference()
,
as_scopes()
,
as_security_scheme()
,
as_security_scheme_details()
,
as_security_schemes()
,
class_api_key_security_scheme()
,
class_components()
,
class_oauth2_authorization_code_flow()
,
class_oauth2_implicit_flow()
,
class_oauth2_security_scheme()
,
class_oauth2_token_flow()
,
class_reference()
,
class_schema()
,
class_scopes()
,
class_security_scheme_details()
,
class_security_schemes()
Examples
as_schema()
#> <rapid::schema>
#> @ type : Factor w/ 6 levels "string","number",..:
#> .. - attr(*, "initialized")= logi TRUE
#> @ nullable : logi(0)
#> @ description: chr(0)
#> @ format : chr(0)
as_schema(
list(
type = "string",
format = "date-time",
description = "Timestamp when the event will occur."
)
)
#> <rapid::schema>
#> @ type : Factor w/ 6 levels "string","number",..: 1
#> .. - attr(*, "initialized")= logi TRUE
#> @ nullable : logi FALSE
#> @ description: chr "Timestamp when the event will occur."
#> @ format : chr "date-time"