package openapi

  1. Overview
  2. Docs
Openapi documentation generation for Opium

Install

Dune Dependency

Authors

Maintainers

Sources

openapi-v0.6.0.tbz
sha256=69fe5f6a245b5c977ff09ba52174bd67684283fadf4cb5d6608d6ad08b0ada3b
sha512=22f81e87e5614e7e98a80914fa6e104bb15446003804dc94af0b95902fc1ad96b5e66fa9c072aa5e09e886ba0a066285f49875e1be0ce4b77399f9a4951d6d16

Description

Shim layer around Opium.App (https://github.com/rgrinberg/opium/) for producing Openapi documentation pages

Published: 18 Mar 2022

README

Openapi for Ocaml

This library provides basic types for parsing/serializing openapi specifications and a nearly drop-in replacement for Opium.App that registers endpoints in a specification and serves openapi.json and docs pages based on the fastapi implementation.

Usage

Basic usage should work equivalently to Opium.App. So instead of

let open Opium in
App.empty
|> App.get "/path/:foo" (fun h -> Response.of_plain_text "hello world")
|> App.run_command

Just do:

let open Opium in
let module App = Openapi.App in
App.empty
|> App.get "/path/:foo" (fun h -> Response.of_plain_text "hello world")
|> App.run_command

The endpoint creation methods provided by Openapi.Opium.App accept additional optional arguments to provide specification information for to document the endpoint. Check the type signatures of these methods for more information.

Demo App

This library includes a demo app in bin/demo (that won't be installed by opam). To see the generated spec/documentation in action, run:

$ dune build
$ ./_build/default/bin/demo.exe

Then browse to http://localhost:8888/docs

Dependencies (6)

  1. ppx_deriving >= "5.2.1"
  2. ppx_yojson_conv >= "v0.14.0" & < "v0.16.0"
  3. core >= "v0.14.1"
  4. yojson >= "1.7.0"
  5. opium >= "0.20.0"
  6. dune >= "2.8"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.