Skip to contents

as_reference() turns an existing object into a reference. This is in contrast with class_reference(), which builds a reference from individual properties.

Usage

as_reference(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 reference.

...

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 the call argument of abort() for more information.

Value

A reference as returned by class_reference().

Examples

as_reference()
#> <rapid::reference>
#>  @ ref_uri    : chr(0) 
#>  @ summary    : chr(0) 
#>  @ description: chr(0) 
as_reference(list(`$ref` = "#/components/schemas/Pet"))
#> <rapid::reference>
#>  @ ref_uri    : chr "#/components/schemas/Pet"
#>  @ summary    : chr(0) 
#>  @ description: chr(0)