Movatterモバイル変換


[0]ホーム

URL:


packageopenapi_router

  1. Overview
  2. Docs

You can search for identifiers within the package.

in-package search v0.2.0

Http server agnostic Openapi documentation generation

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.0.tar.gz
md5=aefecd4c5248ee6d489c43c953577bbc
sha512=99141a7ab8ef04b70db561fb9f0d994496ad7a835bc4f44fad6faec9e0b204a9485f7c1166a63d81e0e9f87eddd189f75330d570fe3d22609e7d27f7b454ade4

Description

A functor to wrap your http server and produce an Openapi documentation pages

Published:14 Sep 2022

README

README.md

This a fork ofopenapi

Openapi for Ocaml

This library is a fork ofopenapi. The goal is to provide a way to generate Openapi UI not only for Opium, but for every http servers. To achieve this, this library provides a functor that'll create a layer above all the methods (get,post,put, ...) and generate a json and a documentation endpoint

Usage

Example withDream

module Config = struct  type app = Dream.handler  type route = Dream.route  type handler = Dream.handler  let json_path = "/openapi.json"  let doc_path = "/docs"  let json_route json = Dream.get json_path (fun _ -> Dream.json json)  let doc_route html = Dream.get doc_path (fun _ -> Dream.html html)  let get = Dream.get  let post = Dream.post  let delete = Dream.delete  let put = Dream.put  let options = Dream.options  let head = Dream.head  let patch = Dream.patch  let build_routes = Dream.routerendmodule OpenRouter = Openapi.Make (Config)let start () =  OpenRouter.empty  |> OpenRouter.description "My app description"  |> OpenRouter.get ~description:"Hello endpoint" "/hello" hello  |> OpenRouter.build  |> Dream.logger  |> Dream.run ~interface:"0.0.0.0" ~port:8080

Example withOpium

module Config = struct  open Opium  type app = App.t  type handler = Rock.Handler.t  type route = App.builder  let json_path = "/openapi.json"  let doc_path = "/docs"  let json_route json =    App.get json_path (fun _ ->        Response.make          ~headers:(Headers.of_list [("Content-Type", "application/json")])          ~body:(Body.of_string json) ()        |> Lwt.return)  let doc_route html =    App.get json_path (fun _ ->        Response.make ~body:(Body.of_string html) () |> Lwt.return)  let get = App.get  let post = App.post  let delete = App.delete  let put = App.put  let options = App.options  let head = App.head  let patch = App.patch  let build_routes = List.fold_left (fun acc route -> route acc) App.emptyendmodule OpenRouter = Openapi.Make (Config)let start () =  OpenRouter.empty  |> OpenRouter.description "My app description"  |> OpenRouter.get ~description:"Hello endpoint" "/hello" hello  |> OpenRouter.build  |> Opium.App.start

Dependencies (5)

  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. dune>= "2.8"

Dev Dependencies (1)

  1. odocwith-doc

Used by

None

Conflicts

None


[8]ページ先頭

©2009-2025 Movatter.jp