vmware / vmware-openapi-generator

VMware-openapi-generator tool generates open-api documents from vapi metamodel format.
Other
23 stars 19 forks source link

Addressed Schema Validation Error by deleting the 'required' attribute #30

Closed kunal-pmj closed 5 years ago

kunal-pmj commented 5 years ago

from a property dict

Signed-off-by: Kunal Singh singhk@vmware.com

kunal-pmj commented 5 years ago

This pull request will address the following issue

sreeshas commented 5 years ago

Hi Kunal, When submitting pull requests, can you make sure to be more descriptive so it is easy for the reviewer to understand. What was the issue here and can you explain how deleting required will solve the problem?

kunal-pmj commented 5 years ago

Hi @sreeshas Apologies for not providing enough information related to the fix. Well, This is another fix to avoid the schema validation error reported in the following issue.

I will illustrate the issue and the fix with this example :

/com/vmware/vcenter/inventory/datastore?~action=find, its success response refers to following type vcenter.inventory.datastore.find_result

"vcenter.inventory.datastore.find_result": { "type": "object", "properties": { "value": { "type": "array", "items": { "type": "object", "properties": { "key": { "type": "string" }, "value": { "required": false, "$ref": "#/definitions/vcenter.inventory.datastore.info" } } } } }, "required": [ "value" ] },

The validation error is reported because the "required" is present along with the $ref.

The fix was to deleted the required attribute if its sibling is $ref. This is similar to the cleanup method line#478 which deletes required field from the properties dictionary

sreeshas commented 5 years ago

Thanks for explaining the fix. I'm okay with the approach but i think there will lot more cases where "required" might need to be removed. So you can move this logic to cleanup method or write a new method and call it from process_output like we do for remove_com_vmware_from_dict.

kunal-pmj commented 5 years ago

Thanks for explaining the fix. I'm okay with the approach but i think there will lot more cases where "required" might need to be removed. So you can move this logic to cleanup method or write a new method and call it from process_output like we do for remove_com_vmware_from_dict.

Hi @sreeshas

I moved the fix to remove_com_vmware_from_dict.

Thanks Kunal

vmwclabot commented 5 years ago

@kunal-pmj, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

vmwclabot commented 5 years ago

@kunal-pmj, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

vmwclabot commented 5 years ago

@kunal-pmj, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.