apidoc

package
v0.0.0-...-3d294e8 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 4 Imported by: 10

Documentation

Overview

Package apidoc implements reflection based api documentation using the OpenAPI 2.0 specification (Swagger).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reference

func Reference(t reflect.Type) string

Reference returns the reference string for the given type.

Types

type Documentation

type Documentation struct {
	Swagger spec.Swagger
}

Documentation wraps the Swagger object of the spec Package.

func New

func New(info *Info) *Documentation

New creates a new documentation.

func (*Documentation) Add

func (doc *Documentation) Add(op *Operation) error

Add a new operation to the documentation.

func (*Documentation) SetApiKeyAuth

func (doc *Documentation) SetApiKeyAuth(in, name string)

SetApiKeyAuth enables the global ApiKey security scheme.

type Info

type Info struct {
	Host        string
	Path        string
	Title       string
	Description string
	Schemes     []string
	Version     string
}

Info holds basic API Information.

type Operation

type Operation struct {
	// Method of this operation.
	Method string

	// Pattern of this operation.
	Pattern string

	// Tags in which this operation will be grouped.
	Tags []string

	// Description of the operation
	Description string

	// Unauthenticated set to true will disable all security defintions.
	Unauthenticated bool

	PathParams []PathParam

	QueryParams []QueryParam

	Input interface{}

	Output interface{}
}

Operation represents an API Operation.

type ParamType

type ParamType string
const (
	Integer ParamType = "integer"
	Number  ParamType = "number"
	String  ParamType = "string"
	Boolean ParamType = "boolean"
)

type PathParam

type PathParam struct {
	Name        string
	Type        ParamType
	Description string
}

type QueryParam

type QueryParam struct {
	Name        string
	Type        ParamType
	Required    bool
	Description string
}

Jump to

Keyboard shortcuts

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