何时使用swagger路由与swagger操作符?

huangapple go评论87阅读模式
英文:

When to use swagger route vs swagger operator

问题

我正在尝试在我的golang项目中使用go-swagger自动生成swagger.yaml文件。我理解了path和operation的区别。这里有关于swagger:routerswagger:operator的各自文档链接。我看到两者的语法看起来相同,但我不明白它们之间的细微差别,以及何时应该使用其中之一,在什么情况下使用?

英文:

I am trying to auto-generate swagger.yaml file using go-swagger in my golang project. I understood difference between path and operation. And here are links for individual documentation for swagger:router and swagger:operator. As I see the syntax for both looks same and I don't understand the nuance between them and when one should be used over another and in what cases ?

答案1

得分: 1

swagger:route是一种定制的语法,与yaml无关,当你定义响应时,你会注意到这一点。

swagger:operation的作用与swagger:route相同,它也允许你定义和描述路由,但你定义参数和响应的方式是使用常规的swagger规范yaml。因此,使用swagger:operation,你基本上是在定义yaml片段,这些片段会被原样放入swagger规范文件中。

英文:

swagger:route is a bespoke syntax that has nothing to do with yaml, you'll notice this especially when you are defining responses

swagger:operation serves the same purpose in that it also allows you to define and describe routes, but the way you define parameters and responses is the regular swagger spec yaml. So with swagger:operation you are basically defining yaml snippets that get put verbatim in the swagger spec file.

huangapple
  • 本文由 发表于 2022年4月14日 15:13:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/71867755.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定