diff --git a/fuzz_lightyear/fuzzer.py b/fuzz_lightyear/fuzzer.py index ecbc394..f60f416 100644 --- a/fuzz_lightyear/fuzzer.py +++ b/fuzz_lightyear/fuzzer.py @@ -11,7 +11,6 @@ from .datastore import get_user_defined_mapping from .output.logging import log -from .supplements.abstraction import get_abstraction def fuzz_parameters( @@ -19,8 +18,6 @@ def fuzz_parameters( ) -> SearchStrategy: output = {} for name, parameter in parameters: - parameter = _deref(parameter) - output[name] = _fuzz_parameter(parameter) return st.fixed_dictionaries(output) @@ -46,7 +43,6 @@ def _fuzz_parameter( }, } """ - parameter = _deref(parameter) required = parameter.get('required', required) strategy = None @@ -158,8 +154,6 @@ def _fuzz_object( # TODO: Handle `additionalProperties` output = {} for name, specification in parameter['properties'].items(): - specification = _deref(specification) - try: strategy = _get_strategy_from_factory(specification['type'], name) except KeyError: @@ -188,13 +182,6 @@ def _fuzz_object( return st.fixed_dictionaries(output) -def _deref(parameter: Dict[str, Any]) -> Dict[str, Any]: - while '$ref' in parameter: - parameter = _get_model_definition(parameter['$ref']) - - return parameter - - def _get_strategy_from_factory( expected_type: str, name: Optional[str] = None, @@ -217,17 +204,3 @@ def type_cast(): return output return st.builds(type_cast) - - -def _get_model_definition( - reference: str, -) -> Dict[str, Any]: - """ - :param reference: e.g. '#/defintions/{ModelName}' - """ - # TODO: Handle multiple files? - try: - model_name = reference.split('/')[-1] - return get_abstraction().client.swagger_spec.definitions[model_name]._model_spec - except (IndexError, KeyError): # pragma: no cover - raise SwaggerValidationError(f'Failed to get model: {reference}') diff --git a/fuzz_lightyear/main.py b/fuzz_lightyear/main.py index 54ece6f..a819b7b 100644 --- a/fuzz_lightyear/main.py +++ b/fuzz_lightyear/main.py @@ -54,10 +54,11 @@ def setup_client( return None try: + config = {'internally_dereference_refs': True} if not schema: - client = SwaggerClient.from_url(url) + client = SwaggerClient.from_url(url, config=config) else: - client = SwaggerClient.from_spec(schema, origin_url=url) + client = SwaggerClient.from_spec(schema, origin_url=url, config=config) except requests.exceptions.ConnectionError: return 'Unable to connect to server.' except (