Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Schema only resolves first of multiple properties with same model #245

Closed
joernesdohr opened this issue Jun 27, 2013 · 5 comments
Closed

Comments

@joernesdohr
Copy link

Hi,
I'm writing some custom models for my API. I have a Colour_pure_and_tinted model, which holds 2 properties of the model "Colour", each is the representation of either unaltered pure RGB values or manipulated ones:

        "Colour_pure_and_tinted" : {
            "id" : "Colour_pure_and_tinted",
            "properties" : {
                 "pure"   : { "type" : "Colour", "required" : true }
                ,"tinted" : { "type" : "Colour", "required" : true }
            }
        }

        ,"Colour" : {
            "id" : "Colour",
            "properties" : {
                 "red"   : { "type" : "int", "required" : true }
                ,"green" : { "type" : "int", "required" : true }
                ,"blue"  : { "type" : "int", "required" : true }
            }
        }

But in the Model Schema view, only the very first instance of Colour (property "pure") is resolved to its proper atomic properties representation. "tinted" remains as just "Colour":

        {
            "pure": {
                "red": "int",
                "green": "int",
                "blue": "int"
            },
            "tinted": "Colour"
        }

Am I doing something incorrectly or is this a bug?

@fehguy
Copy link
Contributor

fehguy commented Jun 27, 2013

that looks like a bug from what you posted. As a test, can you change tinted to be Colour1 and copy the Colour model appropriately?

@joernesdohr
Copy link
Author

tinted resolves correctly to the internal structure of Colour1 then, as does pure to Colour. As expected though, any additional Colour1 property is not resolved.

@fehguy
Copy link
Contributor

fehguy commented Jun 27, 2013

OK, sounds like the schema view is only allowing a single instance of an object. I can see cases for and against that behavior but here, it seems to be doing the wrong thing

@rage-shadowman
Copy link

I was under the impression that this change was done to avoid infinite recursion (where Model X contains an X in a property).

The fix is a 1-liner in swagger.js file.

See: https://github.com/rage-shadowman/swagger-js/commit/6616a58f1e1e8c516d3921005464f7adf31d7673

Note: The only file that really changed in the above was swagger.coffee, the rest of the changes were because I am using a different version of the node coffee compiler.

@fehguy
Copy link
Contributor

fehguy commented Sep 12, 2013

this is pushed to master.

@fehguy fehguy closed this as completed Sep 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants