SpringSwagger

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

README

spring-swag

[仅发布] 该项目仅为最终发布,开发请关注 go-spring 项目。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyParam

func BodyParam(name string, schema *spec.Schema) *spec.Parameter

BodyParam creates a body parameter

func HeaderParam

func HeaderParam(name string, typ, format string) *spec.Parameter

HeaderParam creates a header parameter, this is always required by default

func NewBindResponse

func NewBindResponse(i interface{}, description string) *spec.Response

NewBindResponse creates a new response instance

func NewResponse

func NewResponse(description string) *spec.Response

NewResponse creates a new response instance

func PathParam

func PathParam(name string, typ, format string) *spec.Parameter

PathParam creates a path parameter, this is always required

Types

type DefinitionField

type DefinitionField struct {
	Description string
	Example     interface{}
	Enums       []interface{}
}

type Operation

type Operation struct {
	*spec.Operation
	// contains filtered or unexported fields
}

Operation 封装 *spec.Operation 对象,提供更多功能

func NewOperation

func NewOperation(id string) *Operation

NewOperation creates a new operation instance.

func (*Operation) AddParam

func (o *Operation) AddParam(param *spec.Parameter) *Operation

AddParam adds a parameter to this operation

func (*Operation) BindParam

func (o *Operation) BindParam(i interface{}, description string) *Operation

Bind 绑定请求参数

func (*Operation) Deprecate

func (o *Operation) Deprecate() *Operation

Deprecate marks the operation as deprecated

func (*Operation) Process

func (o *Operation) Process() error

Process 解析绑定的请求参数

func (*Operation) RemoveParam

func (o *Operation) RemoveParam(name, in string) *Operation

RemoveParam removes a parameter from the operation

func (*Operation) RespondsWith

func (o *Operation) RespondsWith(code int, response *spec.Response) *Operation

RespondsWith adds a status code response to the operation.

func (*Operation) SecuredWith

func (o *Operation) SecuredWith(name string, scopes ...string) *Operation

SecuredWith adds a security scope to this operation.

func (*Operation) Undeprecate

func (o *Operation) Undeprecate() *Operation

Undeprecate marks the operation as not deprecated

func (*Operation) WithConsumes

func (o *Operation) WithConsumes(mediaTypes ...string) *Operation

WithConsumes adds media types for incoming body values

func (*Operation) WithDefaultResponse

func (o *Operation) WithDefaultResponse(response *spec.Response) *Operation

WithDefaultResponse adds a default response to the operation.

func (*Operation) WithDescription

func (o *Operation) WithDescription(description string) *Operation

WithDescription sets the description on this operation, allows for chaining

func (*Operation) WithExternalDocs

func (o *Operation) WithExternalDocs(description, url string) *Operation

WithExternalDocs sets/removes the external docs for/from this operation.

func (*Operation) WithID

func (o *Operation) WithID(id string) *Operation

WithID sets the ID property on this operation, allows for chaining.

func (*Operation) WithProduces

func (o *Operation) WithProduces(mediaTypes ...string) *Operation

WithProduces adds media types for outgoing body values

func (*Operation) WithSchemes

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

SetSchemes 设置服务协议

func (*Operation) WithSummary

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

WithSummary sets the summary on this operation, allows for chaining

func (*Operation) WithTags

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

WithTags adds tags for this operation

type Swagger

type Swagger struct {
	spec.Swagger
}

Swagger 封装 spec.Swagger 对象,提供流式调用

func NewSwagger

func NewSwagger() *Swagger

NewSwagger swagger 的构造函数

func (*Swagger) AddApiKeySecurityDefinition

func (s *Swagger) AddApiKeySecurityDefinition(name string, in string) *Swagger

AddApiKeySecurityDefinition 添加 ApiKey 方式认证

func (*Swagger) AddBasicSecurityDefinition

func (s *Swagger) AddBasicSecurityDefinition() *Swagger

AddBasicSecurityDefinition 添加 Basic 方式认证

func (*Swagger) AddDefinition

