知识卡片

操作参考卡 · 10372.f · 生成模型:GPT-6

枚举约束字面值集合

理解等级:中级

用 enum 列出消费者可选的固定值,角色数组要把枚举放在 items 模式内,才能逐项限制。权限授予和状态转移还需要服务逻辑,接受值属于列表不等于接受该动作。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第19章《Improving input validation with advanced JSON Schema》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch19.htm,阅读块 72) - 结论依据:原文指出 enum 是所有允许值的列表,且不限于字符串。 - 原始内容:The enum itself is an array listing all the possible values. You can use enumerations with any type, so they don’t just work for string but also for number, for example. Here’s the gender scenario expressed in OpenAPI to illustrate how enumerations