package ppx_deriving_jsonschema

  1. Overview
  2. Docs
Jsonschema generator for ppx_deriving

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ppx_deriving_jsonschema-0.0.3.tbz
sha256=d517fc97fabe39ef8eea49dcc91b9abec03e86fdcb53fcf37b046aa0954e4d1a
sha512=b9785ea7c0394946d4585839da4d137c2ea15642f2588df3c3506e514c08f4e8413a59dd075730d7e55e686dc165140c5cdce90e5eb349b439953dba9a142d76

doc/src/ppx_deriving_jsonschema.runtime/ppx_deriving_jsonschema_runtime.ml.html

Source file ppx_deriving_jsonschema_runtime.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
let schema_version = "https://json-schema.org/draft/2020-12/schema"

let json_schema ?id ?title ?description ?definitions types =
  match types with
  | `Assoc types ->
    let metadata =
      List.filter_map
        (fun x -> x)
        [
          Some ("$schema", `String schema_version);
          (match id with
          | None -> None
          | Some id -> Some ("$id", `String id));
          (match title with
          | None -> None
          | Some title -> Some ("title", `String title));
          (match description with
          | None -> None
          | Some description -> Some ("description", `String description));
          (match definitions with
          | None -> None
          | Some defs -> Some ("$defs", `Assoc defs));
        ]
    in
    `Assoc (metadata @ types)
OCaml

Innovation. Community. Security.