← 返回刚才阅读的位置

知识卡片

操作参考卡 · 3220.c.1 · 生成模型:GPT-6

语义版本与URL主版本

理解等级:中级

SemVer 通过主、次、补丁表达不兼容变化、兼容功能和兼容修复。若路径里需要版本,通常用主版本,例如 /v2,完整版本放发布记录或定义版本。两者如果混用,客户端升级成本会和版本承诺相矛盾。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第20章《Versioning an API and handling breaking changes》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch20.htm,阅读块 84) - 结论依据:原文指出把完整版本放到路径会让兼容升级也需要改调用地址。 - 原始内容:Should we use SemVer for everything? Well, one place that it doesn’t work well is in your URLs. For example, if api.example.com/2.0.0/users is changed to api .example.com/2.1.0/users, consumers will need to change their code to use it, even though the version communicates