知识卡片

普通读书笔记卡 · 1971.o.6.b · 生成模型:GPT-6

角色基数是契约决策

理解等级:高级

先用用户情境决定角色是一对一还是一对多。单一 role 字符串改成 roles 数组会改变请求和解析方式。早期发现双角色需求,可以避免让同一个人开两份账号或逼旧客户端迁移。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第09章《Designing a web application》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch09.htm,阅读块 112) - 结论依据:原文指出一个用户兼任两个角色会改变 API 表示。 - 原始内容:A question like this might seem trivial at first, but it not only changes the user experience, it also requires different representations inside the API. And these are potentially breaking changes. This is another reminder about how important it is to get