package jsonschema2atd

All checked builds pass
  1. Overview
  2. Docs
Generate ATD types out of JSON Schema and OpenAPI document

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.0.3.tar.gz
md5=8fd01d574c534f8f113f8c434e17f731
sha512=5ff33bc638307d41e8e41c3de44470bfb66b7c4ca3636aa58869accf37f5b2c732928e7d0bfd5ec63492f8463863d901e3a0b979a2a105acc7392ec0aa51a856

Description

Generate ATD types out of JSON Schema and OpenAPI document

Added to opam-repository:

README

jsonschema2atd

Generate an ATD file from a JSON Schema / OpenAPI document.

Installation

The package is available on opam.

opam install jsonschema2atd

If you wish to install the development version you can do so with:

make install

Usage

Generate an ATD file from a JSON Schema:

jsonschema2atd ../path-to-jsonschema.json

Generate an ATD file from an OpenAPI document:

jsonschema2atd --format openapi ../path-to-openapi.json

You can call jsonschema2atd and atdgen in your dune file to generate OCaml types and JSON serializers/deserializers from your JSON Schema or OpenAPI document:

; Add jsonschema2atd.runtime to have access to the oneOf serialization adapter (for variant unboxing).
(library
 ...
 (libraries ... jsonschema2atd.runtime))

; Generate dashboard_gen.atd from the dashboard_types_gen.json OpenAPI document with jsonschema2atd.
(rule
 (target dashboard_gen.atd)
 ; Store the generated .atd file in the code. 
 (mode promote)
 (deps ../grok/dashboard_types_gen.json)
 (action
  (with-stdout-to
   %{target}
   (run
    %{bin:jsonschema2atd} -f openapi
    %{deps}))))

; Generate dashboard_gen_t.mli, dashboard_gen_t.ml, dashboard_gen_j.mli, and dashboard_gen_j.ml from dashboard_gen.atd with atdgen.
(rule
 (targets
  dashboard_gen_t.mli
  dashboard_gen_t.ml
  dashboard_gen_j.mli
  dashboard_gen_j.ml)
 (deps dashboard_gen.atd)
 (action
  (progn
   (run %{bin:atdgen} -j -j-std -j-defaults %{deps})
   (run %{bin:atdgen} -t %{deps}))))

ToDo

  • Base types
  • Records
  • Nullable
  • String enums
  • Integer enums
  • Other primitive enums
  • Refs (OpenAPI format)
  • OneOf (Only serialization is supported)
  • not
  • anyOf
  • allOf

Dependencies (7)

  1. yojson
  2. dune-build-info
  3. cmdliner >= "1.1.0"
  4. atdgen-runtime >= "2.0"
  5. atdgen >= "2.7"
  6. ocaml >= "4.14"
  7. dune >= "3.0"

Dev Dependencies (4)

  1. ounit2 with-test
  2. odoc with-doc
  3. ocamlformat with-dev-setup & = "0.24.1"
  4. ocaml-lsp-server with-dev-setup

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building jsonschema2atd with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.0.3 (this version) n/a good good good good
0.0.1 good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure