def _example_from_array_spec(self, prop_spec):
        """Get an example from a property specification of an array.

        Args:
            prop_spec: property specification you want an example of.

        Returns:
            An example array.
        """
        # if items is a list, then each item has its own spec
        if isinstance(prop_spec['items'], list):
            return [self.get_example_from_prop_spec(item_prop_spec) for item_prop_spec in prop_spec['items']]
        # Standard types in array
        elif 'type' in prop_spec['items'].keys():
            if 'format' in prop_spec['items'].keys() and prop_spec['items']['format'] == 'date-time':
                return self._get_example_from_basic_type('datetime')
            else:
                return self._get_example_from_basic_type(prop_spec['items']['type'])

        # Array with definition
        elif ('$ref' in prop_spec['items'].keys() or
              ('schema' in prop_spec and'$ref' in prop_spec['schema']['items'].keys())):
            # Get value from definition
            definition_name = self.get_definition_name_from_ref(prop_spec['items']['$ref']) or \
                self.get_definition_name_from_ref(prop_spec['schema']['items']['$ref'])
            if self.build_one_definition_example(definition_name):
                example_dict = self.definitions_example[definition_name]
                if not isinstance(example_dict, dict):
                    return [example_dict]
                if len(example_dict) == 1:
                    try:  # Python 2.7
                        res = example_dict[example_dict.keys()[0]]
                    except TypeError:  # Python 3
                        res = example_dict[list(example_dict)[0]]
                    return res

                else:
                    return_value = {}
                    for example_name, example_value in example_dict.items():
                        return_value[example_name] = example_value
                    return [return_value]
        elif 'properties' in prop_spec['items']:
            prop_example = {}
            for prop_name, prop_spec in prop_spec['items']['properties'].items():
                example = self.get_example_from_prop_spec(prop_spec)
                if example is not None:
                    prop_example[prop_name] = example
            return [prop_example]
def _example_from_array_spec ( self , prop_spec ) : if isinstance ( prop_spec [ 'items' ] , list ) : return [ self . get_example_from_prop_spec ( item_prop_spec ) for item_prop_spec in prop_spec [ 'items' ] ] elif 'type' in prop_spec [ 'items' ] . keys ( ) : if 'format' in prop_spec [ 'items' ] . keys ( ) and prop_spec [ 'items' ] [ 'format' ] == 'date-time' : return self . _get_example_from_basic_type ( 'datetime' ) else : return self . _get_example_from_basic_type ( prop_spec [ 'items' ] [ 'type' ] ) elif ( '$ref' in prop_spec [ 'items' ] . keys ( ) or ( 'schema' in prop_spec and '$ref' in prop_spec [ 'schema' ] [ 'items' ] . keys ( ) ) ) : definition_name = self . get_definition_name_from_ref ( prop_spec [ 'items' ] [ '$ref' ] ) or self . get_definition_name_from_ref ( prop_spec [ 'schema' ] [ 'items' ] [ '$ref' ] ) if self . build_one_definition_example ( definition_name ) : example_dict = self . definitions_example [ definition_name ] if not isinstance ( example_dict , dict ) : return [ example_dict ] if len ( example_dict ) == 1 : try : res = example_dict [ example_dict . keys ( ) [ 0 ] ] except TypeError : res = example_dict [ list ( example_dict ) [ 0 ] ] return res else : return_value = { } for example_name , example_value in example_dict . items ( ) : return_value [ example_name ] = example_value return [ return_value ] elif 'properties' in prop_spec [ 'items' ] : prop_example = { } for prop_name , prop_spec in prop_spec [ 'items' ] [ 'properties' ] . items ( ) : example = self . get_example_from_prop_spec ( prop_spec ) if example is not None : prop_example [ prop_name ] = example return [ prop_example ]
Get an example from a property specification of an array.

        Args:
            prop_spec: property specification you want an example of.

        Returns:
            An example array.