Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AleksandrLiber opened this issue Mar 2, 2021 · 0 comments

Comments

@AleksandrLiber
Copy link
Contributor

AleksandrLiber commented Mar 2, 2021

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

@AleksandrLiber AleksandrLiber changed the title Complex array items in a schema are passed in as dict not the generated class. Complex array items in a schema are provided as dict not the generated array object class. Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants