           schema
       else
         throw new Error "No schema found for '#{JSON.stringify(arg)}'"
+
 
     # Find a registered schema.
     #

        pointer: schema.id || "#"
        scope: schema.id || "#"

      # Make an initial pass over the schema looking for $ref fields,
      # recording their targets for use in actual compilation.
      @compile_references context, schema

      # We try a second time to resolve $ref values, because a schema may have
      # been defined after we initially tried to resolve a $ref.
      for ref, {scope, uri} of @unresolved
        if (found_schema = @resolve_uri(uri, scope))?
          delete @unresolved[ref]
          @register ref, found_schema
      if Object.keys(@unresolved).length > 0
        pointers = (uri for key, {uri} of @unresolved)
        throw new Error "Unresolvable $ref values: #{JSON.stringify pointers}"

      @compile(context, schema)

    register: (uri, schema) ->
      @uris[uri] = schema
      # TODO: enforce uniqueness of types
      if (media_type = schema.mediaType)?
        if media_type != "application/json"
          @media_types[media_type] = schema

    validate: (data) ->
      @validator("#").validate(data)

          if "$ref" == attribute
            @resolve_reference(context, schema, definition)
          else
            @reference_container context.child(attribute), definition

    resolve_reference: (context, schema, definition) ->
      {scope, pointer} = context
