Use isinstance function instead of type comparison for checking the type of the value in the utility functions `value_to_schema` and `limit_example_size`. As suggested by flake8.
- Remove false positives because of EOL characters
- First character would always be a digit before as we were handling the int representation of the character
- Add a bigger weight to the HAR extension
- Fix the ASCII detection by removing EOL characters
- Fix the first character detection that was not working because would compare with an int
- Add a pattern to detect Firefox export
Improves the consistency of indentations, reformat comments, and updates the passive voice used in function requests_to_headers and mitmproxy2swagger_e2e_test to active voice.
This adds 2 new command line flags:
- `-r`, `--param-regex`: Allows the user to customize what path segment
value will be considered as a parameter.
- `s`, `--suppress-params`: Only outputs the "templated" path with the
parameter variables, but not the originals with the actual parameters.
Previously, the resulting regex was incorrect, as the
newly introduced control characters (when handling
path parameters) were also escaped. This caused
paths with parameters to not be generated.
Also removes an effect-less `for` loop.
File ".local/lib/python3.10/site-packages/mitmproxy2swagger/mitmproxy2swagger.py", line 172, in main
response_json = json.loads(response_body)
File "/usr/lib/python3.10/json/__init__.py", line 341, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
File "mitmproxy2swagger/mitmproxy2swagger.py", line 151, in main
body_val = json.loads(f.get_request_body())
File "/usr/lib/python3.10/json/__init__.py", line 341, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 144: invalid start byte