Skip to contents

as_foundry_schema() is a small validation/conversion helper. It returns raw JSON Schema lists unchanged, so code can accept either schemas built with foundryR constructors or hand-written JSON Schema lists. If the ellmer package is installed, ellmer::type_object() specifications are converted to the equivalent strict JSON Schema, so ellmer users can pass their existing type definitions to foundry_extract() and foundry_response().

Usage

as_foundry_schema(x)

Arguments

x

Object to convert. Either a foundryR/JSON Schema list or an ellmer type_object() specification.

Value

A JSON Schema represented as an R list.

Examples

schema <- foundry_schema(label = schema_string())
as_foundry_schema(schema)
#> $type
#> [1] "object"
#> 
#> $properties
#> $properties$label
#> $properties$label$type
#> [1] "string"
#> 
#> 
#> 
#> $required
#> [1] "label"
#> 
#> $additionalProperties
#> [1] FALSE
#>