func (s *Swagger) AddDefinition(name string, schema *spec.Schema) *Swagger

AddDefinition 添加一个定义

func (*Swagger) AddOauth2AccessCodeSecurityDefinition

func (s *Swagger) AddOauth2AccessCodeSecurityDefinition(name string, authorizationUrl string, tokenUrl string, scopes map[string]string) *Swagger

AddOauth2AccessCodeSecurityDefinition 添加 OAuth2 AccessCode 方式认证

func (*Swagger) AddOauth2ApplicationSecurityDefinition

func (s *Swagger) AddOauth2ApplicationSecurityDefinition(name string, tokenUrl string, scopes map[string]string) *Swagger

AddOauth2ApplicationSecurityDefinition 添加 OAuth2 Application 方式认证

func (*Swagger) AddOauth2ImplicitSecurityDefinition

func (s *Swagger) AddOauth2ImplicitSecurityDefinition(name string, authorizationUrl string, scopes map[string]string) *Swagger

AddOauth2ImplicitSecurityDefinition 添加 OAuth2 Implicit 方式认证

func (*Swagger) AddOauth2PasswordSecurityDefinition

func (s *Swagger) AddOauth2PasswordSecurityDefinition(name string, tokenUrl string, scopes map[string]string) *Swagger

AddOauth2PasswordSecurityDefinition 添加 OAuth2 Password 方式认证

func (*Swagger) AddPath

func (s *Swagger) AddPath(path string, method string, op web.Operation)

AddPath 添加一个路由

func (*Swagger) BindDefinitionWithTags

func (s *Swagger) BindDefinitionWithTags(i interface{}, attachFields map[string]DefinitionField) *Swagger

BindDefinitionWithTags 绑定一个定义

func (*Swagger) BindDefinitions

func (s *Swagger) BindDefinitions(i ...interface{}) *Swagger

BindDefinitions 绑定一个定义

func (*Swagger) ReadDoc

func (s *Swagger) ReadDoc() string

ReadDoc 获取应用的 Swagger 描述内容

func (*Swagger) WithBasePath

func (s *Swagger) WithBasePath(basePath string) *Swagger

WithBasePath 设置 API 路径的前缀

func (*Swagger) WithConsumes

func (s *Swagger) WithConsumes(consumes ...string) *Swagger

WithConsumes 设置消费协议

func (*Swagger) WithContact

func (s *Swagger) WithContact(name string, url string, email string) *Swagger

WithContact 设置作者的名字、主页地址、邮箱

func (*Swagger) WithDescription

func (s *Swagger) WithDescription(description string) *Swagger

WithDescription 设置服务描述

func (*Swagger) WithExternalDocs

func (s *Swagger) WithExternalDocs(externalDocs *spec.ExternalDocumentation) *Swagger

WithExternalDocs

func (*Swagger) WithHost

func (s *Swagger) WithHost(host string) *Swagger

WithHost 设置可用服务器地址

func (*Swagger) WithID

func (s *Swagger) WithID(id string) *Swagger

WithID 设置应用 ID

func (*Swagger) WithLicense

func (s *Swagger) WithLicense(name string, url string) *Swagger

WithLicense 设置开源协议的名称、地址

func (*Swagger) WithProduces

func (s *Swagger) WithProduces(produces ...string) *Swagger

WithProduces 设置生产协议

func (*Swagger) WithSchemes

func (s *Swagger) WithSchemes(schemes ...string) *Swagger

WithSchemes 设置服务协议

func (*Swagger) WithTags

func (s *Swagger) WithTags(tags ...spec.Tag) *Swagger

WithTags 添加标签

func (*Swagger) WithTermsOfService

func (s *Swagger) WithTermsOfService(termsOfService string) *Swagger

WithTermsOfService 设置服务条款地址

func (*Swagger) WithTitle

func (s *Swagger) WithTitle(title string) *Swagger

WithTitle 设置服务名称

func (*Swagger) WithVersion

func (s *Swagger) WithVersion(version string) *Swagger

WithVersion 设置 API 版本号

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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