OAS Generator

Generate Gleam clients from Open API Specs.

Package Version Hex Docs

✨ Features

Doesn’t support all uses of datatype composition for example AnyOf and OneOf.

πŸ› οΈ Usage

Install as a dev dependency.

gleam add --dev oas_generator@1

Fetch the JSON version of your API specification.

An example for a petstore is available here

Create a module that will call the build function.

Adding the module to the test dir means it is not added to the published library. Support for a dev directory is coming later https://discord.com/channels/768594524158427167/1047099923897794590/threads/1365928769956610090

// test/petstore/dev
import gleam/io
import oas/generator
import snag

pub fn main() {
  case generator.build("./priv/petstore.openapi.json", ".", "petstore") {
    Ok(_) -> Nil
    Error(reason) -> io.print(snag.pretty_print(reason))
  }
}

Run the generator.

gleam run -m petstore/dev

πŸ“š Documentation

Further documentation can be found at https://hexdocs.pm/oas_generator.

πŸ§ͺ Development

gleam test  # Run the tests

πŸ§‘β€πŸ’» Credit

Created for Spotless, a code first integration platform.

✨ Search Document