@cloudflare/json-schema-transform v0.1.1
JSON Schema Transform
A collection of utilities for analyzing and manipulating JSON Schemas statically (without an instance).
Currently, the transformations fall into two categories:
Loading and dereferencing
The AutoExtensionDereferencer class can parse JSON Schemas in JSON, JSON5, YAML, and JavaScript format, and uses the json-schema-ref-parser package to remove all $refs. When dereferencing, no circular references are allowed.
This functionality is used by @cloudflare/json-schema-ref-loader.
Producing API documentation-friendly schemas
Several utilities are packaged up as processApiDocSchema()
which does the following, all of which can be accessed as
individual functions. These functions generally assume that
$refs have been dereferenced, which means that circular
references are not (yet) supported.
The API documentation processing involves:
- Collapsing
allOfs on the assumption that they are used to glue subschemas together, and should not be visible to documentation readers - Replace
"cfRecurse": ""with a copy of the non-linksand non-definitionsportion of a schema data structure (this may be changed to work without making a copy in the future, particularly if the similar$recurseproposed keyword makes it into draft-08) - Build examples out of individual object property and array item
examplevalues - Construct an example invocation of
curlfor each link, using the rolled-upexample
This functionality is used by @cloudflare/json-schema-apidoc-loader.
8 years ago