Repository: hh-h/aiohttp-swagger3

Issue:
Custom string formats
Hello!
 
In our project we need to validate some string formats, which are not represented in aiohhtp-swagger3, like a IPv4Network (192.168.100.0/24). Specification [says](https://swagger.io/specification/?sbsearch=String#dataTypeFormat), that custom formats may be used even though undefined by this specification.

Discussion:
deepcode-ci-bot[bot]: ## DeepCode failed to analyze this pull request
Something went wrong despite trying multiple times, sorry about that.
Please comment this pull request with "Retry DeepCode" to manually retry, or [contact us](https://www.deepcode.ai/feedback?select=4&utm_source=gh_review) so that a human can look into the issue.

codecov[bot]: # [Codecov](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=h1) Report
> Merging [#52](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=desc) into [master](https://codecov.io/gh/hh-h/aiohttp-swagger3/commit/a4a0a383cceacf93fe611d2285fdec0a15201bcd&el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52/graphs/tree.svg?width=650&height=150&src=pr&token=vsUkD2f5wc)](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master      #52   +/-   ##
=======================================
  Coverage   98.77%   98.78%           
=======================================
  Files          11       11           
  Lines        1147     1150    +3     
=======================================
+ Hits         1133     1136    +3     
  Misses         14       14           
```


| [Impacted Files](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [aiohttp\_swagger3/\_\_init\_\_.py](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52/diff?src=pr&el=tree#diff-YWlvaHR0cF9zd2FnZ2VyMy9fX2luaXRfXy5weQ==) | `100.00% <100.00%> (ø)` | |
| [aiohttp\_swagger3/validators.py](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52/diff?src=pr&el=tree#diff-YWlvaHR0cF9zd2FnZ2VyMy92YWxpZGF0b3JzLnB5) | `98.25% <100.00%> (+<0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=footer). Last update [a4a0a38...4b0fbc7](https://codecov.io/gh/hh-h/aiohttp-swagger3/pull/52?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

hh-h: Retry DeepCode

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index a2e38bd..9b803cc 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,11 @@
 Changelog
 =========
 
+0.4.1 (09-03-2020)
+------------------
+
+- allow for unknown string formats. Closes `#51 <https://github.com/hh-h/aiohttp-swagger3/issues/51>`_
+
 0.4.0 (07-03-2020)
 ------------------
 
diff --git a/aiohttp_swagger3/__init__.py b/aiohttp_swagger3/__init__.py
index 21e7e4b..099fbec 100644
--- a/aiohttp_swagger3/__init__.py
+++ b/aiohttp_swagger3/__init__.py
@@ -7,7 +7,7 @@ __all__ = (
     "SwaggerUiSettings",
     "__version__",
 )
-__version__ = "0.4.0"
+__version__ = "0.4.1"
 __author__ = "Valetov Konstantin"
 
 from .swagger_docs import SwaggerDocs
diff --git a/aiohttp_swagger3/validators.py b/aiohttp_swagger3/validators.py
index ed205cc..3befab2 100644
--- a/aiohttp_swagger3/validators.py
+++ b/aiohttp_swagger3/validators.py
@@ -65,6 +65,10 @@ class StringFormat(enum.Enum):
     IPv4 = "ipv4"
     IPv6 = "ipv6"
 
+    @classmethod
+    def _missing_(cls, value: object) -> "StringFormat":
+        return StringFormat.Default
+
 
 @attr.attrs(slots=True, frozen=True, eq=False, hash=False, auto_attribs=True)
 class Integer(Validator):


Test patch:
diff --git a/tests/test_docs_queries.py b/tests/test_docs_queries.py
index d1b3a29..11a429d 100644
--- a/tests/test_docs_queries.py
+++ b/tests/test_docs_queries.py
@@ -680,3 +680,27 @@ async def test_wrong_item_in_array(swagger_docs, aiohttp_client):
     assert resp.status == 400
     error = error_to_json(await resp.text())
     assert error == {"array": {"1": "value should be type of int"}}
+
+
+async def test_unknown_string_format(swagger_docs, aiohttp_client):
+    async def handler(request):
+        """
+        ---
+        parameters:
+
+          - name: array
+            in: query
+            required: true
+            schema:
+              type: string
+              format: something_unknown
+
+        responses:
+          '200':
+            description: OK.
+
+        """
+        return web.json_response()
+
+    swagger = swagger_docs()
+    swagger.add_route("GET", "/r", handler)