   cb null, props
 
 
+# Turns property node into a 'resolved property' object with both
+# representation in JSON Schema and also additional info, such as property
+# name, attributes, etc.
 resolveProperty = (prop, options, cb) ->
   async.waterfall [
     (next) -> handleType prop.content, options, next

  ], cb


handleArray = (arrayType, simpleTypeSpec, options, cb) ->
  cb null, type: 'array'


handlePrimitiveType = (primitiveType, simpleTypeSpec, options, cb) ->
  cb null, type: simpleTypeSpec.name


handleType = (type, options, cb) ->
  resolveType type, (err, simpleTypeSpec) ->
    return cb err if err

        handlePrimitiveType type, simpleTypeSpec, options, cb


# Adds JSON Schema declaration to given schema object.
addSchemaDeclaration = (schema, cb) ->
  schema["$schema"] = "http://json-schema.org/draft-04/schema#"
  cb null, schema


# Transforms given MSON AST into JSON Schema.
transform = (ast, options, cb) ->
  async.waterfall [
    (next) -> handleType ast, options, next
