# Buggy code
def get_endpoint_by_reference(self, reference: str) -> Endpoint:
    """Get local or external `Endpoint` instance by reference.

    Reference example: #/paths/~1users~1{user_id}/patch
    """
    scope, data = self.resolver.resolve(reference)
    path, method = scope.rsplit("/", maxsplit=2)[-2:]
    path = path.replace("~1", "/").replace("~0", "~")
    full_path = self.get_full_path(path)
    resolved_definition = self.resolver.resolve_all(data)
    parent_ref, _ = reference.rsplit("/", maxsplit=1)
    _, methods = self.resolver.resolve(parent_ref)
    common_parameters = get_common_parameters(methods)
    parameters = itertools.chain(
        resolved_definition.get("parameters", ()), common_parameters
    )
    raw_definition = EndpointDefinition(data, scope)
    return self.make_endpoint(
        full_path, method, parameters, resolved_definition, raw_definition
    )


# Traceback (KeyError)
An internal error happened during a test run
Error: Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/schemathesis/runner/__init__.py", line 245, in execute_from_schema
yield from runner.execute()
File "/usr/local/lib/python3.8/site-packages/schemathesis/runner/impl/core.py", line 100, in execute
for event in self._execute(results):
File "/usr/local/lib/python3.8/site-packages/schemathesis/runner/impl/solo.py", line 19, in _execute
yield from self._run_tests(
File "/usr/local/lib/python3.8/site-packages/schemathesis/runner/impl/core.py", line 126, in _run_tests
for endpoint, test in maker(template, settings, seed):
File "/usr/local/lib/python3.8/site-packages/schemathesis/schemas.py", line 79, in get_all_tests
test = make_test_or_exception(endpoint, func, settings, seed)
File "/usr/local/lib/python3.8/site-packages/schemathesis/_hypothesis.py", line 45, in make_test_or_exception
return create_test(endpoint, func, settings, seed=seed)
File "/usr/local/lib/python3.8/site-packages/schemathesis/_hypothesis.py", line 30, in create_test
strategy = endpoint.as_strategy(hooks=hook_dispatcher)
File "/usr/local/lib/python3.8/site-packages/schemathesis/models.py", line 285, in as_strategy
return get_case_strategy(self, hooks)
File "/usr/local/lib/python3.8/site-packages/schemathesis/_hypothesis.py", line 153, in get_case_strategy
parameter, value, endpoint.get_hypothesis_conversions(location)
File "/usr/local/lib/python3.8/site-packages/schemathesis/models.py", line 291, in get_hypothesis_conversions
definitions = [item for item in self.definition.raw.get("parameters", []) if item["in"] == location]
File "/usr/local/lib/python3.8/site-packages/schemathesis/models.py", line 291, in <listcomp>
definitions = [item for item in self.definition.raw.get("parameters", []) if item["in"] == location]
KeyError: 'in'

# Fixed code
def get_endpoint_by_reference(self, reference: str) -> Endpoint:
    """Get local or external `Endpoint` instance by reference.

    Reference example: #/paths/~1users~1{user_id}/patch
    """
    scope, data = self.resolver.resolve(reference)
    path, method = scope.rsplit("/", maxsplit=2)[-2:]
    path = path.replace("~1", "/").replace("~0", "~")
    full_path = self.get_full_path(path)
    resolved_definition = self.resolver.resolve_all(data)
    parent_ref, _ = reference.rsplit("/", maxsplit=1)
    _, methods = self.resolver.resolve(parent_ref)
    common_parameters = get_common_parameters(methods)
    parameters = itertools.chain(
        resolved_definition.get("parameters", ()), common_parameters
    )
    raw_definition = EndpointDefinition(data, resolved_definition, scope)
    return self.make_endpoint(
        full_path, method, parameters, resolved_definition, raw_definition
    )