goapidoc

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 15 Imported by: 0

README

goapidoc

Build Status codecov Go Report Card License Release

  • A golang library for generating api document, including swagger2 and apib.
Function
  • Support api, routes and definitions information
  • Support generic definition type
  • Support most of the functions for swagger 2
  • Support basic functions for API Blueprint 1A
Usage
package main

import (
	. "github.com/Aoi-hosizora/goapidoc"
)

func main() {
	SetDocument("localhost:60001", "/",
		NewInfo("Demo api", "This is a demo api only for testing goapidoc.", "1.0.0").
			License(NewLicense("MIT", "")).
			Contact(NewContact("", "https://github.com/Aoi-hosizora", "")),
	)

	SetOption(NewOption().
		Schemes("http").
		Tags(
			NewTag("Authorization", "auth-controller"),
			NewTag("User", "user-controller"),
		).
		Securities(
			NewApiKeySecurity("jwt", HEADER, "Authorization"),
		).
		GlobalParams(
			NewQueryParam("force_refresh", "boolean", false, "force refresh flag").Default(false),
			NewHeaderParam("X-Special-Flag", "string", false, "a special flag in header").Example("token-xxx"),
		),
	)

	AddOperations(
		NewPostOperation("/auth/register", "Sign up").
			Tags("Authorization").
			Params(
				NewBodyParam("param", "RegisterParam", true, "register param"),
			).
			Responses(
				NewResponse(200, "Result"),
			),

		NewPostOperation("/auth/login", "Sign in").
			Tags("Authorization").
			Params(
				NewBodyParam("param", "LoginParam", true, "login param"),
			).
			Responses(
				NewResponse(200, "_Result<LoginDto>"),
			),

		NewGetOperation("/auth/me", "Get the authorized user").
			Tags("Authorization").
			Securities("jwt").
			Responses(
				NewResponse(200, "_Result<UserDto>"),
			),

		NewDeleteOperation("/auth/logout", "Sign out").
			Tags("Authorization").
			Securities("jwt").
			Responses(
				NewResponse(200, "Result"),
			),
	)

	AddOperations(
		NewGetOperation("/user", "Query all users").
			Tags("User").
			Securities("jwt").
			Params(
				NewQueryParam("page", "integer#int32", false, "query page").Default(1),
				NewQueryParam("limit", "integer#int32", false, "page size").Default(20),
				NewQueryParam("force_refresh", "boolean", false, "force refresh flag for querying users").Default(false),
				NewHeaderParam("X-Special-Flag", "string", true, "a special flag in header, which must be set for querying users"),
			).
			Responses(
				NewResponse(200, "_Result<_Page<UserDto>>"),
			),

		NewGetOperation("/user/{id}", "Query the specific user").
			Tags("User").
			Securities("jwt").
			Params(
				NewPathParam("id", "integer#int64", true, "user id"),
			).
			Responses(
				NewResponse(200, "_Result<UserDto>"),
			),

		NewPutOperation("/user", "Update the authorized user").
			Tags("User").
			Securities("jwt").
			Params(
				NewBodyParam("param", "UpdateUserParam", true, "update user param"),
			).
			Responses(
				NewResponse(200, "Result"),
			),

		NewDeleteOperation("/user", "Delete the authorized user").
			Tags("User").
			Securities("jwt").
			Responses(
				NewResponse(200, "Result"),
			),
	)

	AddDefinitions(
		NewDefinition("Result", "Global response").
			Properties(
				NewProperty("code", "integer#int32", true, "status code"),
				NewProperty("message", "string", true, "status message"),
			),

		NewDefinition("_Result", "Global generic response").
			Generics("T").
			Properties(
				NewProperty("code", "integer#int32", true, "status code"),
				NewProperty("message", "string", true, "status message"),
				NewProperty("data", "T", true, "response data"),
			),

		NewDefinition("_Page", "Global generic page response").
			Generics("T").
			Properties(
				NewProperty("page", "integer#int32", true, "current page"),
				NewProperty("limit", "integer#int32", true, "page size"),
				NewProperty("total", "integer#int32", true, "total count"),
				NewProperty("data", "T[]", true, "response data"),
			),

		NewDefinition("LoginParam", "Login parameter").
			Properties(
				NewProperty("username", "string", true, "username"),
				NewProperty("password", "string", true, "password"),
			),

		NewDefinition("RegisterParam", "Register parameter").
			Properties(
				NewProperty("username", "string", true, "username"),
				NewProperty("password", "string", true, "password"),
			),

		NewDefinition("UpdateUserParam", "Update user parameter").
			Properties(
				NewProperty("username", "string", true, "username"),
				NewProperty("bio", "string", true, "user bio"),
				NewProperty("gender", "string", true, "user gender").Enum("Secret", "Male", "Female"),
				NewProperty("birthday", "string#date", true, "user birthday"),
			),

		NewDefinition("LoginDto", "Login response").
			Properties(
				NewProperty("user", "UserDto", true, "authorized user"),
				NewProperty("token", "string", true, "access token"),
			),

		NewDefinition("UserDto", "User response").
			Properties(
				NewProperty("id", "integer#int64", true, "user id"),
				NewProperty("username", "string", true, "username"),
				NewProperty("bio", "string", true, "user bio"),
				NewProperty("gender", "string", true, "user gender").Enum("Secret", "Male", "Female"),
				NewProperty("birthday", "string#date", true, "user birthday"),
			),
	)

	_, _ = SaveSwaggerYaml("./docs/api3.yaml")
	_, _ = SaveSwaggerJson("./docs/api3.json")
	_, _ = SaveApib("./docs/api3.apib")
}
References

Documentation

Index

Constants

View Source
const (
	BASIC  = "basic"  // BASIC security type: basic authentication
	APIKEY = "apiKey" // APIKEY security type: api key authentication
	OAUTH2 = "oauth2" // OAUTH2 security type: oauth2 authentication
)

security type

View Source
const (
	IMPLICIT_FLOW    = "implicit"    // IMPLICIT_FLOW oauth2 flow: implicit
	PASSWORD_FLOW    = "password"    // PASSWORD_FLOW oauth2 flow: password
	APPLICATION_FLOW = "application" // APPLICATION_FLOW oauth2 flow: application
	ACCESSCODE_FLOW  = "accessCode"  // ACCESSCODE_FLOW oauth2 flow: accessCode
)

oauth2 flow

View Source
const (
	INTEGER = "integer" // INTEGER type: integer, long
	NUMBER  = "number"  // NUMBER type: float, double
	STRING  = "string"  // STRING type: string, byte, binary, date, dateTime, password
	BOOLEAN = "boolean" // BOOLEAN type: boolean
	ARRAY   = "array"   // ARRAY type: array
	FILE    = "file"    // FILE type: file
	OBJECT  = "object"  // OBJECT type: object
)

type

View Source
const (
	INT32    = "int32"     // INT32 format: signed 32 bits
	INT64    = "int64"     // INT64 format: signed 64 bits
	FLOAT    = "float"     // FLOAT format: float
	DOUBLE   = "double"    // DOUBLE format: double
	BYTE     = "byte"      // BYTE format: base64 encoded characters
	BINARY   = "binary"    // BINARY format: any sequence of octets
	DATE     = "date"      // DATE format: As defined by full-date - RFC3339
	DATETIME = "date-time" // DATETIME format: As defined by date-time - RFC3339
	PASSWORD = "password"  // PASSWORD format: Used to hint UIs the input needs to be obscured
)

format

View Source
const (
	QUERY  = "query"    // QUERY param
	PATH   = "path"     // PATH param
	HEADER = "header"   // HEADER param
	BODY   = "body"     // BODY param
	FORM   = "formData" // FORM param
)

param

View Source
const (
	GET     = "get"     // GET method
	PUT     = "put"     // PUT method
	POST    = "post"    // POST method
	DELETE  = "delete"  // DELETE method
	OPTIONS = "options" // OPTIONS method
	HEAD    = "head"    // HEAD method
	PATCH   = "patch"   // PATCH method
)

method

View Source
const (
	ALL   = "*/*"                               // ALL mime data: */*
	JSON  = "application/json"                  // JSON mime data: application/json
	XML   = "application/xml"                   // XML mime data: application/xml
	PLAIN = "text/plain"                        // PLAIN mime data: text/plain
	HTML  = "text/html"                         // HTML mime data: text/html
	MPFD  = "multipart/form-data"               // MPFD mime data: multipart/form-data
	URL   = "application/x-www-form-urlencoded" // URL mime data: application/x-www-form-urlencoded
	PNG   = "image/png"                         // PNG mime data: image/png
	JPEG  = "image/jpeg"                        // JPEG mime data: image/jpeg
	GIF   = "image/gif"                         // GIF mime data: image/gif
)

