     # Here, we treat non-JSON-pointer fragments (such as "#user") as aliases.
     if schema.id && schema.id.indexOf("#") == 0
       uri = URI.resolve scope, schema.id
+      schema.id = uri
       @register uri, schema
 
     if @test_type "object", schema



  constructor: (schemas...) ->
    @references = {}
    @media_types = {}
    @tests = {}
    @unresolved = {}

        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(schema, context)

  register: (uri, schema) ->
    @uris[uri] = schema
    if media_type = schema.mediaType
      if media_type != "application/json"
        @media_types[media_type] = schema

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