docs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTag       = "default"
	BindingTag       = "binding"
	HeaderTag        = "header"
	JsonTag          = "json"
	DefaultStatusTag = "default_status"
	StatusCodesTag   = "status_codes"
	NoUrl            = "-"
)

Variables

This section is empty.

Functions

func DefaultStatus

func DefaultStatus(type_ reflect.Type) int

Types

type Docs

type Docs struct {
	OpenApi        *openapi3.T
	InteractiveUrl string
	JsonUrl        string
	YamlUrl        string
}

func New added in v0.5.0

func New(options *Options) *Docs

func (*Docs) NormalizePath added in v0.5.0

func (d *Docs) NormalizePath(path string) string

func (*Docs) PathItem

func (d *Docs) PathItem(path string) *openapi3.PathItem

func (*Docs) RegisterRoutes added in v0.5.0

func (d *Docs) RegisterRoutes(router gin.IRouter, port string)

func (*Docs) SaveAsJson added in v0.5.0

func (d *Docs) SaveAsJson(path string) error

func (*Docs) SaveAsYaml added in v0.5.0

func (d *Docs) SaveAsYaml(path string) error

func (*Docs) SetPath added in v0.4.0

func (d *Docs) SetPath(path string, method string, doc *Endpoint)

type Endpoint added in v0.4.0

type Endpoint openapi3.Operation

func (*Endpoint) AddHeadersType added in v0.4.0

func (e *Endpoint) AddHeadersType(headerType reflect.Type)

func (*Endpoint) AddPathParam added in v0.4.0

func (e *Endpoint) AddPathParam(name string, type_ reflect.Type)

func (*Endpoint) SetBodyType added in v0.4.0

func (e *Endpoint) SetBodyType(bodyType reflect.Type)

func (*Endpoint) SetQueryType added in v0.4.0

func (e *Endpoint) SetQueryType(queryType reflect.Type)

func (*Endpoint) SetResponses added in v0.4.0

func (e *Endpoint) SetResponses(responseType reflect.Type, errorType reflect.Type)

func (*Endpoint) SetTagsFromPath added in v0.4.0

func (e *Endpoint) SetTagsFromPath(path string)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(docs *Docs, port string) *Handler

func (*Handler) Docs

func (h *Handler) Docs(ctx *gin.Context)

func (*Handler) JsonFile added in v0.5.0

func (h *Handler) JsonFile(ctx *gin.Context)

func (*Handler) YamlFile added in v0.5.0

func (h *Handler) YamlFile(ctx *gin.Context)

type Options added in v0.5.0

type Options struct {
	// ExtensionProps OpenAPI extensions.
	// It reads/writes all properties with prefix "x-".
	// It is empty as default.
	ExtensionProps openapi3.ExtensionProps

	// Title of the documentation.
	// If not set, the default value is "Documentation".
	Title string

	// Description of the documentation.
	// It is empty as default.
	Description string

	// TermsOfService usually should contain the URL to terms of service.
	// It is empty as default.
	TermsOfService string

	// Contact information must be in openAPI format.
	// It is empty as default.
	Contact *openapi3.Contact

	// License information must be in openAPI format.
	// It is empty as default.
	License *openapi3.License

	// Version of the documentation.
	// If not set, the default value is "1.0.0".
	Version string

	// InteractiveUrl is the path where your interactive documentation will be placed. It must be an absolute path, started with "/".
	// If you run the server locally, then your interactive docs will be under "http://localhost:<port><InteractiveUrl>".
	// If set to NoUrl, the interactive documentation will not be served.
	// If not set, the default value is "/docs".
	//
	// Interactive documentation uses the JSON file, thus it requires the JsonUrl is set to a valid url.
	// If the JsonUrl is set to NoUrl, the interactive documentation will be disabled.
	InteractiveUrl string

	// JsonUrl is the path where your openAPI in JSON format will be placed. It must be an absolute path, started with "/".
	// If you run the server locally, then the file will be under "http://localhost:<port><JsonUrl>".
	// If set to NoUrl, the json file will not be served.
	// If not set, the default value is "/docs.json".
	JsonUrl string

	// YamlUrl is the path where your openAPI in YAML format will be placed. It must be an absolute path, started with "/".
	// If you run the server locally, then the file will be under "http://localhost:<port><YamlUrl>".
	// If set to NoUrl, the yaml file will not be served.
	// If not set, the default value is "/docs.yaml".
	YamlUrl string

	// Servers is the list of the API locations. In interactive documentation (see InteractiveUrl) you can try your API out using one of those servers.
	// In case it is an empty list, it will be empty.
	// In case it is nil, the default value is a list with one element "http://localhost:8080".
	Servers []string

	// Tags for the documentation.
	// It is empty as default.
	Tags []string
}

Jump to

Keyboard shortcuts

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