go-swagger toolkit

Swagger 2.0 describes your API's for you, so you don't have to

swagger:meta

spec generate

The swagger:meta annotation flags a file as source for metadata about the API. This is typically a doc.go file with your package documentation. You can specify a Consumes and Produces key which has a new content type on each line Schemes is a tag that is required and allows for a comma separated string composed of: http, https, ws or wss Host and BasePath can be specified but those values will be defaults, they should get substituted when serving the swagger spec.

14 Nov 2015

Generate an API client

The toolkit has a command that will let you generate a client. Usage To generate a client: swagger generate client -f [http-url|filepath] -A [application-name] [--principal [principal-name]] Use a default client, which has an HTTP transport: import ( "log" "github.com/myproject/client/operations" "github.com/go-swagger/go-swagger/strfmt" "github.com/go-swagger/go-swagger/spec" apiclient "github.com/myproject/client" httptransport "github.com/go-swagger/go-swagger/httpkit/client" ) func main() { // make the request to get all items resp, err := apiclient.Default.Operations.All(operations.AllParams{}) if err != nil { log.Fatal(err) } fmt.Printf("%#v\n", resp.Payload)

23 Oct 2015

Validate a swagger spec

Validate a swagger spec The toolkit has a command to validate swagger specifications for you. It includes a full json-schema validator and adds a bunch of extra validations on top of that to ensure the spec is as valid as possible, so that there are no surprises. Usage To validate a specification: swagger validate [http-url|filepath] Supported rules All the rules the validator tool supports: validate against jsonschema validate extra rules

22 Oct 2015