apiaryio / mson

Markdown Syntax for Object Notation
MIT License
903 stars 180 forks source link

Add info about fixed-type property #67

Closed goganchic closed 8 years ago

goganchic commented 8 years ago

based on https://github.com/apiaryio/mson/issues/66

pksunkara commented 8 years ago

There is only one comment. In talking about fixed, MSON spec says this.

  • Individual [Nested Member Types][] MAY override inherited behavior from a fixed inherited type by using an optional attribute and/or MAY indicate values are samples using a [Variable Value][].

    - person (object, fixed)
      - `first_name`
      - `last_name` (optional)

    Implies a "value object" that MUST contain the property "first_name" and MAY contain the property "last_name".

    - colors (array, fixed)
      - red
      - *green*

    Implies an array type structure that MUST contain "red" as an item and MAY contain any other strings, where "green" is a sample value.

You should add something like this for fixed-type too.

goganchic commented 8 years ago

Unfortunately I do not understand what comment should I add for fixed-type. fixed is inheritable, so you can overrride it in some places with optional keyword, but fixed-type is unheritable, so there is nothing to comment about override of this keyword I think.

pksunkara commented 8 years ago

Sorry about that. Got confused for a bit. Never mind that comment.

pksunkara commented 8 years ago

This will be merged when drafter with fixed-type support is released.

zdne commented 8 years ago

Thanks for your contribution!

Before merging I'd like to see reasoning on https://github.com/apiaryio/mson/pull/67/files#r74749674 also I'd like to see using the same terminology as rest of the specification to avoid any disambiguation (internal data structure vs nested member type).

w-vi commented 8 years ago

Can we merge this and fix the lingo separately? Otherwise this will lay around for weeks just because somebody has to learn the slang.

pksunkara commented 8 years ago

@w-vi We do not merge this until drafter is released with this change.

w-vi commented 8 years ago

OK.

zdne commented 8 years ago

@w-vi

Otherwise this will lay around for weeks just because somebody has to learn the slang.

The "slang" is one thing. But I am missing the reasoning about

  1. Why this does new type attribute isn't promoted to nested member types
  2. Proper demonstration where this is useful (the provided examples can be implemented with fixed)
w-vi commented 8 years ago

@zdne

The reason being the flexibility I want array of User objects but I don't want to impose constraints on the User object just because I want it in an array, you can specify any constraints on the User object directly.

Is this not enough for clarification why it is not propagated?

Agree that the examples are not sufficient and are possible by other means although I don't think that examples need to be unique.

pksunkara commented 8 years ago

Merging since this is released in drafter 3.1.0