mime

View Source
const (
	CSV   = "csv"   // CSV collection format: foo,bar
	SSV   = "ssv"   // SSV collection format: foo bar
	TSV   = "tsv"   // TSV collection format: foo\tbar
	PIPES = "pipes" // PIPES collection format: foo|bar
	MULTI = "multi" // MULTI collection format: foo=bar&foo=baz
)

collection format

Variables

This section is empty.

Functions

func DisableWarningLogger added in v1.3.0

func DisableWarningLogger()

DisableWarningLogger disables the warning logger switcher.

func EnableWarningLogger added in v1.3.0

func EnableWarningLogger()

EnableWarningLogger enables the warning logger switcher.

func GenerateApib

func GenerateApib() ([]byte, error)

GenerateApib generates apib script and returns byte array.

func GenerateSwaggerJson

func GenerateSwaggerJson() ([]byte, error)

GenerateSwaggerJson generates swagger json script and returns byte array.

func GenerateSwaggerYaml

func GenerateSwaggerYaml() ([]byte, error)

GenerateSwaggerYaml generates swagger yaml script and returns byte array.

func GetBasePath added in v1.3.0

func GetBasePath() string

GetBasePath returns the basePath from global Document.

func GetHost added in v1.3.0

func GetHost() string

GetHost returns the host from global Document.

func SaveApib added in v1.3.0

func SaveApib(path string) ([]byte, error)

SaveApib generates apib script and saves into file.

func SaveSwaggerJson added in v1.3.0

func SaveSwaggerJson(path string) ([]byte, error)

SaveSwaggerJson generates swagger json script and saves into file.

func SaveSwaggerYaml added in v1.3.0

func SaveSwaggerYaml(path string) ([]byte, error)

SaveSwaggerYaml generates swagger yaml script and saves into file.

Types

type Contact

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

Contact represents a contact information of Document.

func NewContact

func NewContact(name, url, email string) *Contact

NewContact creates a default Contact with given arguments.

func (*Contact) Email added in v1.3.0

func (c *Contact) Email(email string) *Contact

Email sets the email in Contact.

func (*Contact) GetEmail added in v1.3.0

func (c *Contact) GetEmail() string

GetEmail returns the email from Contact.

func (*Contact) GetName added in v1.3.0

func (c *Contact) GetName() string

GetName returns the name from Contact.

func (*Contact) GetUrl added in v1.3.0

func (c *Contact) GetUrl() string

GetUrl returns the url from Contact.

func (*Contact) Name added in v1.3.0

func (c *Contact) Name(name string) *Contact

Name sets the name in Contact.

func (*Contact) Url added in v1.3.0

func (c *Contact) Url(url string) *Contact

Url sets the url in Contact.

type Definition

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

Definition represents an api definition information of Document.

func GetDefinitions added in v1.3.0

func GetDefinitions() []*Definition

GetDefinitions returns the whole definitions from global Document.

func NewDefinition

func NewDefinition(name, desc string) *Definition

NewDefinition creates a default Definition with given arguments.

func (*Definition) AddProperties added in v1.3.0

func (d *Definition) AddProperties(properties ...*Property) *Definition

AddProperties add some properties into Definition.

func (*Definition) Desc added in v1.3.0

func (d *Definition) Desc(desc string) *Definition

Desc sets the desc in Definition.

func (*Definition) Generics

func (d *Definition) Generics(generics ...string) *Definition

Generics sets the whole generics in Definition.

func (*Definition) GetDesc added in v1.3.0

func (d *Definition) GetDesc() string

GetDesc returns the desc from Definition.

func (*Definition) GetGenerics added in v1.3.0

func (d *Definition) GetGenerics() []string

GetGenerics returns the whole generics from Definition.

func (*Definition) GetName added in v1.3.0

func (d *Definition) GetName() string

GetName returns the name from Definition.

func (*Definition) GetProperties added in v1.3.0

func (d *Definition) GetProperties() []*Property

GetProperties returns the whole properties from Definition.

func (*Definition) GetXMLRepr added in v1.3.0

func (d *Definition) GetXMLRepr() *XMLRepr

GetXMLRepr returns the xml repr from Definition.

func (*Definition) Name added in v1.3.0

func (d *Definition) Name(name string) *Definition

Name sets the name in Definition.

func (*Definition) Properties

func (d *Definition) Properties(properties ...*Property) *Definition

Properties sets the whole properties in Definition.

func (*Definition) XMLRepr added in v1.3.0

func (d *Definition) XMLRepr(repr *XMLRepr) *Definition

XMLRepr sets the xml repr in Definition, this is only supported in Swagger.

type Document

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

Document represents an api document information.

func AddDefinitions

func AddDefinitions(definitions ...*Definition) *Document

AddDefinitions adds some definitions into global Document.

func AddOperations added in v1.3.0

func AddOperations(operations ...*Operation) *Document

AddOperations adds some operations into global Document.

func CleanupDocument added in v1.3.0

func CleanupDocument() *Document

CleanupDocument cleans up the global Document.

func NewDocument added in v1.3.0

func NewDocument(host, basePath string, info *Info) *Document

NewDocument creates a default Document with given arguments.

func SetBasePath added in v1.3.0

func SetBasePath(basePath string) *Document

SetBasePath sets the basePath in global Document.

func SetDefinitions added in v1.3.0

func SetDefinitions(definitions ...*Definition) *Document

SetDefinitions sets the whole definitions in global Document.

func SetDocument

func SetDocument(host, basePath string, info *Info) *Document

SetDocument sets the basic information for global Document.

func SetHost added in v1.3.0

func SetHost(host string) *Document

SetHost sets the host in global Document.

func SetInfo added in v1.3.0

func SetInfo(info *Info) *Document

SetInfo sets the info in global Document.

func SetOperations added in v1.3.0

func SetOperations(operations ...*Operation) *Document

SetOperations sets the whole operations in global Document.

func SetOption added in v1.3.0

func SetOption(option *Option) *Document

SetOption sets the option in Document.

func (*Document) AddDefinitions

func (d *Document) AddDefinitions(definitions ...*Definition) *Document

AddDefinitions adds some definitions into Document.

func (*Document) AddOperations added in v1.3.0

func (d *Document) AddOperations(operations ...*Operation) *Document

AddOperations adds some operations into Document.

func (*Document) BasePath added in v1.3.0

func (d *Document) BasePath(basePath string) *Document

BasePath sets the basePath in Document.

func (*Document) Cleanup added in v1.3.0

func (d *Document) Cleanup() *Document

Cleanup cleans up the Document.

func (*Document) Definitions added in v1.3.0

func (d *Document) Definitions(definitions ...*Definition) *Document

Definitions sets the whole definitions in Document.

func (*Document) GenerateApib

func (d *Document) GenerateApib() ([]byte, error)

GenerateApib generates apib script and returns byte array.

func (*Document) GenerateSwaggerJson

func (d *Document) GenerateSwaggerJson() ([]byte, error)

GenerateSwaggerJson generates swagger json script and returns byte array.

func (*Document) GenerateSwaggerYaml

func (d *Document) GenerateSwaggerYaml() ([]byte, error)

GenerateSwaggerYaml generates swagger yaml script and returns byte array.

func (*Document) GetBasePath added in v1.3.0

func (d *Document) GetBasePath() string

GetBasePath returns the basePath from Document.

func (*Document) GetDefinitions added in v1.3.0

func (d *Document) GetDefinitions() []*Definition

GetDefinitions returns the whole definitions from Document.

func (*Document) GetHost added in v1.3.0

func (d *Document) GetHost() string

GetHost returns the host from Document.

func (*Document) GetInfo added in v1.3.0

func (d *Document) GetInfo() *Info

GetInfo returns the info from Document.

func (*Document) GetOperations added in v1.3.0

func (d *Document) GetOperations() []*Operation

GetOperations returns the whole operations from Document.

func (*Document) GetOption added in v1.3.0

func (d *Document) GetOption() *Option

GetOption returns the option from Document.

func (*Document) Host added in v1.3.0

func (d *Document) Host(host string) *Document

Host sets the host in Document.

func (*Document) Info added in v1.3.0

func (d *Document) Info(info *Info) *Document

Info sets the info in Document.

func (*Document) Operations added in v1.3.0

