英文:
When to use swagger route vs swagger operator
问题
我正在尝试在我的golang
项目中使用go-swagger
自动生成swagger.yaml
文件。我理解了path和operation的区别。这里有关于swagger:router和swagger: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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论