Skip to content

cussrox/swac

 
 

Repository files navigation

OpenAPI 3.0 / Swagger 2.0 compiler

A tool to render API spec as code.

Build Status codecov Image Size Code lines Comments

Installation

Phar

Download swac from releases page.

Docker

docker run swaggest/swac swac --help
v0.1.0 swac
OpenAPI/Swagger compiler, https://github.com/swaggest/swac
Usage: 
   swac <action>
   action   Action name                                 
            Allowed values: php-guzzle-client, go-client
...

Example

mkdir petstore && cd petstore
docker run -v $(pwd):/code swaggest/swac swac php-guzzle-client https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore.json --namespace MyApp\\Petstore

Composer

Install PHP Composer

composer global require swaggest/swac

Usage

PHP Client

swac php-guzzle-client --help
v0.1.0 swac php-guzzle-client
OpenAPI/Swagger compiler, https://github.com/swaggest/swac
Usage: 
   swac php-guzzle-client <schemaPath> --namespace <namespace>
   schemaPath   Path/URL to OpenAPI/Swagger schema
   
Options: 
   --operations <operations>      Operations filter in form of comma-separated list of method/path, default empty
   --project-path <projectPath>   Path to project root, default ./                                               
   --namespace <namespace>        Project namespace

Generated client depends on swaggest/rest-client, guzzlehttp/guzzle 6, and swaggest/json-schema.

Examples.

Go Client

swac go-client --help 
v0.1.0 swac go-client
OpenAPI/Swagger compiler, https://github.com/swaggest/swac
Usage: 
   swac go-client <schemaPath>
   schemaPath   Path/URL to OpenAPI/Swagger schema
   
Options: 
   --operations <operations>   Operations filter in form of comma-separated list of method/path, default empty
   --out <out>                 Path to output package, default ./client                                       
   --pkg-name <pkgName>        Output package name, default "client"                                          

Examples.

Generated client is a single package without external dependencies.

About

OpenAPI/Swagger compiler

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 98.7%
  • Makefile 1.3%