【发布时间】:2017-03-01 01:42:52
【问题描述】:
我正在寻找在使用媒体类型版本控制我的 REST API 版本时使用 Camel Rest DSL 的解决方案。请参阅https://www.narwhl.com/2015/03/the-ultimate-solution-to-versioning-rest-apis-content-negotiation/ 了解我想要完成的工作的详细信息。
例如,如果我有两个版本的 Store 对象(V1_0 和 V2_0)。
.post('/').description('Create a new store').type(Store_V1_0).outType(Store_V1_0)
.consumes('application/x.canopy.store+json; version=1.0, application/x.canopy.store+json; version=2.0')
.produces('application/x.canopy.store+json; version=1.0, application/x.canopy.store+json; version=2.0' )
.param().name('body').type(body).description('The store to create').endParam()
.route()
.to('log:com.acme.api.store?level=INFO&showHeaders=true')
.endRest()
请注意,我在“consumes”/“produces”中指定了多种媒体类型。但是,我仅限于“type”/“outType”中的单个类。
如果我尝试多行“post('/')”,我会收到“rest-dsl 中检测到重复动词”错误。有没有办法可以将媒体类型绑定到 POJO?
欢迎任何有关如何使用媒体类型处理我的 REST API 版本控制的建议。
编辑:我也在尝试为 Swagger 生成规范,并希望能够根据所选的内容类型在 Swagger UI 中看到不同的“示例值”。
【问题讨论】:
标签: rest apache-camel