func (d *Document) Operations(operations ...*Operation) *Document

Operations sets the whole operations in Document.

func (*Document) Option added in v1.3.0

func (d *Document) Option(option *Option) *Document

Option sets the option in Document.

func (*Document) SaveApib added in v1.3.0

func (d *Document) SaveApib(path string) ([]byte, error)

SaveApib generates apib script and saves into file.

func (*Document) SaveSwaggerJson added in v1.3.0

func (d *Document) SaveSwaggerJson(path string) ([]byte, error)

SaveSwaggerJson generates swagger json script and saves into file.

func (*Document) SaveSwaggerYaml added in v1.3.0

func (d *Document) SaveSwaggerYaml(path string) ([]byte, error)

SaveSwaggerYaml generates swagger yaml script and saves into file.

type ExternalDoc added in v1.3.0

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

ExternalDoc represents an external documentation information of Document, Tag and Operation.

func NewExternalDoc added in v1.3.0

func NewExternalDoc(desc, url string) *ExternalDoc

NewExternalDoc creates a default ExternalDoc with given arguments.

func (*ExternalDoc) Desc added in v1.3.0

func (e *ExternalDoc) Desc(desc string) *ExternalDoc

Desc sets the desc in ExternalDoc.

func (*ExternalDoc) GetDesc added in v1.3.0

func (e *ExternalDoc) GetDesc() string

GetDesc returns the desc from ExternalDoc.

func (*ExternalDoc) GetUrl added in v1.3.0

func (e *ExternalDoc) GetUrl() string

GetUrl returns the url from ExternalDoc.

func (*ExternalDoc) Url added in v1.3.0

func (e *ExternalDoc) Url(url string) *ExternalDoc

Url sets the url in ExternalDoc.

type Info

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

Info represents a basic information of Document.

func GetInfo added in v1.3.0

func GetInfo() *Info

GetInfo returns the info from global Document.

func NewInfo

func NewInfo(title, desc, version string) *Info

NewInfo creates a default Info with given arguments.

func (*Info) Contact

func (i *Info) Contact(contact *Contact) *Info

Contact sets the contact in Info.

func (*Info) Desc added in v1.3.0

func (i *Info) Desc(desc string) *Info

Desc sets the desc in Info.

func (*Info) GetContact added in v1.3.0

func (i *Info) GetContact() *Contact

GetContact returns the contact from Info.

func (*Info) GetDesc added in v1.3.0

func (i *Info) GetDesc() string

GetDesc returns the desc from Info.

func (*Info) GetLicense added in v1.3.0

func (i *Info) GetLicense() *License

GetLicense returns the license from Info.

func (*Info) GetTermsOfService added in v1.3.0

func (i *Info) GetTermsOfService() string

GetTermsOfService returns the terms of service from Info.

func (*Info) GetTitle added in v1.3.0

func (i *Info) GetTitle() string

GetTitle returns the title from Info.

func (*Info) GetVersion added in v1.3.0

func (i *Info) GetVersion() string

GetVersion returns the version from Info.

func (*Info) License

func (i *Info) License(license *License) *Info

License sets the license in Info.

func (*Info) TermsOfService

func (i *Info) TermsOfService(terms string) *Info

TermsOfService sets the terms of service in Info.

func (*Info) Title added in v1.3.0

func (i *Info) Title(title string) *Info

Title sets the title in Info.

func (*Info) Version added in v1.3.0

func (i *Info) Version(version string) *Info

Version sets the version in Info.

type ItemOption added in v1.3.0

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

ItemOption represents an array type's item option of Param, Property and ItemOption itself, this is only supported in Swagger.

func NewItemOption added in v1.3.0

func NewItemOption() *ItemOption

NewItemOption creates a default ItemOption.

func (*ItemOption) AllowEmpty added in v1.3.0

func (o *ItemOption) AllowEmpty(allow bool) *ItemOption

AllowEmpty sets the allowEmpty in ItemOption.

func (*ItemOption) CollectionFormat added in v1.3.0

func (o *ItemOption) CollectionFormat(collectionFormat string) *ItemOption

CollectionFormat sets the collectionFormat in ItemOption.

func (*ItemOption) Default added in v1.3.0

func (o *ItemOption) Default(defaul interface{}) *ItemOption

Default sets the default in ItemOption.

func (*ItemOption) Enum added in v1.3.0

func (o *ItemOption) Enum(enums ...interface{}) *ItemOption

Enum sets the whole enums in ItemOption.

func (*ItemOption) Example added in v1.3.0

func (o *ItemOption) Example(example interface{}) *ItemOption

Example sets the example in ItemOption.

func (*ItemOption) ExclusiveMax added in v1.3.0

func (o *ItemOption) ExclusiveMax(exclusiveMax bool) *ItemOption

ExclusiveMax sets the exclusiveMax in ItemOption.

func (*ItemOption) ExclusiveMin added in v1.3.0

func (o *ItemOption) ExclusiveMin(exclusiveMin bool) *ItemOption

ExclusiveMin sets the exclusiveMin in ItemOption.

func (*ItemOption) GetAllowEmpty added in v1.3.0

func (o *ItemOption) GetAllowEmpty() bool

GetAllowEmpty returns the allowEmpty from ItemOption.

func (*ItemOption) GetCollectionFormat added in v1.3.0

func (o *ItemOption) GetCollectionFormat() string

GetCollectionFormat returns the collectionFormat from ItemOption.

func (*ItemOption) GetDefault added in v1.3.0

func (o *ItemOption) GetDefault() interface{}

GetDefault returns the default from ItemOption.

func (*ItemOption) GetEnum added in v1.3.0

func (o *ItemOption) GetEnum() []interface{}

GetEnum returns the enum from ItemOption.

func (*ItemOption) GetExample added in v1.3.0

func (o *ItemOption) GetExample() interface{}

GetExample returns the example from ItemOption.

func (*ItemOption) GetExclusiveMax added in v1.3.0

func (o *ItemOption) GetExclusiveMax() bool

GetExclusiveMax returns the exclusiveMax from ItemOption.

func (*ItemOption) GetExclusiveMin added in v1.3.0

func (o *ItemOption) GetExclusiveMin() bool

GetExclusiveMin returns the exclusiveMin from ItemOption.

func (*ItemOption) GetItemOption added in v1.3.0

func (o *ItemOption) GetItemOption() *ItemOption

GetItemOption returns the itemOption from ItemOption.

func (*ItemOption) GetMaxItems added in v1.3.0

func (o *ItemOption) GetMaxItems() *int

GetMaxItems returns the maxItems from ItemOption.

func (*ItemOption) GetMaxLength added in v1.3.0

func (o *ItemOption) GetMaxLength() *int

GetMaxLength returns the maxLength from ItemOption.

func (*ItemOption) GetMaximum added in v1.3.0

func (o *ItemOption) GetMaximum() *float64

GetMaximum returns the maximum from ItemOption.

func (*ItemOption) GetMinItems added in v1.3.0

func (o *ItemOption) GetMinItems() *int

GetMinItems returns the minItems from ItemOption.

func (*ItemOption) GetMinLength added in v1.3.0

func (o *ItemOption) GetMinLength() *int

GetMinLength returns the minLength from ItemOption.

func (*ItemOption) GetMinimum added in v1.3.0

func (o *ItemOption) GetMinimum() *float64

GetMinimum returns the minimum from ItemOption.

func (*ItemOption) GetMultipleOf added in v1.3.0

func (o *ItemOption) GetMultipleOf() float64

GetMultipleOf returns the multipleOf from ItemOption.

func (*ItemOption) GetPattern added in v1.3.0

func (o *ItemOption) GetPattern() string

GetPattern returns the pattern from ItemOption.

func (*ItemOption) GetUniqueItems added in v1.3.0

func (o *ItemOption) GetUniqueItems() bool

GetUniqueItems returns the uniqueItems from ItemOption.

func (*ItemOption) GetXMLRepr added in v1.3.0

func (o *ItemOption) GetXMLRepr() *XMLRepr

GetXMLRepr returns the xmlRepr from ItemOption.

func (*ItemOption) ItemOption added in v1.3.0

func (o *ItemOption) ItemOption(itemOption *ItemOption) *ItemOption

ItemOption sets the item option in ItemOption, this is only supported in Swagger.

func (*ItemOption) ItemsRange added in v1.3.0

func (o *ItemOption) ItemsRange(min, max int) *ItemOption

ItemsRange sets the minItems and maxItems in ItemOption.

func (*ItemOption) LengthRange added in v1.3.0

