robotoworks / specapi

A Web API specification language
2 stars 1 forks source link

Mixins #3

Open fluxtah opened 10 years ago

fluxtah commented 10 years ago

Currently the grammar supports the concept of extending responses with an entity.

response extends Base { ... }

This has recently been changed to

response mixin Base { ... }

At the moment Base should be defined as an entity, however it would be better to introduce a specific keyword to specify something that can be "mixed in"

Some languages have the concept of categories, it could work like this:

properties Base {
    status:boolean,
    message:string
}

Which is basically a bag of properties that can be 'mixed in' with other entities.

SInce some responses can be defined anonymously (which might be a bad thing anyway), ie:-

resonse {
    status:boolean,
    message:string
}

Then it makes sense to allow a mixin here (which mechanoidnet supports as extends, ie:-

response mixin Base {
   qux:string
}

and as mentoined with entities:-

entity Repository mixin Base {
   id:int,
   name:string
}
fluxtah commented 10 years ago

To add, these mixins should not form a base type in a given code generator but should be combined into a concrete type.