4 ms·
JSONSchema has a concept of "$refs", which is a way to encode a pointer to a value in a JSONSchema. $refs can point to another node in the same graph, a node in
by bcherny 10y ago
JSONSchema has a concept of "$refs", which is a way to encode a pointer to a value in a JSONSchema. $refs can point to another node in the same graph, a node in another JSONSchema on the same filesystem, or a node in another JSONSchema fetched over the network.
$refs are used in JSONSchema, but are described in the separate JSONPointer spec [0].
See unit tests for examples:
- In-file $ref: https://github.com/bcherny/json-schema-to-typescript/blob/master/test/e2e/ref.2.ts https://github.com/bcherny/json-schema-to-typescript/blob/ma...
- Local $ref: https://github.com/bcherny/json-schema-to-typescript/blob/master/test/e2e/ref.1.ts https://github.com/bcherny/json-schema-to-typescript/blob/ma...
- Remote $ref: https://github.com/bcherny/json-schema-to-typescript/blob/master/test/e2e/ref.3.ts https://github.com/bcherny/json-schema-to-typescript/blob/ma...
- Cyclical $ref: https://github.com/bcherny/json-schema-to-typescript/blob/master/test/e2e/refWithCycle.1.ts https://github.com/bcherny/json-schema-to-typescript/blob/ma...
Hope that helps!
[0] https://tools.ietf.org/html/rfc6901 https://tools.ietf.org/html/rfc6901