-
Notifications
You must be signed in to change notification settings - Fork 3
Allow specifying arrays of objects for link data #7
Comments
@fosrias @sheavalentine-mdsol @miwest929 create:
doc: Creates a DRD.
rt: drds
links:
self: DRDs#create
help: Forms/create
href: update
accept: collection
semantics:
- href: name
ext: validated_input_field
- href: leviathan_uuid
field_type: text
- href: leviathan_health_points
field_type: number
validators:
- required
- min: 0
- max: 100
sample: 42
- href: leviathan_email
field_type: email
validators:
- required
- pattern: "^.+@.+$" How do we specify this in HALE is open question. |
@fosrias @sheavalentine-mdsol @miwest929 @ejennings-mdsol Here is a solution: semantics:
apartment_number:
doc: Apartment number
href: http://alps.io/schema.org/Text
street:
doc: Street name
href: http://alps.io/schema.org/Text
city:
doc: City name
href: http://alps.io/schema.org/Text
address:
doc: Address
href: http://alps.io/schema.org/Object? #should point to objects profile
semantics:
- href: apartment_number
field_type: text
- href: street
field_type: text
- href: city
field_type: text
idempotent:
update:
doc: Updates persons address
rt: none
semantics:
- href: address
field_type: object
multiple: true #implement support for this in API doc And here is hale document for this case: {
"update": {
"href": "http: //localhost:3000/person",
"templated": true,
"method": "PUT",
"data": {
"address": {
"type": "object",
"multi": true,
"data": {
"apartment_number": {
"type": "text: text"
},
"street": {
"type": "text: text"
},
"city": {
"type": "text: text"
}
}
}
}
}
}
|
@fosrias @sheavalentine-mdsol @miwest929 @ejennings-mdsol |
Seems you could skip the "Address" semantics and do: semantics:
address:
doc: Some Addresses
multiple: true #implement support for this in API doc
data:
- href: apartment_number
- href: street
- href: city Or at least be able to do that. As for the Hale spec, not sure if we need the "multi" key if you specify type as an array as @sheavalentine-mdsol did in a prior example that we merged. Further, instead of using multiple, we could use "cardinality" and in Hale use that as well with a default to single, but if it is multiple, n or a fixed number could use that for both the descriptor document and hale. I will be working on getting what I suspect will be cardinality into ALPS soon hopefully. Does this address your questions @brutski? |
@fosrias Yes, we don't need to introduce address semantic separately on a top-level. You can define it like you defined. However, you still need to have complex semantic elements in order to do artificial grouping of related items (aka fieldset in html). Yes, answers my question. Working on a solution in HALE. |
Array won't serialize that way, you still need multi: {
"address": {
"type": "array",
"multi": true,
"data": {
"apartment_number": {
"type": "text: text"
},
"street": {
"type": "text: text"
},
"city": {
"type": "text: text"
}
}
} This will expect: { "address":
[ {
"apartment_number": 1,
"street": 123,
"city": "New York"},
{
"apartment_number": 2,
"street": 123,
"city": "New York"},
]
} However this "address": {
"type": "object",
"multi": true,
"data": {
"apartment_number": {
"type": "text: text"
},
"street": {
"type": "text: text"
},
"city": {
"type": "text: text"
}
} Will Expect: [ {
"address": {
"apartment_number": 1,
"street": 123,
"city": "New York"},},
{
"address": {
"apartment_number": 2,
"street": 123,
"city": "New York"},},
] |
Well both examples include multi. However, it seems the first example is "address": {
If there is no multi property and why? Seems we just need to define Am I missing something? On Tue, Jul 22, 2014 at 7:49 AM, Shea Valentine [email protected]
|
So, @fosrias It looks like hale down below doesn't make sense. "person" : {
"type": "array",
"data": {
"name": {},
"phone_number": {}
}
} What that means, essentially, is that you have something like: [ "Name", "1-234-567-8911" ] which is unrelated data. However, this hale does make sense, which is an array of names. "names": {
"type": "array",
"data": {
"name": {}
}
} So were brainstorming this and and most of the use cases can be covered with "type: object" or "type: anything" and "multi: true". create:
type: unsafe
data:
names:
type: array
data:
- href: name Which can be achieved with: create:
type: unsafe
data:
- href: name
multi: true Another example which doesn't make sense is, since data is unrelated and semantically different. create:
type: unsafe
data:
names:
type: array
data:
- href: name
- href: uuid Example below on the other hand makes sense:
Which is exactly the same meaning like: create:
type: unsafe
data:
person:
type: object
multi: true
data:
- href: name
- href: uuid Thoughts? |
@fosrias @sheavalentine-mdsol now, when I think about this, I really don't like keys like 'person', 'address' and etc. as grouping elements. We should probably introduce generic one, like in HTML, called 'fieldset'. data:
fieldset:
type: object
multi: true
data:
- href: name
- href: uuid HALE will look like: "fieldset": {
"type" : "object",
"multi": true,
"data": {
"name": {...},
"uuid": {...}
}
}
And it will expect: [
{ "name": "Drd", "uuid": "1" },
{ "name": "Leviathan", "uuid": "2" }
]
Thoughts? |
I don't think using fieldset under data is good because we now have a magic @brutski I am not sure I followed your prior example with the wrong value On Wed, Jul 23, 2014 at 4:58 PM, brutski [email protected] wrote:
|
Us this now addressed with the recursive ability of "data", if not, can we restate the problem? |
I think it is. But if we have not documented it clearly we should. @brutski can you comment? |
@fosrias @sheavalentine-mdsol Yes, I think I did that here: Complex object. |
If it's unclear, maybe we should create a new issue for "clear example of how to render POST data" and close this issue as resolved. |
@ejennings-mdsol Mentioned the issue of a batch create that sent an array of some type of object. I think we could recursively add using data elements but we may need to include some flag like accept or require multiple or something.
The text was updated successfully, but these errors were encountered: