Skip to content

Commit a24c940

Browse files
authored
Merge pull request #892 from cjproud/fix-ip-field
Add IP fields to DEFAULT_FIELD_MAPPING
2 parents 2855263 + e0fc7b0 commit a24c940

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ Contributors (chronological)
8181
- Sebastien Lovergne `@TheBigRoomXXL <https://github.com/TheBigRoomXXL>`_
8282
- Luna Lovegood `@duchuyvp <https://github.com/duchuyvp>`_
8383
- Tobias Kolditz `@kolditz-senec <https://github.com/kolditz-senec>`_
84+
- Christian Proud `@cjproud <https://github.com/cjproud>`_

src/apispec/ext/marshmallow/field_converter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
marshmallow.fields.Field: (None, None),
3939
marshmallow.fields.Raw: (None, None),
4040
marshmallow.fields.List: ("array", None),
41+
marshmallow.fields.IP: ("string", "ip"),
42+
marshmallow.fields.IPv4: ("string", "ipv4"),
43+
marshmallow.fields.IPv6: ("string", "ipv6"),
4144
}
4245

4346

tests/test_ext_marshmallow_field.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def test_field2choices_preserving_order(openapi):
3232
(fields.TimeDelta, "integer"),
3333
(fields.Email, "string"),
3434
(fields.URL, "string"),
35+
(fields.IP, "string"),
36+
(fields.IPv4, "string"),
37+
(fields.IPv6, "string"),
3538
# Custom fields inherit types from their parents
3639
(CustomStringField, "string"),
3740
(CustomIntegerField, "integer"),
@@ -66,6 +69,9 @@ def test_formatted_field_translates_to_array(ListClass, spec_fixture):
6669
(fields.Date, "date"),
6770
(fields.Email, "email"),
6871
(fields.URL, "url"),
72+
(fields.IP, "ip"),
73+
(fields.IPv4, "ipv4"),
74+
(fields.IPv6, "ipv6"),
6975
],
7076
)
7177
def test_field2property_formats(FieldClass, expected_format, spec_fixture):

0 commit comments

Comments
 (0)