2

How can I ommit property from defined MSON? I have defined one simple entity (object) using 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)

I'm using Article object in several api endpoints. The problem is that I don't want id to be specified when posting new article so I want to omit it in the documentation for POST method. Is it possible to include Article entity in all endpoints and say what fields I want to omit?

Northys
  • 1,305
  • 3
  • 16
  • 32
  • Isn't the optional specification on data structure enough? – Vincenzo Jun 12 '16 at 15:20
  • It is not optional... You can't set it, because the database fills `id` using auto increment. Maybe you are correct, you can post it and I can ignore it but it is weird to see it in documentation and can't use it. – Northys Jun 12 '16 at 15:25

1 Answers1

2

There is no actually way how to do it. You have two options:

  • declare id with attribute nullable

  • Declare Article without id and later inherit from Article and attach id.

# Data Structures

## Article (object)
+ name: My first article (string)

## ArticleInstance (Article)
+ id (number)

## 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)
Northys
  • 1,305
  • 3
  • 16
  • 32
Jiri Kratochvil
  • 111
  • 1
  • 2
  • Thanks. It does not add `id` property to inherited `Article` though. `Article` and `ArticleInstance` are same. [Here you can see full blueprint](https://gist.github.com/Northys/aec89a325e223d86674e4d78cb31378c). Am I missing something? – Northys Jun 13 '16 at 12:25
  • I'm sorry, fields are added to the bottom of the entity. It works, thank you! – Northys Jun 15 '16 at 19:44