当前位置: 首页>>代码示例>>Golang>>正文


Golang spec.Swagger类代码示例

本文整理汇总了Golang中github.com/casualjim/go-swagger/spec.Swagger的典型用法代码示例。如果您正苦于以下问题:Golang Swagger类的具体用法?Golang Swagger怎么用?Golang Swagger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Swagger类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: newMetaParser

func newMetaParser(swspec *spec.Swagger) *sectionedParser {
	sp := new(sectionedParser)
	if swspec.Info == nil {
		swspec.Info = new(spec.Info)
	}
	info := swspec.Info
	sp.setTitle = func(lines []string) {
		tosave := joinDropLast(lines)
		if len(tosave) > 0 {
			tosave = rxStripTitleComments.ReplaceAllString(tosave, "")
		}
		info.Title = tosave
	}
	sp.setDescription = func(lines []string) { info.Description = joinDropLast(lines) }
	sp.taggers = []tagParser{
		newMultiLineTagParser("TOS", newMultilineDropEmptyParser(rxTOS, metaTOSSetter(info))),
		newMultiLineTagParser("Consumes", newMultilineDropEmptyParser(rxConsumes, metaConsumesSetter(swspec))),
		newMultiLineTagParser("Produces", newMultilineDropEmptyParser(rxProduces, metaProducesSetter(swspec))),
		newSingleLineTagParser("Schemes", newSetSchemes(metaSchemeSetter(swspec))),
		newSingleLineTagParser("Version", &setMetaSingle{swspec, rxVersion, setInfoVersion}),
		newSingleLineTagParser("Host", &setMetaSingle{swspec, rxHost, setSwaggerHost}),
		newSingleLineTagParser("BasePath", &setMetaSingle{swspec, rxBasePath, setSwaggerBasePath}),
		newSingleLineTagParser("Contact", &setMetaSingle{swspec, rxContact, setInfoContact}),
		newSingleLineTagParser("License", &setMetaSingle{swspec, rxLicense, setInfoLicense}),
	}
	return sp
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:27,代码来源:meta.go

示例2: setSwaggerBasePath

func setSwaggerBasePath(swspec *spec.Swagger, lines []string) error {
	var ln string
	if len(lines) > 0 {
		ln = lines[0]
	}
	swspec.BasePath = ln
	return nil
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:8,代码来源:meta.go

示例3: setSwaggerHost

func setSwaggerHost(swspec *spec.Swagger, lines []string) error {
	lns := lines
	if len(lns) == 0 || (len(lines) == 1 && len(lines[0]) == 0) {
		lns = []string{"localhost"}
	}
	swspec.Host = lns[0]
	return nil
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:8,代码来源:meta.go

示例4: newAppScanner

// newAPIParser creates a new api parser
func newAppScanner(bp string, input *spec.Swagger, includes, excludes packageFilters) (*appScanner, error) {
	var ldr loader.Config
	ldr.ParserMode = goparser.ParseComments
	ldr.Import(bp)
	prog, err := ldr.Load()
	if err != nil {
		return nil, err
	}
	if input == nil {
		input = new(spec.Swagger)
	}

	if input.Paths == nil {
		input.Paths = new(spec.Paths)
	}
	if input.Definitions == nil {
		input.Definitions = make(map[string]spec.Schema)
	}
	if input.Responses == nil {
		input.Responses = make(map[string]spec.Response)
	}

	return &appScanner{
		MainPackage: bp,
		prog:        prog,
		input:       input,
		loader:      &ldr,
		operations:  collectOperationsFromInput(input),
		definitions: input.Definitions,
		responses:   input.Responses,
		classifier: &programClassifier{
			Includes: includes,
			Excludes: excludes,
		},
	}, nil
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:37,代码来源:scanner.go

示例5: metaSchemeSetter

func metaSchemeSetter(meta *spec.Swagger) func([]string) {
	return func(schemes []string) { meta.Schemes = schemes }
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:3,代码来源:meta.go

示例6: metaProducesSetter

func metaProducesSetter(meta *spec.Swagger) func([]string) {
	return func(produces []string) { meta.Produces = produces }
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:3,代码来源:meta.go

示例7: metaConsumesSetter

func metaConsumesSetter(meta *spec.Swagger) func([]string) {
	return func(consumes []string) { meta.Consumes = consumes }
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:3,代码来源:meta.go

示例8: safeInfo

func safeInfo(swspec *spec.Swagger) *spec.Info {
	if swspec.Info == nil {
		swspec.Info = new(spec.Info)
	}
	return swspec.Info
}
开发者ID:yourchanges,项目名称:go-swagger,代码行数:6,代码来源:meta.go


注:本文中的github.com/casualjim/go-swagger/spec.Swagger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。