func (o *ItemOption) LengthRange(min, max int) *ItemOption

LengthRange sets the minLength and maxLength in ItemOption.

func (*ItemOption) MaxItems added in v1.3.0

func (o *ItemOption) MaxItems(max int) *ItemOption

MaxItems sets the maxItems in ItemOption.

func (*ItemOption) MaxLength added in v1.3.0

func (o *ItemOption) MaxLength(max int) *ItemOption

MaxLength sets the maxLength in ItemOption.

func (*ItemOption) Maximum added in v1.3.0

func (o *ItemOption) Maximum(max float64) *ItemOption

Maximum sets the maximum in ItemOption.

func (*ItemOption) MinItems added in v1.3.0

func (o *ItemOption) MinItems(min int) *ItemOption

MinItems sets the minItems in ItemOption.

func (*ItemOption) MinLength added in v1.3.0

func (o *ItemOption) MinLength(min int) *ItemOption

MinLength sets the minLength in ItemOption.

func (*ItemOption) Minimum added in v1.3.0

func (o *ItemOption) Minimum(min float64) *ItemOption

Minimum sets the minimum in ItemOption.

func (*ItemOption) MultipleOf added in v1.3.0

func (o *ItemOption) MultipleOf(multipleOf float64) *ItemOption

MultipleOf sets the multipleOf in ItemOption.

func (*ItemOption) Pattern added in v1.3.0

func (o *ItemOption) Pattern(pattern string) *ItemOption

Pattern sets the pattern in ItemOption.

func (*ItemOption) UniqueItems added in v1.3.0

func (o *ItemOption) UniqueItems(unique bool) *ItemOption

UniqueItems sets the uniqueItems in ItemOption.

func (*ItemOption) ValueRange added in v1.3.0

func (o *ItemOption) ValueRange(min, max float64) *ItemOption

ValueRange sets the minimum and maximum in ItemOption.

func (*ItemOption) XMLRepr added in v1.3.0

func (o *ItemOption) XMLRepr(repr *XMLRepr) *ItemOption

XMLRepr sets the xml repr in ItemOption, this is only supported in Swagger.

type License

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

License represents a license information of Document.

func NewLicense

func NewLicense(name, url string) *License

NewLicense creates a default License with given arguments.

func (*License) GetName added in v1.3.0

func (l *License) GetName() string

GetName returns the name from License.

func (*License) GetUrl added in v1.3.0

func (l *License) GetUrl() string

GetUrl returns the url from License.

func (*License) Name added in v1.3.0

func (l *License) Name(name string) *License

Name sets the name in License.

func (*License) Url added in v1.3.0

func (l *License) Url(url string) *License

Url sets the url in License.

type Operation added in v1.3.0

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

Operation represents an api operation information of Document.

func GetOperations added in v1.3.0

func GetOperations() []*Operation

GetOperations returns the whole operations from global Document.

func NewDeleteOperation added in v1.3.0

func NewDeleteOperation(route, summary string) *Operation

NewDeleteOperation creates a delete Operation with given arguments.

func NewGetOperation added in v1.3.0

func NewGetOperation(route, summary string) *Operation

NewGetOperation creates a get Operation with given arguments.

func NewHeadOperation added in v1.3.0

func NewHeadOperation(route, summary string) *Operation

NewHeadOperation creates a head Operation with given arguments.

func NewOperation added in v1.3.0

func NewOperation(method, route, summary string) *Operation

NewOperation creates a default Operation with given arguments.

func NewOptionsOperation added in v1.3.0

func NewOptionsOperation(route, summary string) *Operation

NewOptionsOperation creates an options Operation with given arguments.

func NewPatchOperation added in v1.3.0

func NewPatchOperation(route, summary string) *Operation

NewPatchOperation creates a patch Operation with given arguments.

func NewPostOperation added in v1.3.0

func NewPostOperation(route, summary string) *Operation

NewPostOperation creates a post Operation with given arguments.

func NewPutOperation added in v1.3.0

func NewPutOperation(route, summary string) *Operation

NewPutOperation creates a put Operation with given arguments.

func (*Operation) AddConsumes added in v1.3.0

func (o *Operation) AddConsumes(consumes ...string) *Operation

AddConsumes adds some consumes into Operation.

func (*Operation) AddParams added in v1.3.0

func (o *Operation) AddParams(params ...*Param) *Operation

AddParams adds some params into Operation.

func (*Operation) AddProduces added in v1.3.0

func (o *Operation) AddProduces(produces ...string) *Operation

AddProduces adds some produces into Operation.

func (*Operation) AddResponses added in v1.3.0

func (o *Operation) AddResponses(responses ...*Response) *Operation

AddResponses adds some responses into Operation.

func (*Operation) AddSchemes added in v1.3.0

func (o *Operation) AddSchemes(schemes ...string) *Operation

AddSchemes adds some schemes into Operation.

func (*Operation) AddSecurities added in v1.3.0

func (o *Operation) AddSecurities(securities ...string) *Operation

AddSecurities adds some security requirements into Operation.

func (*Operation) AddTags added in v1.3.0

func (o *Operation) AddTags(tags ...string) *Operation

AddTags adds some tags into Operation.

func (*Operation) AdditionalDoc added in v1.3.0

func (o *Operation) AdditionalDoc(doc string) *Operation

AdditionalDoc sets the additional document in Operation, this is only supported in API Blueprint.

func (*Operation) Consumes added in v1.3.0

func (o *Operation) Consumes(consumes ...string) *Operation

Consumes sets the whole consumes in Operation.

func (*Operation) Deprecated added in v1.3.0

func (o *Operation) Deprecated(deprecated bool) *Operation

Deprecated sets the deprecated in Operation.

func (*Operation) Desc added in v1.3.0

func (o *Operation) Desc(desc string) *Operation

Desc sets the desc in Operation.

func (*Operation) ExternalDoc added in v1.3.0

func (o *Operation) ExternalDoc(doc *ExternalDoc) *Operation

ExternalDoc sets the external documentation in Operation.

func (*Operation) GetAdditionalDoc added in v1.3.0

func (o *Operation) GetAdditionalDoc() string

GetAdditionalDoc returns the additional document from Operation.

func (*Operation) GetConsumes added in v1.3.0

func (o *Operation) GetConsumes() []string

GetConsumes returns the whole consumes from Operation.

func (*Operation) GetDeprecated added in v1.3.0

func (o *Operation) GetDeprecated() bool

GetDeprecated returns the deprecated from Operation.

func (*Operation) GetDesc added in v1.3.0

func (o *Operation) GetDesc() string

GetDesc returns the desc from Operation.

func (*Operation) GetExternalDoc added in v1.3.0

func (o *Operation) GetExternalDoc() *ExternalDoc

GetExternalDoc returns the external documentation from Operation.

func (*Operation) GetMethod added in v1.3.0

func (o *Operation) GetMethod() string

GetMethod returns the method from Operation.

func (*Operation) GetOperationId added in v1.3.0

func (o *Operation) GetOperationId() string

GetOperationId returns the operationId from Operation.

func (*Operation) GetParams added in v1.3.0

func (o *Operation) GetParams() []*Param

GetParams returns the whole params from Operation.

func (*Operation) GetProduces added in v1.3.0

func (o *Operation) GetProduces() []string

GetProduces returns the whole produces from Operation.

func (*Operation) GetRequestExample added in v1.3.0

func (o *Operation) GetRequestExample() interface{}

GetRequestExample returns the request example from Operation.

func (*Operation) GetResponses added in v1.3.0

func (o *Operation) GetResponses() []*Response

GetResponses returns the whole responses from Operation.

func (*Operation) GetRoute added in v1.3.0

func (o *Operation) GetRoute() string

GetRoute returns the route from Operation.

func (*Operation) GetSchemes added in v1.3.0

func (o *Operation) GetSchemes() []string

GetSchemes returns the whole schemes from Operation.

func (*Operation) GetSecurities added in v1.3.0

func (o *Operation) GetSecurities() []string

GetSecurities returns the whole securities requirements from Operation.

func (*Operation) GetSecuritiesScopes added in v1.3.0

func (o *Operation) GetSecuritiesScopes() map[string][]string

GetSecuritiesScopes returns the whole securities scopes from Operation.

func (*Operation) GetSummary added in v1.3.0

func (o *Operation) GetSummary() string

GetSummary returns the summary from Operation.

func (*Operation) GetTags added in v1.3.0

func (o *Operation) GetTags() []string

GetTags returns the whole tags from Operation.

