···11-# OCaml OpenAPI
22-33-OpenAPI code generator for OCaml, specialized for:
44-- **requests** HTTP library (Eio-based)
55-- **jsont** for JSON codecs
66-- Stdlib-first approach (avoiding Base/Core)
77-- OCamldoc comments from OpenAPI descriptions
88-99-## Quick Start
1010-1111-```bash
1212-# Generate client from OpenAPI spec
1313-opam exec -- dune exec -- openapi-gen generate spec.json -o ./generated -n my_api
1414-1515-# Include dune regeneration rules
1616-opam exec -- dune exec -- openapi-gen generate spec.json -o ./generated -n my_api --regen
1717-```
1818-1919-## Generated Code Structure
2020-2121-```
2222-output/
2323-├── dune # Build configuration (wrapped library)
2424-├── dune.inc # Regeneration rules (if --regen used)
2525-├── types.ml # Type definitions with jsont codecs
2626-├── types.mli # Type interfaces
2727-├── client.ml # API client functions using requests
2828-├── client.mli # Client interface
2929-├── <api_name>.ml # Wrapped main module
3030-└── <api_name>.mli # Main module interface
3131-```
3232-3333-## Usage
3434-3535-After generation, you can use the API like:
3636-3737-```ocaml
3838-(* Access types through the wrapped module *)
3939-let album : Immich.Types.AlbumResponseDto.t = ...
4040-4141-(* Create a client and make requests *)
4242-Eio_main.run @@ fun env ->
4343-Eio.Switch.run @@ fun sw ->
4444-let client = Immich.Client.create ~sw env ~base_url:"http://localhost:2283/api" in
4545-let json = Immich.Client.get_activities ~album_id:"..." client () in
4646-...
4747-```
4848-4949-## Regeneration with Dune
5050-5151-When using `--regen`, the generated `dune.inc` contains rules for:
5252-5353-```bash
5454-# Regenerate and promote changes
5555-dune build @gen --auto-promote
5656-```
5757-5858-## Architecture
5959-6060-- `lib/openapi_spec.ml` - OpenAPI 3.x specification types with jsont codecs
6161-- `lib/openapi_codegen.ml` - Code generation from spec to OCaml
6262-- `lib/openapi_runtime.ml` - Runtime utilities for generated clients
6363-- `bin/openapi_cli.ml` - CLI tool
6464-6565-## Build & Test
6666-6767-```bash
6868-opam exec -- dune build
6969-opam exec -- dune test
7070-```
+15
ocaml-openapi/LICENSE.md
···11+## ISC License
22+33+Copyright (c) Anil Madhavapeddy
44+55+Permission to use, copy, modify, and/or distribute this software for any
66+purpose with or without fee is hereby granted, provided that the above
77+copyright notice and this permission notice appear in all copies.
88+99+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1010+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1111+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1212+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1313+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1414+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1515+PERFORMANCE OF THIS SOFTWARE.
+8-3
ocaml-openapi/dune-project
···55(generate_opam_files true)
6677(license ISC)
88+89(authors "Anil Madhavapeddy")
99-(homepage "https://tangled.org/@anil.recoil.org/ocaml-openapi")
1010+1011(maintainers "Anil Madhavapeddy <anil@recoil.org>")
1111-(maintenance_intent "(latest)")
1212+1213(source (tangled anil.recoil.org/ocaml-openapi))
13141515+(homepage "https://tangled.org/@anil.recoil.org/ocaml-openapi")
1616+1717+(bug_reports "https://tangled.org/@anil.recoil.org/ocaml-openapi/issues")
1818+1419(package
1520 (name openapi)
1621 (synopsis "OpenAPI code generator for OCaml with requests and jsont")
1722 (description
1823 "Generate type-safe OCaml API clients from OpenAPI 3.x specifications.
1919- Uses the requests HTTP library and jsont for JSON codecs.")
2424+Uses the requests HTTP library and jsont for JSON codecs.")
2025 (depends
2126 (ocaml (>= 5.1.0))
2227 jsont
+2-2
ocaml-openapi/openapi.opam
···33synopsis: "OpenAPI code generator for OCaml with requests and jsont"
44description: """
55Generate type-safe OCaml API clients from OpenAPI 3.x specifications.
66- Uses the requests HTTP library and jsont for JSON codecs."""
66+Uses the requests HTTP library and jsont for JSON codecs."""
77maintainer: ["Anil Madhavapeddy <anil@recoil.org>"]
88authors: ["Anil Madhavapeddy"]
99license: "ISC"
1010homepage: "https://tangled.org/@anil.recoil.org/ocaml-openapi"
1111-bug-reports: "https://tangled.org/anil.recoil.org/ocaml-openapi/issues"
1111+bug-reports: "https://tangled.org/@anil.recoil.org/ocaml-openapi/issues"
1212depends: [
1313 "dune" {>= "3.21"}
1414 "ocaml" {>= "5.1.0"}