cloudwan / gohan

Gohan is an API Gateway Server written by Go that makes it easy for developers to create and maintain REST-style API
http://www.slideshare.net/natiueno/gohan-61170476
Other
109 stars 44 forks source link

Schema for associations like has_one and has_many #142

Open morrisson opened 8 years ago

morrisson commented 8 years ago

With 'parent' and 'relation' statement, we can define a kind of 'belongs_to' association. We often get 'child' resources for visualizing when querying some resources but currently there is no way to get child resources.

To enhance usability of querying data, schema description should allow to define associations like has_one and has_many. Example schema is as follows:

schemas:
- id: some_resource
  description: Some Resource Schema
  title: Some Resource
  singular: some_resource
  plural: some_resources
  associations:
    has_one:
    - some_operational_resource
    has_many:
    - some_child_resource
    - some_other_child_resource
  schema:
    properties:
      ...

'Child' resources should have foreign_key for parent resource which is created automatically.

nati commented 8 years ago

+1