| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A CLI tool that generates a Lua client library from an OpenAPI spec.
Most of this project was vibe coded. Please review the output and use at your own risk.
Given an OpenAPI (v3) JSON file, this tool generates a Lua module with a nested table structure that mirrors your API paths, and convenience methods for each operation.
I couldn’t find a working generator that fit my needs, and I only needed this for a specific use case. If a better tool comes around, I’ll likely just archive this one.
npx openapi-2-lua --spec openapi.json --out client.lua --name Clientnpm i -g openapi-2-lua
openapi-2-lua --spec openapi.json --out client.lua --name Clientnpx openapi-2-lua@latests --spec openapi.json --out client.lua --name ClientThe generated client expects you to provide a request function on construction that accepts a single table argument in this shape:
-- request { url = string, body? = string, headers? = { [string] = string }, binary? = boolean,
-- method? = string, redirect? = boolean, timeout? = number }The generated client calls it like:
return self.request(request_options)Pass query parameters via options.query on any generated endpoint call.
client.echo.post({
query = {
q = "hello world",
count = 2,
include = { "a", "b" }
}
})
-- /echo?count=2&include=a&include=b&q=hello%20worldNotes:
local Client = require("client")
local client = Client:new({
baseUrl = "https://api.example.com",
request = function(opts)
-- implement your HTTP call here
-- opts.url, opts.method, opts.headers, opts.body, ...
end
})
-- Example endpoint call (depends on your spec)
-- client.users["@me"].get()This repo includes a GitHub Actions workflow that publishes to npm when you push a version tag like v1.2.3.
| Back | FazBrowse Home | New Git URL |