func (*Operation) Method added in v1.3.0

func (o *Operation) Method(method string) *Operation

Method sets the method in Operation.

func (*Operation) OperationId added in v1.3.0

func (o *Operation) OperationId(operationId string) *Operation

OperationId sets the operationId in Operation.

func (*Operation) Params added in v1.3.0

func (o *Operation) Params(params ...*Param) *Operation

Params sets the whole params in Operation.

func (*Operation) Produces added in v1.3.0

func (o *Operation) Produces(produces ...string) *Operation

Produces sets the whole produces in Operation.

func (*Operation) RequestExample added in v1.3.0

func (o *Operation) RequestExample(reqExample interface{}) *Operation

RequestExample sets the request example in Operation, this is only supported in API Blueprint.

func (*Operation) Responses added in v1.3.0

func (o *Operation) Responses(responses ...*Response) *Operation

Responses sets the whole responses in Operation.

func (*Operation) Route added in v1.3.0

func (o *Operation) Route(route string) *Operation

Route sets the route in Operation.

func (*Operation) Schemes added in v1.3.0

func (o *Operation) Schemes(schemes ...string) *Operation

Schemes sets the whole schemes in Operation.

func (*Operation) Securities added in v1.3.0

func (o *Operation) Securities(securities ...string) *Operation

Securities sets the whole security requirements in Operation.

func (*Operation) SetSecurityScopes added in v1.3.0

func (o *Operation) SetSecurityScopes(security string, scopes ...string) *Operation

SetSecurityScopes sets a security's scopes in Operation.

func (*Operation) Summary added in v1.3.0

func (o *Operation) Summary(summary string) *Operation

Summary sets the summary in Operation.

func (*Operation) Tags added in v1.3.0

func (o *Operation) Tags(tags ...string) *Operation

Tags sets the whole tags in Operation.

type Option added in v1.3.0

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

Option represents an api extra option of Document.

func GetOption added in v1.3.0

func GetOption() *Option

GetOption returns the option from global Document.

func NewOption added in v1.3.0

func NewOption() *Option

NewOption creates a default Option.

func (*Option) AddConsumes added in v1.3.0

func (o *Option) AddConsumes(consumes ...string) *Option

AddConsumes adds some consumes into Option.

func (*Option) AddGlobalParams added in v1.3.1

func (o *Option) AddGlobalParams(globalParams ...*Param) *Option

AddGlobalParams adds some global params into Option.

func (*Option) AddProduces added in v1.3.0

func (o *Option) AddProduces(produces ...string) *Option

AddProduces adds some produces into Option.

func (*Option) AddRoutesOptions added in v1.3.0

func (o *Option) AddRoutesOptions(options ...*RoutesOption) *Option

AddRoutesOptions adds some routes group options in Option, this is only supported in API Blueprint.

func (*Option) AddSchemes added in v1.3.0

func (o *Option) AddSchemes(schemes ...string) *Option

AddSchemes adds some schemes into Option.

func (*Option) AddSecurities added in v1.3.0

func (o *Option) AddSecurities(securities ...*Security) *Option

AddSecurities adds some securities into Option.

func (*Option) AddTags added in v1.3.0

func (o *Option) AddTags(tags ...*Tag) *Option

AddTags adds some tags into Option.

func (*Option) AdditionalDoc added in v1.3.0

func (o *Option) AdditionalDoc(doc string) *Option

AdditionalDoc sets the additional document in Option, this is only supported in API Blueprint.

func (*Option) Consumes added in v1.3.0

func (o *Option) Consumes(consumes ...string) *Option

Consumes sets the whole consumes in Option.

func (*Option) ExternalDoc added in v1.3.0

func (o *Option) ExternalDoc(doc *ExternalDoc) *Option

ExternalDoc sets the external documentation in Option.

func (*Option) GetAdditionalDoc added in v1.3.0

func (o *Option) GetAdditionalDoc() string

GetAdditionalDoc returns the additional document from Option.

func (*Option) GetConsumes added in v1.3.0

func (o *Option) GetConsumes() []string

GetConsumes returns the whole consumes from Option.

func (*Option) GetExternalDoc added in v1.3.0

func (o *Option) GetExternalDoc() *ExternalDoc

GetExternalDoc returns the external documentation from Option.

func (*Option) GetGlobalParams added in v1.3.1

func (o *Option) GetGlobalParams() []*Param

GetGlobalParams returns the whole global params from Option.

func (*Option) GetProduces added in v1.3.0

func (o *Option) GetProduces() []string

GetProduces returns the whole produces from Option.

func (*Option) GetRoutesOptions added in v1.3.0

func (o *Option) GetRoutesOptions() []*RoutesOption

GetRoutesOptions returns the whole routes options from Option.

func (*Option) GetSchemes added in v1.3.0

func (o *Option) GetSchemes() []string

GetSchemes returns the whole schemes from Option.

func (*Option) GetSecurities added in v1.3.0

func (o *Option) GetSecurities() []*Security

GetSecurities returns the whole securities from Option.

func (*Option) GetTags added in v1.3.0

func (o *Option) GetTags() []*Tag

GetTags returns the whole tags from Option.

func (*Option) GlobalParams added in v1.3.1

func (o *Option) GlobalParams(globalParams ...*Param) *Option

GlobalParams sets the whole global params in Option.

func (*Option) Produces added in v1.3.0

func (o *Option) Produces(produces ...string) *Option

Produces sets the whole produces in Option.

func (*Option) RoutesOptions added in v1.3.0

func (o *Option) RoutesOptions(options ...*RoutesOption) *Option

RoutesOptions sets the whole routes group options in Option, this is only supported in API Blueprint.

func (*Option) Schemes added in v1.3.0

func (o *Option) Schemes(schemes ...string) *Option

Schemes sets the whole schemes in Option.

func (*Option) Securities added in v1.3.0

func (o *Option) Securities(securities ...*Security) *Option

Securities sets the whole securities in Option.

func (*Option) Tags added in v1.3.0

func (o *Option) Tags(tags ...*Tag) *Option

Tags sets the whole tags in Option.

type Param

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

Param represents a request parameter information of Operation.

func NewBodyParam

func NewBodyParam(name, typ string, required bool, desc string) *Param

NewBodyParam creates a body Param with given arguments.

func NewFormParam

func NewFormParam(name, typ string, required bool, desc string) *Param

NewFormParam creates a form Param with given arguments.

func NewHeaderParam

func NewHeaderParam(name, typ string, required bool, desc string) *Param

NewHeaderParam creates a header Param with given arguments.

func NewParam

func NewParam(name, in, typ string, required bool, desc string) *Param

NewParam creates a default Param with given arguments.

func NewPathParam

func NewPathParam(name, typ string, required bool, desc string) *Param

NewPathParam creates a path Param with given arguments.

func NewQueryParam

func NewQueryParam(name, typ string, required bool, desc string) *Param

NewQueryParam creates a query Param with given arguments.

func (*Param) AllowEmpty

func (p *Param) AllowEmpty(allow bool) *Param

AllowEmpty sets the allowEmpty in Param.

func (*Param) CollectionFormat added in v1.3.0

func (p *Param) CollectionFormat(collectionFormat string) *Param

CollectionFormat sets the collectionFormat in Param.

func (*Param) Default

func (p *Param) Default(defaul interface{}) *Param

Default sets the default in Param.

func (*Param) Desc added in v1.3.0

func (p *Param) Desc(desc string) *Param

Desc sets the desc in Param.

func (*Param) Enum

func (p *Param) Enum(enums ...interface{}) *Param

Enum sets the whole enums in Param.

func (*Param) Example

func (p *Param) Example(example interface{}) *Param

Example sets the example in Param.

func (*Param) ExclusiveMax added in v1.3.0

func (p *Param) ExclusiveMax(exclusiveMax bool) *Param

ExclusiveMax sets the exclusiveMax in Param.

func (*Param) ExclusiveMin added in v1.3.0

func (p *Param) ExclusiveMin(exclusiveMin bool) *Param

ExclusiveMin sets the exclusiveMin in Param.

func (*Param) GetAllowEmpty added in v1.3.0

func (p *Param) GetAllowEmpty() bool

GetAllowEmpty returns the allowEmpty from Param.

func (*Param) GetCollectionFormat added in v1.3.0

func (p *Param) GetCollectionFormat() string

GetCollectionFormat returns the collectionFormat from Param.

func (*Param) GetDefault added in v1.3.0

func (p *Param) GetDefault() interface{}

GetDefault returns the default from Param.

