Skip to content

Commit c9c4177

Browse files
authored
Merge pull request #39 from moisesbenzan/fix/add-uri-string-format
Fix: Typo on multipart form content type and adds URI field to StringFormat
2 parents 1e98f7c + 6cd6ec9 commit c9c4177

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

src/openapi_parser/enumeration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class StringFormat(Enum):
3333
PASSWORD = 'password'
3434
UUID = 'uuid'
3535
EMAIL = 'email'
36+
URI = 'uri'
3637

3738

3839
@unique
@@ -67,7 +68,7 @@ class ContentType(Enum):
6768
JSON = 'application/json'
6869
XML = 'application/xml'
6970
FORM = 'application/x-www-form-urlencoded'
70-
MULTIPART_FORM = 'multipart_form/form-data'
71+
MULTIPART_FORM = 'multipart/form-data'
7172
PLAIN_TEXT = 'text/plain'
7273
HTML = 'text/html'
7374
PDF = 'application/pdf'

tests/data/swagger.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ components:
248248
- required:
249249
- login
250250
- email
251+
- avatar
251252
- properties:
252253
login:
253254
type: string
@@ -258,3 +259,8 @@ components:
258259
format: email
259260
example: 'user@mail.com'
260261
description: 'User E-mail address'
262+
avatar:
263+
type: string
264+
format : uri
265+
example: 'https://github.com/manchenkoff/openapi3-parser'
266+
description: 'User Avatar URL'

tests/openapi_fixture.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
schema_user = Object(
44
type=DataType.OBJECT,
5-
required=["uuid", "login", "email"],
5+
required=["uuid", "login", "email", "avatar"],
66
properties=[
77
Property(
88
name="uuid",
@@ -30,6 +30,15 @@
3030
format=StringFormat.EMAIL,
3131
)
3232
),
33+
Property(
34+
name="avatar",
35+
schema=String(
36+
type=DataType.STRING,
37+
description="User Avatar URL",
38+
example="https://github.com/manchenkoff/openapi3-parser",
39+
format=StringFormat.URI,
40+
)
41+
),
3342
],
3443
)
3544

@@ -222,7 +231,7 @@ def create_specification() -> Specification:
222231
),
223232
"User": Object(
224233
type=DataType.OBJECT,
225-
required=["uuid", "login", "email"],
234+
required=["uuid", "login", "email", "avatar"],
226235
properties=[
227236
Property(
228237
name="uuid",
@@ -250,6 +259,15 @@ def create_specification() -> Specification:
250259
description="User E-mail address",
251260
)
252261
),
262+
Property(
263+
name="avatar",
264+
schema=String(
265+
type=DataType.STRING,
266+
description="User Avatar URL",
267+
example="https://github.com/manchenkoff/openapi3-parser",
268+
format=StringFormat.URI,
269+
)
270+
),
253271
],
254272
)
255273
}

tests/test_enumeration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_number_format_error() -> None:
6262
("password", StringFormat.PASSWORD),
6363
("uuid", StringFormat.UUID),
6464
("email", StringFormat.EMAIL),
65+
("uri", StringFormat.URI),
6566
)
6667

6768

@@ -136,7 +137,7 @@ def test_parameter_location_error() -> None:
136137
("application/json", ContentType.JSON),
137138
("application/xml", ContentType.XML),
138139
("application/x-www-form-urlencoded", ContentType.FORM),
139-
("multipart_form/form-data", ContentType.MULTIPART_FORM),
140+
("multipart/form-data", ContentType.MULTIPART_FORM),
140141
("text/plain", ContentType.PLAIN_TEXT),
141142
("text/html", ContentType.HTML),
142143
("application/pdf", ContentType.PDF),

0 commit comments

Comments
 (0)