# argus_api.parsers package

## Submodules

## argus_api.parsers.openapi2 module

class `argus_api.parsers.openapi2.``Swagger2RequestMethod`(url: str, name: str, method: str, description: str, parameters: dict, response: list = None, errors: list = None)

  Bases: `argus_api.helpers.parsers.RequestMethod`

  Structure for a request method, allowing it to be passed to a template, create mocks for tests, or spit out defined functions

  static `from_swagger_definition`(api_url: str, endpoint_url: str, method: str, definition: dict) → argus_api.parsers.openapi2.Swagger2RequestMethod

    Creates request methods from their Swagger definitions

    Parameters: | api_url (str) – API base url endpoint_url (str) – URL to API endpoint method (str) – GET / POST / PUT / PATCH / DELETE definition (dict) – Method definition

`argus_api.parsers.openapi2.``add_endpoints`(cls, endpoints)

  Adds endpoint functions to a class, and adds bridging classes in between

  Parameters: | cls (class) – Class to add functions/classes to endpoints (dict) – Endpoints to add

`argus_api.parsers.openapi2.``flatten`(nested_list: list) → list

  Generator that flattens lists inside a list

`argus_api.parsers.openapi2.``load`(location: str) → dict

  This is the main entry point of the OpenAPI2 parser. It loads the given OpenAPI 2.0 definition, and makes sure it’s saved to disk, and that references are resolved, and javascript type names replaced with Python type names.

  It’ll then begin setting up the nested endpoint structure, and create RequestMethods for each API endpoint before loading these as templates.

  The returned structure will be a nested dict representing the paths to each endpoint, where some dicts (the actual endpoints) will contain keys with metadata such as [“__METADATA__”][“__MODULE_NAME__”] and other useful data.

  It’s up to the application to make use of these endpoints, e.g call nested_dict_structure_to_class_structure(endpoints), or whatever else you may want to do with these.

  If the endpoint structure has been loaded previously, the already loaded structure will be returned.

`argus_api.parsers.openapi2.``recursively_flatten_properties`(schema, recursion_limit=100)

  Recursively flattens all ‘properties’ keys in the schema, to avoid unnecessary and unwanted nesting

  Parameters: | schema – Any value it comes across while recursing

`argus_api.parsers.openapi2.``recursively_replace_types_with_pythonic_types`(schema, recursion_limit: int = 100)

  Recurses through a nested dict, looking for keys ‘type’, and ‘format’. The “format” key will be removed as it’s superfluous, and the “type” key will have its value replaced with the Python equivalent of that type.

  Parameters: | schema (dict) – Will be the root dictionary at the start recursion_limit (int) – Limits recursion to avoid maximum recursion depth

`argus_api.parsers.openapi2.``recursively_resolve_references`(reference: jsonschema.validators.RefResolver, value, recursion_limit: int = 10)

  Recursively iterates through the swagger schema and resolves JSON references

  Parameters: | reference (RefResolver) – A RefResolver object used to resolve references value – Any value it comes across - starting with the schema object root
  Returns: |

## Module contents