Swagger 2中的版本控制端点
我是Swagger的新手,我希望能够在需要时轻松创build新版端点。 我的swagger.yaml
文件看起来像这样:
swagger: "2.0" info: version: "1.0.0" title: API description: blah contact: name: Some guy basePath: /v1 schemes: - http - https consumes: - application/json produces: - application/json paths: /log: x-swagger-router-controller: log post: summary: Creates a log entry. description: Creates a log entry. tags: - Logs security: - user: [] - session: [] parameters: - name: body in: body required: true responses: 200: description: Success 400: description: Error 401: description: Unauthorized
我非常一贯地看到Swagger教程使用/ v1或/ v2等作为他们的基本path。 这有点乞丐的问题…如何增加个人端点的版本? 到目前为止,我所做的是使基path/
然后用v1
(例如v1/log
)加上每个端点path。 这个解决scheme不能很好地扩展,因为我将拥有一个巨大的swagger.yaml
文件,因为我将拥有文件中每个端点的每个版本。 更不用说,这也使文档变得混乱,因为每个端点都附加了版本标识符。
Swagger 2有没有更容易或更好的方法?