Author Message
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
I'm trying to use a schema that has types defined elsewhere in the document, and are referred to by $ref. How to accomplish this in ED?

Sample json:
{

"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"contact_info": {
"$ref": "#/components/schemas/ContactInfo"
}
}
},
"ContactInfo": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"phone": {
"type": "string"
}
}
}
}
}
}
AnuragAggarwal
Joined: Jun 1, 2014
Messages: 154
Offline
ref is not currently supported in ED
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
Thanks for the confirmation. What would be the proper way to rewrite the ref in order for ED to recognize the schema? Using the above sample as an example.
AnuragAggarwal
Joined: Jun 1, 2014
Messages: 154
Offline
you can inline ref, something of sort

{
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"contact_info": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"phone": {
"type": "string"
}
}
}
}
}
}
}
}

also probably format would need to be modified to look something like

{
"title": "user_schema",
"type": "object",
"properties": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"contact_info": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"phone": {
"type": "string"
}
}
}
}
}
}
}
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
Ok, so nested object types are fine, just no ref. Got it, thanks!
Go to:   
Mobile view