jsonary-js / jsonary

Quickly assemble clients for JSON-based APIs (powered by JSON Schema)
http://jsonary.com/
MIT License
122 stars 14 forks source link

title isn't respected when property is defined via "$ref" #134

Closed Ognian closed 10 years ago

Ognian commented 10 years ago

I'm pretty sure that this was working. the following property:

 "xxx": {
                    "$ref": "/v1/dbRef",
                    "title": "Titel of X"
                },

Is shown as xxx instead of "Titel of X", any idea why? Thanks Ognian

gazpachoking commented 10 years ago

The way I read the JSON ref spec, this seems correct. Otherwise some sort of merging behavior would have to be defined.

Any members other than "$ref" in a JSON Reference object SHALL be ignored.

http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03

Ognian commented 10 years ago

You are right, but this doesn't help. I need to use a $ref since I want to define that "sub" schema only once. And by using it in several places I need to name it different...

Ognian commented 10 years ago

I think that there was a discussion on the JSON Schema google group explaining the problem. Think of an address schema. Now you want to use a $ref everywhere where you have an address, regardless if it is a delivery address or and invoice address etc. So in my opinion there must be a way to define this with $ref, I would think that merging is the solution, and that this should be changed in json-ref-04... help...

gazpachoking commented 10 years ago

Would something like this work for your case?

{
    "title": "Title of X",
    "allOf": [{"$ref": "/v1/dbRef"}]
}
Ognian commented 10 years ago

Yes indeed this works! Thank you