func (*Param) GetDesc added in v1.3.0

func (p *Param) GetDesc() string

GetDesc returns the desc from Param.

func (*Param) GetEnum added in v1.3.0

func (p *Param) GetEnum() []interface{}

GetEnum returns the whole enum from Param.

func (*Param) GetExample added in v1.3.0

func (p *Param) GetExample() interface{}

GetExample returns the example from Param.

func (*Param) GetExclusiveMax added in v1.3.0

func (p *Param) GetExclusiveMax() bool

GetExclusiveMax returns the exclusiveMax from Param.

func (*Param) GetExclusiveMin added in v1.3.0

func (p *Param) GetExclusiveMin() bool

GetExclusiveMin returns the exclusiveMin from Param.

func (*Param) GetInLoc added in v1.3.0

func (p *Param) GetInLoc() string

GetInLoc returns the in-location from Param.

func (*Param) GetItemOption added in v1.3.0

func (p *Param) GetItemOption() *ItemOption

GetItemOption returns the item option from Param.

func (*Param) GetMaxItems added in v1.3.0

func (p *Param) GetMaxItems() *int

GetMaxItems returns the maxItems from Param.

func (*Param) GetMaxLength added in v1.3.0

func (p *Param) GetMaxLength() *int

GetMaxLength returns the maxLength from Param.

func (*Param) GetMaximum added in v1.3.0

func (p *Param) GetMaximum() *float64

GetMaximum returns the maximum from Param.

func (*Param) GetMinItems added in v1.3.0

func (p *Param) GetMinItems() *int

GetMinItems returns the minItems from Param.

func (*Param) GetMinLength added in v1.3.0

func (p *Param) GetMinLength() *int

GetMinLength returns the minLength from Param.

func (*Param) GetMinimum added in v1.3.0

func (p *Param) GetMinimum() *float64

GetMinimum returns the minimum from Param.

func (*Param) GetMultipleOf added in v1.3.0

func (p *Param) GetMultipleOf() float64

GetMultipleOf returns the multipleOf from Param.

func (*Param) GetName added in v1.3.0

func (p *Param) GetName() string

GetName returns the name from Param.

func (*Param) GetPattern added in v1.3.0

func (p *Param) GetPattern() string

GetPattern returns the pattern from Param.

func (*Param) GetRequired added in v1.3.0

func (p *Param) GetRequired() bool

GetRequired returns the required from Param.

func (*Param) GetType added in v1.3.0

func (p *Param) GetType() string

GetType returns the type from Param.

func (*Param) GetUniqueItems added in v1.3.0

func (p *Param) GetUniqueItems() bool

GetUniqueItems returns the uniqueItems from Param.

func (*Param) GetXMLRepr added in v1.3.0

func (p *Param) GetXMLRepr() *XMLRepr

GetXMLRepr returns the xml repr from Param.

func (*Param) InLoc added in v1.3.0

func (p *Param) InLoc(in string) *Param

InLoc sets the in-location in Param.

func (*Param) ItemOption added in v1.3.0

func (p *Param) ItemOption(itemOption *ItemOption) *Param

ItemOption sets the item option in Param, this is only supported in Swagger.

func (*Param) ItemsRange added in v1.3.0

func (p *Param) ItemsRange(min, max int) *Param

ItemsRange sets the minItems and maxItems in Param.

func (*Param) LengthRange added in v1.3.0

func (p *Param) LengthRange(min, max int) *Param

LengthRange sets the minLength and maxLength in Param.

func (*Param) MaxItems added in v1.3.0

func (p *Param) MaxItems(max int) *Param

MaxItems sets the maxItems in Param.

func (*Param) MaxLength

func (p *Param) MaxLength(max int) *Param

MaxLength sets the maxLength in Param.

func (*Param) Maximum

func (p *Param) Maximum(max float64) *Param

Maximum sets the maximum in Param.

func (*Param) MinItems added in v1.3.0

func (p *Param) MinItems(min int) *Param

MinItems sets the minItems in Param.

func (*Param) MinLength

func (p *Param) MinLength(min int) *Param

MinLength sets the minLength in Param.

func (*Param) Minimum

func (p *Param) Minimum(min float64) *Param

Minimum sets the minimum in Param.

func (*Param) MultipleOf added in v1.3.0

func (p *Param) MultipleOf(multipleOf float64) *Param

MultipleOf sets the multipleOf in Param.

func (*Param) Name added in v1.3.0

func (p *Param) Name(name string) *Param

Name sets the name in Param.

func (*Param) Pattern added in v1.3.0

func (p *Param) Pattern(pattern string) *Param

Pattern sets the pattern in Param.

func (*Param) Required added in v1.3.0

func (p *Param) Required(required bool) *Param

Required sets the required in Param.

func (*Param) Type added in v1.3.0

func (p *Param) Type(typ string) *Param

Type sets the type in Param.

func (*Param) UniqueItems added in v1.3.0

func (p *Param) UniqueItems(unique bool) *Param

UniqueItems sets the uniqueItems in Param.

func (*Param) ValueRange added in v1.3.0

func (p *Param) ValueRange(min, max float64) *Param

ValueRange sets the minimum and maximum in Param.

func (*Param) XMLRepr added in v1.3.0

func (p *Param) XMLRepr(repr *XMLRepr) *Param

XMLRepr sets the xml repr in Param, this is only supported in Swagger.

type Property

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

Property represents a definition property information of Definition.

func NewProperty

func NewProperty(name, typ string, required bool, desc string) *Property

NewProperty creates a default Property with given arguments.

func (*Property) AllowEmpty

func (p *Property) AllowEmpty(allow bool) *Property

AllowEmpty sets the allowEmpty in Property.

func (*Property) CollectionFormat added in v1.3.0

func (p *Property) CollectionFormat(collectionFormat string) *Property

CollectionFormat sets the collectionFormat in Property.

func (*Property) Default

func (p *Property) Default(defaul interface{}) *Property

Default sets the default in Property.

func (*Property) Desc added in v1.3.0

func (p *Property) Desc(desc string) *Property

Desc sets the desc in Property.

func (*Property) Enum

func (p *Property) Enum(enums ...interface{}) *Property

Enum sets the whole enums in Property.

func (*Property) Example

func (p *Property) Example(example interface{}) *Property

Example sets the example in Property.

func (*Property) ExclusiveMax added in v1.3.0

func (p *Property) ExclusiveMax(exclusiveMax bool) *Property

ExclusiveMax sets the exclusiveMax in Property.

func (*Property) ExclusiveMin added in v1.3.0

func (p *Property) ExclusiveMin(exclusiveMin bool) *Property

ExclusiveMin sets the exclusiveMin in Property.

func (*Property) GetAllowEmpty added in v1.3.0

func (p *Property) GetAllowEmpty() bool

GetAllowEmpty returns the allowEmpty from Property.

func (*Property) GetCollectionFormat added in v1.3.0

func (p *Property) GetCollectionFormat() string

GetCollectionFormat returns the collectionFormat from Property.

func (*Property) GetDefault added in v1.3.0

func (p *Property) GetDefault() interface{}

GetDefault returns the default from Property.

func (*Property) GetDesc added in v1.3.0

func (p *Property) GetDesc() string

GetDesc returns the desc from Property.

func (*Property) GetEnum added in v1.3.0

func (p *Property) GetEnum() []interface{}

GetEnum returns the enum from Property.

func (*Property) GetExample added in v1.3.0

func (p *Property) GetExample() interface{}

GetExample returns the example from Property.

func (*Property) GetExclusiveMax added in v1.3.0

func (p *Property) GetExclusiveMax() bool

GetExclusiveMax returns the exclusiveMax from Property.

func (*Property) GetExclusiveMin added in v1.3.0

func (p *Property) GetExclusiveMin() bool

GetExclusiveMin returns the exclusiveMin from Property.

func (*Property) GetItemOption added in v1.3.0

func (p *Property) GetItemOption() *ItemOption

GetItemOption returns the item option from Property.

func (*Property) GetMaxItems added in v1.3.0

func (p *Property) GetMaxItems() *int

GetMaxItems returns the maxItems from Property.

func (*Property) GetMaxLength added in v1.3.0

func (p *Property) GetMaxLength() *int

GetMaxLength returns the maxLength from Property.

func (*Property) GetMaximum added in v1.3.0

func (p *Property) GetMaximum() *float64

GetMaximum returns the maximum from Property.

func (*Property) GetMinItems added in v1.3.0

func (p *Property) GetMinItems() *int

GetMinItems returns the minItems from Property.

