2

如何从定义的 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)

Article在几个 api 端点中使用对象。问题是我不想id在发布新文章时被指定,所以我想在POST方法文档中省略它。是否可以在所有端点中包含Article实体并说明我想省略哪些字段?

4

1 回答 1

2

实际上没有办法做到这一点。你有两个选择:

  • id用属性声明nullable

  • 声明Articlewithoutid并且稍后继承Article和 attach id

# 数据结构

##文章(对象)
+ 名称:我的第一篇文章(字符串)

## ArticleInstance(文章)
+ id(数字)

## 文章 [/articles]

### 获取所有文章 [GET]

获取本网站上所有可用的文章。

+ 响应 200(应用程序/json)
 + 属性(数组[文章])

### 创建文章 [POST]

创建新文章。

+ 请求(应用程序/json)
    + 属性(文章)
于 2016-06-13T12:09:23.193 回答