Array type schemas do not render
brian-slate opened this issue · 4 comments
Array type schemas do not render, nor populate with model data.
Expected behaviour
I expected this schema to render:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"properties": {},
"items": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Contact",
"type": "object",
"description": "A Salesforce contact.",
"required": [
"Id"
],
"properties": {
"Level__C": {
"type": "string",
"description": "The Membership Level of the Contact."
},
"Id": {
"type": "string",
"description": "The ID of the contact."
},
"FirstName": {
"type": "string",
"description": "The first name of the contact."
},
"LastName": {
"type": "string",
"description": "The last name of the contact."
},
"Phone": {
"type": "string",
"description": "The phone number of the contact."
},
"HomePhone": {
"type": "string",
"description": "The home phone number of the contact."
},
"MobilePhone": {
"type": "string",
"description": "The mobile phone number of the contact."
},
"OtherPhone": {
"type": "string",
"description": "Other phone number of the contact."
},
"Email": {
"type": "string",
"description": "The email address of the contact."
},
"MailingStreet": {
"type": "string",
"description": "The street address of the contact."
},
"MailingCity": {
"type": "string",
"description": "The city of the contact."
},
"MailingState": {
"type": "string",
"description": "The state of the contact."
},
"MailingPostalCode": {
"type": "string",
"description": "The postal code of the contact."
},
"MailingCountry": {
"type": "string",
"description": "The country of the contact."
}
}
}
}
Actual behaviour
It actually does nothing. I can pull out the nested schema under 'items' which renders fine and populates with data.
Gist/Plunker/Demo
With array schema (doesnt work): https://plnkr.co/edit/QvCijZcoV7BV4RU9m2cz?p=preview
Pulling nested schema out of items to simple object schema: https://plnkr.co/edit/n1bQwjmCOF10KKogAtFg?p=preview
I've also tried the Alpha builds (up to 1.0.0-alpha.4) with no luck.
As a test, I was able to paste the above schema and sample data into another angular json schema form directive (angular-json-schema-form) and it works as expected: https://azimi.me/angular-json-schema-form/demo/demo.html
angular-json-schema-form: https://github.com/mohsen1/angular-json-schema-form/
Looking forward to updates on this project, it's been great up to this point! 👍
@bmherold for whatever reason the original design of this project assumed the root to be an object for simplicity. You can read prior issue responses in this issue How to make array type schemas work without wrapping them inside an object type and this issue root array not rendered
If it looks at any point like I could do it easily without breaking everything else I will do it, but I have too much on the TODO list to consider it at the moment unfortunately.
I intend to do some updates soon as I should have some time off to work on it soon while job hunting.
@Anthropic thanks for the prompt response! I'll take a look at the linked issues and maybe I can submit a PR in the meantime if you aren't able to get to it. Cheers 🍻
@bmherold I don't expect it to be easy enough till I finish some of the re-write stuff I am working on, it really is embedded and hard to work on at the moment unfortunately.