daybed icon indicating copy to clipboard operation
daybed copied to clipboard

[WIP] Add Json schema support

Open almet opened this issue 11 years ago • 11 comments

  • [x] Plug the new renderer with cornice;
  • [x] Test that all the fields are supported;
  • [x] Decide on a mime type to use.
  • [ ] Accept JSON schema for definitions.

Here are the types supported by Daybed that we need to convert to JSON Schema:

  • [x] Integer
  • [x] Text
  • [x] Datetime
  • [x] Boolean
  • [x] Regex
  • [ ] JSON
  • [ ] Anyof
  • [x] Email
  • [ ] OneOf
  • [x] String
  • [ ] Object
  • [ ] Date
  • [x] Url
  • [ ] List
  • [ ] Choices
  • [x] Range

GeoTypes:

  • [ ] Point
  • [ ] Polygon
  • [ ] GeoJSON
  • [ ] Line

almet avatar Aug 09 '14 00:08 almet

Great ! We should definitely follow standards ! ref #53 I could help you on this, this is quite a big task :)

leplatrem avatar Aug 09 '14 07:08 leplatrem

I added some changes to the branch, and I updated the description to contain the list of fields we currently support in daybed.

I'll be out starting tomorrow for one week, don't hesitate to continue what I started :)

almet avatar Aug 09 '14 17:08 almet

A few outstanding questions:

  • How do we deal with relation between models? (I guess we should set them to integers / strings depending the case);
  • How do we handle the JSON and GeoJSON fields? We could do a (really long) regexp, but I wonder if there is another take on it?
  • Handling objects and lists will be fun :)

almet avatar Aug 09 '14 17:08 almet

FWIW, here is the doc I'm using as a reference https://spacetelescope.github.io/understanding-json-schema/

almet avatar Aug 09 '14 17:08 almet

For relations between models modelname is a string.

Natim avatar Aug 10 '14 07:08 Natim

I was wondering if it is still relevant to have our own schema formalism... I mean, instead of formatting our custom stuff to the standard JSON schema, just accept it as input for model creation ?

leplatrem avatar Aug 10 '14 13:08 leplatrem

For know it is relevant because our schema is close to what daybed do. Btw we could implement both input formalisms if we need to be compatible somehow and ask the question again then.

Natim avatar Aug 11 '14 08:08 Natim

@leplatrem, I was wondering the exact same thing.

I believe what we have for daybed is simpler than json schema, but I may be wrong. Especially, for the geometric fields, there is nothing that deals with them in json schema, so that could be a bit hard to do.

For really simple cases, I believe we should accept JSON Schema definitions, and that would make us open to a list of services that already support this formalism.

However, that's in my opinion a separate issue. In this one, I think we should focus on outputing a json schema from a daybed (colander) definition.

almet avatar Aug 18 '14 08:08 almet

for now, mimetype is application/schema+json

almet avatar Aug 25 '14 14:08 almet

@leplatrem do you have any idea how we can deal with geographic fields here?

almet avatar Aug 25 '14 14:08 almet

I found only one example, and it looks pretty complete : https://github.com/fge/sample-json-schemas/blob/master/geojson/geometry.json

In Daybed we have a geojson geometry field (as above), and some basic geo fields that could be described with the positions part only (coordinates only)

leplatrem avatar Aug 25 '14 22:08 leplatrem