delphix / virtualization-sdk

Delphix vSDK.
Apache License 2.0
7 stars 25 forks source link

Complex array items in a schema are provided as dict not the generated array object class. #356

Open AleksandrLiber opened 3 years ago

AleksandrLiber commented 3 years ago

The attached schema contains complex array object definitions. When the plugin is built classes are generated for these array objects. The main schema that is generated seems to imply that the property will return a list of these objects.

    @property
    def repo_array(self):
        """Gets the repo_array of this RepositoryDefinition.

        :return: The repo_array of this RepositoryDefinition.
        :rtype: List[RepositoryDefinitionRepoArray]
        """
        return self._repo_array

This is not the case however. When trying to query one of the parameters of the repository array object the following error was observed: Error A "AttributeError" was detected while running the plugin operation "Direct Linked Source Pre-Snapshot": 'dict' object has no attribute 'repo_array_string_value'

I then inspected the repository object being provided to the presnapshot function:

logger.info("Repo param: %s",type(repository))
logger.info("Repo object: %s", type(repository.repo_object))
logger.info("Repo array: %s",type(repository.repo_array))
for item in repository.repo_array:
        logger.info("Repo array item: %s",type(item))

this returned the following:

[JOB-43|DB_SYNC(APPDATA_CONTAINER-2)] 2021-03-01 13:41:40,891 INFO     [plugin_runner.py:136] Repo param: <class 'generated.definitions.repository_definition.RepositoryDefinition'>
[JOB-43|DB_SYNC(APPDATA_CONTAINER-2)] 2021-03-01 13:41:40,951 INFO     [plugin_runner.py:137] Repo object: <class 'generated.definitions.repository_definition_repo_object.RepositoryDefinitionRepoObject'>
[JOB-43|DB_SYNC(APPDATA_CONTAINER-2)] 2021-03-01 13:41:41,13 INFO     [plugin_runner.py:138] Repo array: <type 'list'>
[JOB-43|DB_SYNC(APPDATA_CONTAINER-2)] 2021-03-01 13:41:41,55 INFO     [plugin_runner.py:140] Repo array item: <type 'dict'>

The overall param and the separate object param that are defined in the schema both show as being the appropriate class type. The array itself is a list as expected. However the items in the list are not objects of the class that was generated by swagger they are dictionaries. This is the same for other schemas as well. I've attached the schema definition and the class files that were generated by swagger for the repository schema.

schema_and_generated.zip