restful-api-description-language / RADL

RADL: A description language and tooling for hypermedia-driven RESTful APIs
Apache License 2.0
23 stars 5 forks source link

Extract common data structure out of <data-model> #32

Closed RaySinnema closed 9 years ago

RaySinnema commented 9 years ago

Consider a system for working with people and organizations they are affiliated with. There would be resources /organizations/{id}/ and /persons/{id}/ and the representation for both would include an address. With the current schema, we would have two <data-model> elements that contain nested properties for the address. IOW, we would have to duplicate the address structure.

I propose we eliminate that duplication by introducing a reference, e.g. something like:

<data-model name="address">
  <!-- properties -->
</data-model>

<data-model name="person">
  <properties>
    <property name="address">
      <properties ref="address"/>
    </property>
  </properties>
</data-model>

<data-model name="organization">
  <properties>
    <property name="visit-address">
      <properties ref="address"/>
    </property>
    <property name="post-address">
      <properties ref="address"/>
    </property>
  </properties>
</data-model>
jonathanrobie commented 9 years ago

+1

gentlewind commented 9 years ago

+1 for ref

jonathanrobie commented 9 years ago

Note that this is a breaking change for anyone using data models.

RaySinnema commented 9 years ago

Why is that? We're just adding the ref attribute, not taking anything away or changing any existing semantics, are we?

jonathanrobie commented 9 years ago

The ref attribute by itself is not a breaking change, we have several related issues, and the data-model element is going away.

jonathanrobie commented 9 years ago

See https://github.com/restful-api-description-language/RADL/issues/34

jonathanrobie commented 9 years ago

Is this resolved by the solution in issue #34 ?

RaySinnema commented 9 years ago

Yes.