pythononwheels / pow_devel

development repo for PyhtonOnWheels framework
www.pythononwheels.org
MIT License
75 stars 10 forks source link

Add default schema URL / Endpoint for model REST API #34

Open pythononwheels opened 5 years ago

pythononwheels commented 5 years ago

So you can access the schema as well

API /modelname/schema Returns JSON

Example JSON Rsponse for a blog article model:

call:

localhost:8080/article/shema

response:

schema = {
        'title'          :   { 'type' : 'string', 'maxlength' : 255},
        'teaser'         :   { 'type' : 'string' },
        'text'           :   { 'type' : 'string'},
        'tags'           :   { 'type' : 'list', "default" : [] },
        'comments'       :   { 'type' : 'list', "default" : [] },
        'featured'       :   { 'type' : 'boolean', "default" : False },
        'blog'           :   { 'type' : 'boolean', "default" : False },  
        "blog_link"      :   { 'type' : 'string', "default" : "" },
        "votes"          :   { "type" : "integer", "default" : 0 },
        "author"         :   { "type" : "dict" }, #author 
        "images"         :   { "type" : "list"  }, #list of images uploaded for this article   
        "featured_image" :   { "type" : "string", "default" : "" },
        "read_time"      :   { "type" : "string"},
        "published"      :   { "type" : "boolean"},
        "published_date" :   { "type" : "datetime", "default" : datetime.datetime(1999,1,1,23,59)},
        "voter_ips"      :   { "type" : "list", "default" : [] },
     "twitter_card"  :   { "type" : "boolean", "default" : False }
    }

fwfgr