openapi-cli-generator

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 20 Imported by: 0

README

OpenAPI CLI Generator

A fork of danielgtaylor/openapi-cli-generator that generates Go-based command-line clients from OpenAPI 3.0 specs. The upstream project is no longer maintained.

What this fork adds
  • Resource grouping -- commands are organized into subcommand groups based on URL path structure instead of a flat list (e.g. my-cli items list instead of my-cli list-items)
  • x-cli-group / x-cli-name extensions -- override the auto-derived group or action name per-operation
  • Action name derivation from HTTP method + path pattern (GET /resourceslist, POST /resources/{id}/actionaction)

Usage

Install the generator
go install github.com/WallfacerTech/openapi-cli-generator@latest
Generate a CLI

Create a project directory and generate commands from your OpenAPI spec:

mkdir my-cli && cd my-cli
go mod init my-cli
openapi-cli-generator generate openapi.yaml

This produces an openapi.go file with all the CLI commands. Create a main.go entrypoint:

package main

import "github.com/WallfacerTech/openapi-cli-generator/cli"

func main() {
	cli.Init(&cli.Config{
		AppName:   "my-cli",
		EnvPrefix: "MY_CLI",
		Version:   "1.0.0",
	})

	openapiRegister(false)
	cli.Root.Execute()
}

Build and run:

go build -o my-cli .
./my-cli --help

Features

  • Resource-grouped subcommands from URL path analysis
  • Syntax-highlighted JSON output
  • JMESPath response filtering via --filter
  • Table output format
  • OAuth 2.0, API key, and Auth0 authentication support
  • Input from files, stdin, or shorthand syntax
  • Caching and profile support

License

MIT -- see LICENSE.

Attribution

Originally created by Daniel G. Taylor.

Documentation

Overview

Code generated for package main by go-bindata DO NOT EDIT. (@generated) sources: templates/commands.tmpl templates/main.tmpl

Directories

Path Synopsis
Package apikey provides authentication profile support for APIs that require a pre-generated constant authenticationn key passed via a header, query parameter, or cookie value in each request.
Package apikey provides authentication profile support for APIs that require a pre-generated constant authenticationn key passed via a header, query parameter, or cookie value in each request.
j
Package oauth provides authentication profile support for APIs that require OAuth 2.0 auth.
Package oauth provides authentication profile support for APIs that require OAuth 2.0 auth.
Package shorthand provides a quick way to generate structured data via command line parameters.
Package shorthand provides a quick way to generate structured data via command line parameters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL