1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Weed, CA, US
    Posts
    18
    Answers
    2
    Vote Rating
    1
    justinzane is on a distinguished road

      1  

    Default Unanswered: Is it possible to autocreate Models based on the JSON schema from a REST server?

    Unanswered: Is it possible to autocreate Models based on the JSON schema from a REST server?


    My REST api, django-tastypie, provides a nice schema for each model:
    Code:
    {
        "allowed_detail_http_methods": ["get", "post", "put", "delete", "patch"], 
        "allowed_list_http_methods": ["get", "post", "put", "delete", "patch"], 
        "default_format": "application/json", 
        "default_limit": 20, 
        "fields": {
            "id": {
                "blank": false, 
                "default": "", 
                "help_text": 
                "Unicode string data. Ex: \"Hello World\"", 
                "nullable": false, 
                "readonly": false, 
                "type": "string", 
                "unique": true
            }, 
            "resource_uri": {
                "blank": false, 
                "default": "No default provided.", 
                "help_text": "Unicode string data. Ex: \"Hello World\"", 
                "nullable": false, 
                "readonly": true, 
                "type": "string", 
                "unique": false
            }, 
            "text": {
                "blank": false, 
                "default": "", 
                "help_text": 
                "Unicode string data. Ex: \"Hello World\"", 
                "nullable": false, 
                "readonly": false, 
                "type": "string", 
                "unique": false
            }
        }
    }
    It strikes me that coding models in both the RESTful server and the RESTful client, in this case django-tastypie and ExtJS, is a violation of the DRY (don't repeat yourself) development pattern.

    What I am hoping for is guidance on how to create dynamic Models/Stores based on the schema data pulled by a proxy.

    Some background info:
    http://webofdata.wordpress.com/2011/...-and-the-rest/
    http://json-schema.org/
    JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.
    Last edited by justinzane; 15 May 2012 at 11:43 AM. Reason: Adding background

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    lukepatrick is on a distinguished road

      0  

    Default Response MetaData

    Response MetaData


    Well, it seems like it is kind-of possible through the Response MetaData and the 'metachange' listner. http://docs.sencha.com/ext-js/4-1/#!...ta.reader.Json
    though this isn't exactly what you are looking for. I would be interested in a better answer as I'm looking for the same thing you are.

Thread Participants: 1

Tags for this Thread