swagger

package module
v0.0.0-...-a784d27 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

README

Swagger 2.0 Run CI codecovGo Report Card

GitHub version Docker Repository on Quay Docker Repository on Github GitHub commits since latest release

Slack Status license GoDoc

Open SSF Scorecard FOSSA Status


This project contains a golang implementation of Swagger 2.0 (aka OpenAPI 2.0). It provide tools to work with swagger specifications.

Swagger is a simple yet powerful representation of your RESTful API.

Documentation

https://goswagger.io

Features

go-swagger brings to the go community a complete suite of fully-featured, high-performance, API components to work with a Swagger API: server, client and data model.

  • Generates a server from a swagger specification
  • Generates a client from a swagger specification
  • Generates a CLI (command line tool) from a swagger specification (alpha stage)
  • Supports most features offered by jsonschema and swagger, including polymorphism
  • Generates a swagger specification from annotated go code
  • Additional tools to work with a swagger spec
  • Great customization features, with vendor extensions and customizable templates

Our focus with code generation is to produce idiomatic, fast go code, which plays nice with golint, go vet etc.

More details.

Project status

This project supports OpenAPI 2.0. At this moment it does not support OpenAPI 3.x.

go-swagger is now feature complete and has stabilized its API.

Most features and building blocks are now in a stable state, with a rich set of CI tests.

The go-openapi community actively continues bringing fixes and enhancements to this code base.

There is still much room for improvement: contributors and PR's are welcome. You may also get in touch with maintainers on our slack channel.

Installing

go install github.com/go-swagger/go-swagger/cmd/swagger@latest

go-swagger is also available as binary or docker releases as well as from source: more details.

Try it

Try go-swagger in a free online workspace using Gitpod:

Open in Gitpod

Licensing

The toolkit itself is licensed under an Apache Software License 2.0.

Just like swagger, this does not cover code generated by the toolkit. That code is entirely yours to license however you see fit.

Licence scan on dependencies

FOSSA Status

Documentation

Overview

Package swagger (2.0) provides a powerful interface to your API

Contains an implementation of Swagger 2.0. It knows how to serialize, deserialize and validate swagger specifications.

Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment.

With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. We created Swagger to help fulfill the promise of APIs.

Swagger helps companies like Apigee, Getty Images, Intuit, LivingSocial, McKesson, Microsoft, Morningstar, and PayPal build the best possible services with RESTful APIs.Now in version 2.0, Swagger is more enabling than ever. And it's 100% open source software.

More detailed documentation is available at https://goswagger.io.

Install:

go get -u github.com/go-swagger/go-swagger/cmd/swagger

The implementation also provides a number of command line tools to help working with swagger.

Currently there is a spec validator tool:

swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json

To generate a server for a swagger spec document:

swagger generate server [-f ./swagger.json] -A [application-name [--principal [principal-name]]

To generate a client for a swagger spec document:

swagger generate client [-f ./swagger.json] -A [application-name [--principal [principal-name]]

To generate a swagger spec document for a go application:

swagger generate spec -o ./swagger.json

There are several other sub commands available for the generate command

Sub command | Description
------------|----------------------------------------------------------------------------------
operation   | generates one or more operations specified in the swagger definition
model       | generates model files for one or more models specified in the swagger definition
support     | generates the api builder and the main method
server      | generates an entire server application
client      | generates a client for a swagger specification
spec        | generates a swagger spec document based on go code

Generating code

You're free to add files to the directories the generated code lands in, but the files generated by the generator itself will be regenerated on following generation runs so any changes to those files will be lost. However extra files you create won't be lost so they are safe to use for customizing the application to your needs.

To generate a server for a swagger spec document:

swagger generate server -f ./swagger.json -A [application-name] [--principal [principal-name]]

Directories

Path Synopsis
cmd
swagger/commands/internal/cmdtest
Package cmdtest provides test utilities to assert the output of CLI commands
Package cmdtest provides test utilities to assert the output of CLI commands
Package codescan provides a scanner for go files that produces a swagger spec document.
Package codescan provides a scanner for go files that produces a swagger spec document.
examples
authentication/restapi
Package restapi keyauth debug
Package restapi keyauth debug
auto-configure/restapi
Package restapi A To Do list application
Package restapi A To Do list application
composed-auth/restapi
Package restapi Composing authorizations
Package restapi Composing authorizations
Package restapi Petstore
external-types/restapi
Package restapi external types imports: external anonymous types
Package restapi external types imports: external anonymous types
file-server/restapi
Package restapi File Upload
Package restapi File Upload
generated/restapi
Package restapi Swagger Petstore
Package restapi Swagger Petstore
oauth2/restapi
Package restapi oauth2 debug
Package restapi oauth2 debug
stream-server/restapi
Package restapi Countdown
Package restapi Countdown
task-tracker/restapi
Package restapi Issue Tracker API
Package restapi Issue Tracker API
todo-list-strict/restapi
Package restapi Simple To Do List API
Package restapi Simple To Do List API
todo-list/restapi
Package restapi Simple To Do List API
Package restapi Simple To Do List API
tutorials/custom-server/gen/restapi
Package restapi Greeting Server
Package restapi Greeting Server
tutorials/todo-list/server-1/restapi
Package restapi A To Do list application
Package restapi A To Do list application
tutorials/todo-list/server-2/restapi
Package restapi A To Do list application
Package restapi A To Do list application
tutorials/todo-list/server-complete/restapi
Package restapi A To Do list application
Package restapi A To Do list application
fixtures
enhancements/793
Package petstore API
Package petstore API
goparsing/bookings
Package booking API.
Package booking API.
goparsing/classification
Package classification Petstore API.
Package classification Petstore API.
goparsing/meta/v1
Package meta Petstore API.
Package meta Petstore API.
goparsing/meta/v2
Package meta Petstore API.
Package meta Petstore API.
goparsing/meta/v3
Package meta Petstore API.
Package meta Petstore API.
goparsing/meta/v4
Package meta Petstore API.
Package meta Petstore API.
goparsing/petstore
Package petstore Petstore API.
Package petstore Petstore API.
goparsing/spec
Package booking API.
Package booking API.
Package generator provides the code generation library for go-swagger.
Package generator provides the code generation library for go-swagger.
internal/gentest
Package gentest provides internal test utilities
Package gentest provides internal test utilities

Jump to

Keyboard shortcuts

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