func (*Property) GetMinLength added in v1.3.0

func (p *Property) GetMinLength() *int

GetMinLength returns the minLength from Property.

func (*Property) GetMinimum added in v1.3.0

func (p *Property) GetMinimum() *float64

GetMinimum returns the minimum from Property.

func (*Property) GetMultipleOf added in v1.3.0

func (p *Property) GetMultipleOf() float64

GetMultipleOf returns the multipleOf from Property.

func (*Property) GetName added in v1.3.0

func (p *Property) GetName() string

GetName returns the name from Property.

func (*Property) GetPattern added in v1.3.0

func (p *Property) GetPattern() string

GetPattern returns the pattern from Property.

func (*Property) GetRequired added in v1.3.0

func (p *Property) GetRequired() bool

GetRequired returns the required from Property.

func (*Property) GetType added in v1.3.0

func (p *Property) GetType() string

GetType returns the type from Property.

func (*Property) GetUniqueItems added in v1.3.0

func (p *Property) GetUniqueItems() bool

GetUniqueItems returns the uniqueItems from Property.

func (*Property) GetXMLRepr added in v1.3.0

func (p *Property) GetXMLRepr() *XMLRepr

GetXMLRepr returns the xml repr from Property.

func (*Property) ItemOption added in v1.3.0

func (p *Property) ItemOption(itemOption *ItemOption) *Property

ItemOption sets the item option in Property, this is only supported in Swagger.

func (*Property) ItemsRange added in v1.3.0

func (p *Property) ItemsRange(min, max int) *Property

ItemsRange sets the minItems and maxItems in Property.

func (*Property) LengthRange added in v1.3.0

func (p *Property) LengthRange(min, max int) *Property

LengthRange sets the minLength and maxLength in Property.

func (*Property) MaxItems added in v1.3.0

func (p *Property) MaxItems(max int) *Property

MaxItems sets the maxItems in Property.

func (*Property) MaxLength

func (p *Property) MaxLength(max int) *Property

MaxLength sets the maxLength in Property.

func (*Property) Maximum

func (p *Property) Maximum(max float64) *Property

Maximum sets the maximum in Property.

func (*Property) MinItems added in v1.3.0

func (p *Property) MinItems(min int) *Property

MinItems sets the minItems in Property.

func (*Property) MinLength

func (p *Property) MinLength(min int) *Property

MinLength sets the minLength in Property.

func (*Property) Minimum

func (p *Property) Minimum(min float64) *Property

Minimum sets the minimum in Property.

func (*Property) MultipleOf added in v1.3.0

func (p *Property) MultipleOf(multipleOf float64) *Property

MultipleOf sets the multipleOf in Property.

func (*Property) Name added in v1.3.0

func (p *Property) Name(name string) *Property

Name sets the name in Property.

func (*Property) Pattern added in v1.3.0

func (p *Property) Pattern(pattern string) *Property

Pattern sets the pattern in Property.

func (*Property) Required added in v1.3.0

func (p *Property) Required(required bool) *Property

Required sets the required in Property.

func (*Property) Type added in v1.3.0

func (p *Property) Type(typ string) *Property

Type sets the type in Property.

func (*Property) UniqueItems added in v1.3.0

func (p *Property) UniqueItems(unique bool) *Property

UniqueItems sets the uniqueItems in Property.

func (*Property) ValueRange added in v1.3.0

func (p *Property) ValueRange(min, max float64) *Property

ValueRange sets the minimum and maximum in Property.

func (*Property) XMLRepr added in v1.3.0

func (p *Property) XMLRepr(repr *XMLRepr) *Property

XMLRepr sets the xml repr in Property, this is only supported in Swagger.

type Response

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

Response represents an operation response information of Operation.

func NewResponse

func NewResponse(code int, typ string) *Response

NewResponse creates a default Response with given arguments.

func (*Response) AddExamples added in v1.3.0

func (r *Response) AddExamples(examples ...*ResponseExample) *Response

AddExamples add some response examples into Response.

func (*Response) AddHeaders added in v1.3.0

func (r *Response) AddHeaders(headers ...*ResponseHeader) *Response

AddHeaders add some response headers in Response.

func (*Response) AdditionalDoc added in v1.3.0

func (r *Response) AdditionalDoc(doc string) *Response

AdditionalDoc sets the additional document in Response, this is only supported in API Blueprint.

func (*Response) Code added in v1.3.0

func (r *Response) Code(code int) *Response

Code sets the code in Response.

func (*Response) Desc

func (r *Response) Desc(desc string) *Response

Desc sets the desc in Response.

func (*Response) Examples

func (r *Response) Examples(examples ...*ResponseExample) *Response

Examples sets the whole response examples in Response.

func (*Response) GetAdditionalDoc added in v1.3.0

func (r *Response) GetAdditionalDoc() string

GetAdditionalDoc returns the additional document from Response

func (*Response) GetCode added in v1.3.0

func (r *Response) GetCode() int

GetCode returns the code from Response

func (*Response) GetDesc added in v1.3.0

func (r *Response) GetDesc() string

GetDesc returns the desc from Response

func (*Response) GetExamples added in v1.3.0

func (r *Response) GetExamples() []*ResponseExample

GetExamples returns the whole response examples from Response

func (*Response) GetHeaders added in v1.3.0

func (r *Response) GetHeaders() []*ResponseHeader

GetHeaders returns the whole response headers from Response

func (*Response) GetType added in v1.3.0

func (r *Response) GetType() string

GetType returns the type from Response

func (*Response) Headers

func (r *Response) Headers(headers ...*ResponseHeader) *Response

Headers sets the whole response headers in Response.

func (*Response) Type added in v1.3.0

func (r *Response) Type(typ string) *Response

Type sets the type in Response.

type ResponseExample added in v1.3.0

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

ResponseExample represents a response example information of Response.

func NewResponseExample added in v1.3.0

func NewResponseExample(mime string, example interface{}) *ResponseExample

NewResponseExample creates a default ResponseExample with given arguments.

func (*ResponseExample) Example added in v1.3.0

func (r *ResponseExample) Example(example interface{}) *ResponseExample

Example sets the example in ResponseExample.

func (*ResponseExample) GetExample added in v1.3.0

func (r *ResponseExample) GetExample() interface{}

GetExample returns the example from ResponseExample.

func (*ResponseExample) GetMime added in v1.3.0

func (r *ResponseExample) GetMime() string

GetMime returns the mime from ResponseExample.

func (*ResponseExample) Mime added in v1.3.0

func (r *ResponseExample) Mime(mime string) *ResponseExample

Mime sets the mime in ResponseExample.

type ResponseHeader added in v1.3.0

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

ResponseHeader represents a response header information of Response.

func NewResponseHeader added in v1.3.0

func NewResponseHeader(name, typ, desc string) *ResponseHeader

NewResponseHeader creates a default Header with given arguments.

func (*ResponseHeader) Desc added in v1.3.0

func (h *ResponseHeader) Desc(desc string) *ResponseHeader

Desc sets the desc in ResponseHeader.

func (*ResponseHeader) Example added in v1.3.0

func (h *ResponseHeader) Example(example interface{}) *ResponseHeader

Example sets the example in ResponseHeader.

func (*ResponseHeader) GetDesc added in v1.3.0

func (h *ResponseHeader) GetDesc() string

GetDesc returns the desc from ResponseHeader.

func (*ResponseHeader) GetExample added in v1.3.0

func (h *ResponseHeader) GetExample() interface{}

GetExample returns the example from ResponseHeader.

func (*ResponseHeader) GetName added in v1.3.0

func (h *ResponseHeader) GetName() string

GetName returns the name from ResponseHeader.

func (*ResponseHeader) GetType added in v1.3.0

func (h *ResponseHeader) GetType() string

GetType returns the type from ResponseHeader.

func (*ResponseHeader) Name added in v1.3.0

func (h *ResponseHeader) Name(name string) *ResponseHeader

Name sets the name in ResponseHeader.

func (*ResponseHeader) Type added in v1.3.0

func (h *ResponseHeader) Type(typ string) *ResponseHeader

Type sets the type in ResponseHeader.

type RoutesOption added in v1.3.0

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

RoutesOption represents a routes group option of Document, this is only supported in API Blueprint.

func NewRoutesOption added in v1.3.0

func NewRoutesOption(route string) *RoutesOption

NewRoutesOption creates a default RoutesOption with given arguments.

func (*RoutesOption) AdditionalDoc added in v1.3.0

func (r *RoutesOption) AdditionalDoc(additionalDoc string) *RoutesOption

