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.2.tbz
sha256=fc8a8ff5d75e3b9d296324dafd6b823cc5869486ef9b7e5dcbf7df6304ac3d04
sha512=71663dfb7fb02c2d96bb5b55d5293eb3ca745aa949e53356a78708d09468b80e02e5d2847f309cb92f55db8e429fcc97f53a6e9f18bf2c8d11896ee026e1c65a

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.