知识卡片
API版本选择机制
版本选择机制规定调用方如何取到约定版本。常见选择有路径、主机名、查询参数、自定义请求头、Accept 媒体类型和账号固定版本。路径版本能在 URL 中直观看出,主机名利于流量隔离,但迁移可能涉及客户端安全配置。头部和内容协商保持 URI 稳定,需要文档说明请求头和默认值。
固定版本可在首访时把版本记入账号,后续默认沿用,允许消费者单独试用或升级。如果组合账号默认与请求头覆盖,要写清优先级。也可以没有请求级版本选择,此时使用方会更依赖发布方维持长期兼容。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 破坏性变更与 API 演进 4.7 API versioning schemes · 查看原书依据
This is also known as point-in-time versioning or dynamic-date versioning. The first time an API consumer makes a request to an API, the current API version is pinned to their account profile and used to process the request. All further API requests from that consumer default to that pinned version. When the API consumer is ready to upgrade to a new API version, they can log in to their account profile and update their default version setting.
参考来源
- 位置:《Automating API Delivery APIOps with OpenAPI》《第 04 章 破坏性变更与 API 演进》(4.7 API versioning schemes;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-4.xhtml#p124)
- 结论依据:解释账号固定版本的机制及消费者自行升级的时机。
- 原始内容:This is also known as point-in-time versioning or dynamic-date versioning. The first time an API consumer makes a request to an API, the current API version is pinned to their account profile and used to process the request. All further API requests from that consumer default to that pinned version. When the API consumer is ready to upgrade to a new API version, they can log in to their account profile and update their default version setting.