 # Takes 'resolved items' and generates JSON Schema for their wrapper array
 # *Element* node.
 buildArrayRepr = (context, cb) ->
-  buildItemsRepr context, (err, itemsRepr) ->
+  buildArrayItemsRepr context, (err, itemsRepr) ->
     return cb err if err
 
     repr = type: 'array'

async = require 'async'
inspect = require '../inspect'
{coerceLiteral} = require '../jsonutils'
{resolveType} = require '../typeresolution'


# Turns multiple *Element* nodes into 'resolved elements', i.e. objects
# carrying both representation in JSON Schema and optionally also
# some additional info.
#
# The implementation of such resolution is to be provided in the
# *resolveElement* argument in form of an asynchronous function with
# following signature:
#
#     (element, inherited, cb) -> ...
#
resolveElements = (elements, resolveElement, inherited, cb) ->
  async.map elements, (element, next) ->
    resolveElement element, inherited, next
  , cb


# Turns *Element* node containing object property into a 'resolved property'

handleObjectElement = (objectElement, resolvedType, inherited, cb) ->
  fixed = inspect.isOrInheritsFixed objectElement, inherited
  heritage = inspect.getHeritage fixed

  async.waterfall [
    (next) -> resolveProperties objectElement, heritage, next
    (resolvedProps, next) -> buildObjectRepr {resolvedProps, fixed}, next
  ], cb


# Turns *Element* node containing array or enum item into a 'resolved item'
# object with both representation in JSON and optionally also
# some additional info.
resolveItem = (item, inherited, cb) ->