AdditionalDoc sets the additional document in RoutesOption, this is only supported in API Blueprint.

func (*RoutesOption) GetAdditionalDoc added in v1.3.0

func (r *RoutesOption) GetAdditionalDoc() string

GetAdditionalDoc returns the additional document from RoutesOption.

func (*RoutesOption) GetRoute added in v1.3.0

func (r *RoutesOption) GetRoute() string

GetRoute returns the route from RoutesOption.

func (*RoutesOption) GetSummary added in v1.3.0

func (r *RoutesOption) GetSummary() string

GetSummary returns the summary from RoutesOption.

func (*RoutesOption) Route added in v1.3.0

func (r *RoutesOption) Route(route string) *RoutesOption

Route sets the route in RoutesOption.

func (*RoutesOption) Summary added in v1.3.0

func (r *RoutesOption) Summary(summary string) *RoutesOption

Summary sets the summary in RoutesOption.

type Security

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

Security represents a security definition information of Document.

func NewApiKeySecurity added in v1.3.0

func NewApiKeySecurity(title, in, name string) *Security

NewApiKeySecurity creates an apiKey authentication Security with given arguments.

func NewBasicSecurity added in v1.3.0

func NewBasicSecurity(title string) *Security

NewBasicSecurity creates a basic authentication Security with given arguments.

func NewOAuth2Security added in v1.3.0

func NewOAuth2Security(title string, flow string) *Security

NewOAuth2Security creates an oauth2 authentication Security with given arguments.

func NewSecurity

func NewSecurity(title string, typ string) *Security

NewSecurity creates a default Security with given arguments.

func (*Security) AddScopes added in v1.3.0

func (s *Security) AddScopes(scopes ...*SecurityScope) *Security

AddScopes add some security scopes into Security.

func (*Security) AuthorizationUrl added in v1.3.0

func (s *Security) AuthorizationUrl(authorizationUrl string) *Security

AuthorizationUrl sets the authorization url in Security.

func (*Security) Desc added in v1.3.0

func (s *Security) Desc(desc string) *Security

Desc sets the desc in Security.

func (*Security) Flow added in v1.3.0

func (s *Security) Flow(flow string) *Security

Flow sets the flow in Security.

func (*Security) GetAuthorizationUrl added in v1.3.0

func (s *Security) GetAuthorizationUrl() string

GetAuthorizationUrl returns the authorization url from Security.

func (*Security) GetDesc added in v1.3.0

func (s *Security) GetDesc() string

GetDesc returns the desc from Security.

func (*Security) GetFlow added in v1.3.0

func (s *Security) GetFlow() string

GetFlow returns the flow from Security.

func (*Security) GetInLoc added in v1.3.0

func (s *Security) GetInLoc() string

GetInLoc returns the in-location from Security.

func (*Security) GetName added in v1.3.0

func (s *Security) GetName() string

GetName returns the name from Security.

func (*Security) GetScopes added in v1.3.0

func (s *Security) GetScopes() []*SecurityScope

GetScopes returns the whole security scopes from Security.

func (*Security) GetTitle added in v1.3.0

func (s *Security) GetTitle() string

GetTitle returns the title from Security.

func (*Security) GetTokenUrl added in v1.3.0

func (s *Security) GetTokenUrl() string

GetTokenUrl returns the token url from Security.

func (*Security) GetType added in v1.3.0

func (s *Security) GetType() string

GetType returns the authentication type from Security.

func (*Security) InLoc added in v1.3.0

func (s *Security) InLoc(in string) *Security

InLoc sets the in-location in Security.

func (*Security) Name added in v1.3.0

func (s *Security) Name(name string) *Security

Name sets the name in Security.

func (*Security) Scopes added in v1.3.0

func (s *Security) Scopes(scopes ...*SecurityScope) *Security

Scopes sets the whole security scopes in Security.

func (*Security) Title added in v1.3.0

func (s *Security) Title(title string) *Security

Title sets the title in Security.

func (*Security) TokenUrl added in v1.3.0

func (s *Security) TokenUrl(tokenUrl string) *Security

TokenUrl sets the token url in Security.

func (*Security) Type added in v1.3.0

func (s *Security) Type(typ string) *Security

Type sets the authentication type in Security.

type SecurityScope added in v1.3.0

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

SecurityScope represents a security scope information of Document.

func NewSecurityScope added in v1.3.0

func NewSecurityScope(scope, desc string) *SecurityScope

NewSecurityScope creates a default SecurityScope with given arguments.

func (*SecurityScope) Desc added in v1.3.0

func (s *SecurityScope) Desc(desc string) *SecurityScope

Desc sets the desc in Security.

func (*SecurityScope) GetDesc added in v1.3.0

func (s *SecurityScope) GetDesc() string

GetDesc returns the desc from SecurityScope.

func (*SecurityScope) GetScope added in v1.3.0

func (s *SecurityScope) GetScope() string

GetScope returns the scope from SecurityScope.

func (*SecurityScope) Scope added in v1.3.0

func (s *SecurityScope) Scope(scope string) *SecurityScope

Scope sets the scope in Security.

type Tag

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

Tag represents a tag information of Document.

func NewTag

func NewTag(name, desc string) *Tag

NewTag creates a default Tag with given arguments.

func (*Tag) AdditionalDoc added in v1.3.0

func (t *Tag) AdditionalDoc(doc string) *Tag

AdditionalDoc sets the additional document in Tag, this is only supported in API Blueprint.

func (*Tag) Desc added in v1.3.0

func (t *Tag) Desc(desc string) *Tag

Desc sets the desc in Tag.

func (*Tag) ExternalDoc added in v1.3.0

func (t *Tag) ExternalDoc(doc *ExternalDoc) *Tag

ExternalDoc sets the external documentation in Tag.

func (*Tag) GetAdditionalDoc added in v1.3.0

func (t *Tag) GetAdditionalDoc() string

GetAdditionalDoc returns the additional document from Tag.

func (*Tag) GetDesc added in v1.3.0

func (t *Tag) GetDesc() string

GetDesc returns the desc from Tag.

func (*Tag) GetExternalDoc added in v1.3.0

func (t *Tag) GetExternalDoc() *ExternalDoc

GetExternalDoc returns the external documentation from Tag.

func (*Tag) GetName added in v1.3.0

func (t *Tag) GetName() string

GetName returns the name from Tag.

func (*Tag) Name added in v1.3.0

func (t *Tag) Name(name string) *Tag

Name sets the name in Tag.

type XMLRepr added in v1.3.0

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

XMLRepr represents a xml representation format information of Definition, Property, Param an ItemOption, this is only supported in Swagger.

func NewXMLRepr added in v1.3.0

func NewXMLRepr(name string) *XMLRepr

NewXMLRepr creates a default XMLRepr with given arguments.

func (*XMLRepr) Attribute added in v1.3.0

func (x *XMLRepr) Attribute(attribute bool) *XMLRepr

Attribute sets the attribute in XMLRepr.

func (*XMLRepr) GetAttribute added in v1.3.0

func (x *XMLRepr) GetAttribute() bool

GetAttribute returns the attribute from XMLRepr.

func (*XMLRepr) GetName added in v1.3.0

func (x *XMLRepr) GetName() string

GetName returns the name from XMLRepr.

func (*XMLRepr) GetNamespace added in v1.3.0

func (x *XMLRepr) GetNamespace() string

GetNamespace returns the namespace from XMLRepr.

func (*XMLRepr) GetPrefix added in v1.3.0

func (x *XMLRepr) GetPrefix() string

GetPrefix returns the prefix from XMLRepr.

func (*XMLRepr) GetWrapped added in v1.3.0

func (x *XMLRepr) GetWrapped() bool

GetWrapped returns the wrapped from XMLRepr.

func (*XMLRepr) Name added in v1.3.0

func (x *XMLRepr) Name(name string) *XMLRepr

Name sets the name in XMLRepr.

func (*XMLRepr) Namespace added in v1.3.0

func (x *XMLRepr) Namespace(namespace string) *XMLRepr

Namespace sets the namespace in XMLRepr.

func (*XMLRepr) Prefix added in v1.3.0

func (x *XMLRepr) Prefix(prefix string) *XMLRepr

Prefix sets the prefix in XMLRepr.

func (*XMLRepr) Wrapped added in v1.3.0

func (x *XMLRepr) Wrapped(wrapped bool) *XMLRepr

Wrapped sets the wrapped in XMLRepr.

Jump to

Keyboard shortcuts

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