spiral-project / daybed

Form validation and data storage API
http://daybed.rtfd.org/
BSD 3-Clause "New" or "Revised" License
53 stars 8 forks source link

geojson renderer used when not needed #181

Closed almet closed 9 years ago

almet commented 9 years ago

By default, the geojson renderer is used even when it doesn't make sense. We shouldn't do that.

almet commented 9 years ago

After two POST for a todo:

http POST http://localhost:8000/models/todo/records item="work on daybed" status="done" --verbose

I have:

{
    "features": [
        {
            "id": null, 
            "properties": {
                "item": "work on daybed", 
                "status": "done"
            }, 
            "type": "Feature"
        }, 
        {
            "id": null, 
            "properties": {
                "item": "work on daybed", 
                "status": "done"
            }, 
            "type": "Feature"
        }
    ], 
    "type": "FeatureCollection"
}
almet commented 9 years ago

Thinking again, that's valid, since we're not asking for a particular mime type, but I would expect this to be json by default.

If you ask for json, you actually get json so that works.

@leplatrem any thoughts on this one?

leplatrem commented 9 years ago

Yep, this is a ticket I opened in cornice : https://github.com/mozilla-services/cornice/issues/150

Natim commented 9 years ago

Also geojson is the default for Daybed so if you don't specify it to be JSON you will get geojson.

Natim commented 9 years ago
http GET http://localhost:8000/models/todo/records
HTTP/1.1 200 OK
Content-Length: 166
Content-Type: application/vnd.geo+json; charset=UTF-8
Date: Wed, 30 Jul 2014 09:37:12 GMT
Server: waitress

{
    "features": [
        {
            "id": "0af6caa9b345473d81f68d23e8aff214", 
            "properties": {
                "item": "work on daybed", 
                "status": "done"
            }, 
            "type": "Feature"
        }
    ], 
    "type": "FeatureCollection"
}
http GET http://localhost:8000/models/todo/records --json
HTTP/1.1 200 OK
Content-Length: 101
Content-Type: application/json; charset=UTF-8
Date: Wed, 30 Jul 2014 09:37:23 GMT
Server: waitress

{
    "records": [
        {
            "id": "0af6caa9b345473d81f68d23e8aff214", 
            "item": "work on daybed", 
            "status": "done"
        }
    ]
}
Natim commented 9 years ago

I fixed it like so: https://github.com/spiral-project/daybed/pull/185/files#diff-d37c76536c0cc671b37242441ef06620R23

Natim commented 9 years ago

Actually it is a random fix :s

leplatrem commented 9 years ago

Bug can be observed here with backbone-daybed : http://spiral-project.github.io/backbone-daybed/#todo

Accept header is application/json, text/javascript, */*; q=0.01

Rather problematic :/