Skip to contents

Explicitly download remote $ref target documents and record them in specmill-references.yml beside a local schema, so parsing and generation resolve them offline.

Usage

freeze_references(schema, urls, refresh = FALSE)

Arguments

schema

Existing local JSON or YAML schema. The lock file is written beside it.

urls

HTTP(S) document URLs, without fragments, queries, dot segments or a trailing slash.

refresh

Replace an entry whose upstream bytes changed. Leave FALSE until you have reviewed the change.

Value

Invisibly, a data frame with url, file, sha256 and status: added, refreshed, restored (local copy rewritten to the recorded bytes) or unchanged.

Details

This is the only specmill function that fetches schema dependencies. Parsing, validation, generation and generated clients stay offline.

New files are stored under references/<host>/<path> inside the lock directory. Existing entries keep their file. Each download must parse as YAML when its file ends in .yaml or .yml, and as JSON otherwise. All URLs are downloaded and checked before any file or the lock changes; an unchanged re-run leaves the lock untouched. Rewriting the lock drops YAML comments written by hand.

Nested references are not followed. After freezing, read_operations() reports any remaining unmapped URL as external_reference; review it and freeze it too. Review downloaded content before committing it.

See also

read_operations, validate_schema

Examples

if (FALSE) { # \dontrun{
freeze_references(
  "schema/openapi.json",
  "https://schemas.opengis.net/ogcapi/features/part1/1.0/openapi/ogcapi-features-1.yaml"
)
read_operations("schema/openapi.json")$diagnostics
} # }