【发布时间】:2016-06-12 15:12:56
【问题描述】:
如何从定义的 MSON 中省略属性?我已经使用 MSON 定义了一个简单的实体(对象):
# Data Structures
## Article (object)
Represents an article
## Properties
+ id: 1 (number, optional)
+ name: My first article (string)
## Articles [/articles]
### Get all articles [GET]
Get all articles available on this website.
+ Response 200 (application/json)
+ Attributes (array[Article])
### Create an article [POST]
Create new article.
+ Request (application/json)
+ Attributes (Article)
我在几个 api 端点中使用 Article 对象。问题是我不想在发布新文章时指定id,所以我想在POST 方法的文档中省略它。是否可以在所有端点中包含 Article 实体并说出我想省略哪些字段?
【问题讨论】:
-
数据结构的可选规范还不够吗?
-
它不是可选的...你不能设置它,因为数据库使用自动增量填充
id。也许您是对的,您可以发布它,我可以忽略它,但是在文档中看到它并且无法使用它很奇怪。
标签: apiblueprint apiary.io mson