Skip to content

amer8/apibconv

Repository files navigation

apibconv

CI codecov Go Reference Go Report Card Go Version Docker Image License

Convert between API Blueprint (*.apib), OpenAPI 2.0/3.0/3.1, and AsyncAPI 2.x/3.0 specifications.

Installation

Using Go

go install github.com/amer8/apibconv/cmd/apibconv@latest

Using Docker

Pull the image

docker pull ghcr.io/amer8/apibconv:latest

Run directly

docker run --rm -v $(pwd):/data -w /data ghcr.io/amer8/apibconv -o openapi.json api.apib

Download Binary

Download pre-built binaries from GitHub Releases:

  • published release assets cover Linux, macOS, and Windows on x64 and arm64
  • each platform archive ships with a matching *_checksums.txt file for targeted verification
  • signed releases also ship a matching *.sigstore.json bundle for the checksum file
  • each release also includes a CycloneDX bom.json SBOM

Older releases may only have the checksum file. In that case, verify the checksum directly.

Example verification:

cosign verify-blob \
  --bundle apibconv_X.Y.Z_Linux_x86_64.tar.gz_checksums.txt.sigstore.json \
  --certificate-identity "https://github.com/amer8/apibconv/.github/workflows/release.yml@refs/tags/vX.Y.Z" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  apibconv_X.Y.Z_Linux_x86_64.tar.gz_checksums.txt

sha256sum -c apibconv_X.Y.Z_Linux_x86_64.tar.gz_checksums.txt

Usage

CLI Usage

The tool automatically detects the input format based on file extension and content. It supports both file arguments and stdin.

Usage: apibconv [OPTIONS] [INPUT_FILE]

Arguments:
  INPUT_FILE
      Input specification file (OpenAPI, AsyncAPI, or API Blueprint)

Options:
  -o, --output FILE
      Output file path (required for conversion)
  
  --to FORMAT
      Target format: openapi, asyncapi, apib
      Auto-detected from --output extension if not specified
  
  -e, --encoding FORMAT
      Output encoding: json, yaml (default: auto-detected from output extension)
  
  --validate
      Validate input without converting. Pinned OpenAPI and AsyncAPI versions
      are checked against specification JSON Schemas plus model validation
  
  -v, --version
      Print version information
  
  -h, --help
      Show this help message

AsyncAPI Options:
  --protocol PROTO
      Protocol: ws, wss, mqtt, kafka, amqp, http, https, auto (required)
  
  --asyncapi-version VERSION
      Version: 2.6, 3.0 (default: "2.6")

OpenAPI Options:
  --openapi-version VERSION
      Version: 2.0, 3.0, 3.1 (default: "3.0")

Examples:
  apibconv -o output.json spec.apib
  apibconv -o output.yaml --protocol ws spec.apib
  apibconv -o output.json --to openapi --openapi-version 3.1 < spec.apib
  apibconv --validate spec.json

GitHub Actions

For GitHub Actions, prefer the first-party install action over go install ...@latest. Pin the action itself to a full commit SHA and pin the binary version to a release tag.

- name: Install apibconv
  uses: amer8/apibconv@<full-commit-sha>
  with:
    version: vX.Y.Z

- name: Convert OpenAPI to API Blueprint
  run: apibconv -o api-blueprint.apib openapi.json

The action downloads the published release asset for the current runner, verifies its SHA-256 checksum, and when the release includes a Sigstore bundle it also verifies the checksum signature with cosign against this repository's release workflow identity. Older releases without a bundle fall back to checksum-only verification with a warning. Published action assets target x64 and arm64 runners.

Go projects

This tool is designed for seamless integration with servers and CLI tools built in Go.

Contributing

Contributions are welcome! Please ensure:

  1. All tests pass: go test ./...
  2. Linter passes: golangci-lint run
  3. Code coverage remains high

License

See LICENSE file for details.

About

Convert between API Blueprint (*.apib), OpenAPI 2.0/3.0.x/3.1.x, and AsyncAPI 2.6/3.0 specifications.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors