Skip to content

Commit 73effeb

Browse files
committed
feat: time string format support
1 parent 670d1dd commit 73effeb

2 files changed

Lines changed: 100 additions & 98 deletions

File tree

src/openapi_parser/enumeration.py

Lines changed: 88 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -3,146 +3,147 @@
33

44
@unique
55
class DataType(Enum):
6-
NULL = 'null'
7-
INTEGER = 'integer'
8-
NUMBER = 'number'
9-
STRING = 'string'
10-
BOOLEAN = 'boolean'
11-
ARRAY = 'array'
12-
OBJECT = 'object'
13-
ONE_OF = 'oneOf'
14-
ANY_OF = 'anyOf'
6+
NULL = "null"
7+
INTEGER = "integer"
8+
NUMBER = "number"
9+
STRING = "string"
10+
BOOLEAN = "boolean"
11+
ARRAY = "array"
12+
OBJECT = "object"
13+
ONE_OF = "oneOf"
14+
ANY_OF = "anyOf"
1515

1616

1717
@unique
1818
class IntegerFormat(Enum):
19-
INT32 = 'int32'
20-
INT64 = 'int64'
19+
INT32 = "int32"
20+
INT64 = "int64"
2121

2222

2323
@unique
2424
class NumberFormat(Enum):
25-
FLOAT = 'float'
26-
DOUBLE = 'double'
25+
FLOAT = "float"
26+
DOUBLE = "double"
2727

2828

2929
@unique
3030
class StringFormat(Enum):
31-
BYTE = 'byte'
32-
BINARY = 'binary'
33-
DATE = 'date'
34-
DATETIME = 'date-time'
35-
PASSWORD = 'password'
36-
UUID = 'uuid'
37-
UUID4 = 'uuid4'
38-
EMAIL = 'email'
39-
URI = 'uri'
40-
HOSTNAME = 'hostname'
41-
IPV4 = 'ipv4'
42-
IPV6 = 'ipv6'
43-
URL = 'url'
31+
BYTE = "byte"
32+
BINARY = "binary"
33+
DATE = "date"
34+
DATETIME = "date-time"
35+
PASSWORD = "password"
36+
UUID = "uuid"
37+
UUID4 = "uuid4"
38+
EMAIL = "email"
39+
URI = "uri"
40+
HOSTNAME = "hostname"
41+
IPV4 = "ipv4"
42+
IPV6 = "ipv6"
43+
URL = "url"
44+
TIME = "time"
4445

4546

4647
@unique
4748
class OperationMethod(Enum):
48-
GET = 'get'
49-
PUT = 'put'
50-
POST = 'post'
51-
DELETE = 'delete'
52-
OPTIONS = 'options'
53-
HEAD = 'head'
54-
PATCH = 'patch'
55-
TRACE = 'trace'
49+
GET = "get"
50+
PUT = "put"
51+
POST = "post"
52+
DELETE = "delete"
53+
OPTIONS = "options"
54+
HEAD = "head"
55+
PATCH = "patch"
56+
TRACE = "trace"
5657

5758

5859
@unique
5960
class BaseLocation(Enum):
60-
HEADER = 'header'
61-
QUERY = 'query'
62-
COOKIE = 'cookie'
61+
HEADER = "header"
62+
QUERY = "query"
63+
COOKIE = "cookie"
6364

6465

6566
@unique
6667
class ParameterLocation(Enum):
67-
HEADER = 'header'
68-
QUERY = 'query'
69-
COOKIE = 'cookie'
70-
PATH = 'path'
68+
HEADER = "header"
69+
QUERY = "query"
70+
COOKIE = "cookie"
71+
PATH = "path"
7172

7273

7374
@unique
7475
class PathParameterStyle(Enum):
75-
SIMPLE = 'simple'
76-
LABEL = 'label'
77-
MATRIX = 'matrix'
76+
SIMPLE = "simple"
77+
LABEL = "label"
78+
MATRIX = "matrix"
7879

7980

8081
@unique
8182
class QueryParameterStyle(Enum):
82-
FORM = 'form'
83-
SPACE_DELIMITED = 'spaceDelimited'
84-
PIPE_DELIMITED = 'pipeDelimited'
85-
DEEP_OBJECT = 'deepObject'
83+
FORM = "form"
84+
SPACE_DELIMITED = "spaceDelimited"
85+
PIPE_DELIMITED = "pipeDelimited"
86+
DEEP_OBJECT = "deepObject"
8687

8788

8889
@unique
8990
class HeaderParameterStyle(Enum):
90-
SIMPLE = 'simple'
91+
SIMPLE = "simple"
9192

9293

9394
@unique
9495
class CookieParameterStyle(Enum):
95-
FORM = 'form'
96+
FORM = "form"
9697

9798

9899
@unique
99100
class ContentType(Enum):
100-
JSON = 'application/json'
101-
JSON_TEXT = 'text/json'
102-
JSON_ANY = 'application/*+json'
103-
JSON_PROBLEM = 'application/problem+json'
104-
XML = 'application/xml'
105-
FORM = 'application/x-www-form-urlencoded'
106-
MULTIPART_FORM = 'multipart/form-data'
107-
PLAIN_TEXT = 'text/plain'
108-
HTML = 'text/html'
109-
PDF = 'application/pdf'
110-
PNG = 'image/png'
111-
JPEG = 'image/jpeg'
112-
GIF = 'image/gif'
113-
SVG = 'image/svg+xml'
114-
AVIF = 'image/avif'
115-
BMP = 'image/bmp'
116-
WEBP = 'image/webp'
117-
Image = 'image/*'
118-
BINARY = 'application/octet-stream'
101+
JSON = "application/json"
102+
JSON_TEXT = "text/json"
103+
JSON_ANY = "application/*+json"
104+
JSON_PROBLEM = "application/problem+json"
105+
XML = "application/xml"
106+
FORM = "application/x-www-form-urlencoded"
107+
MULTIPART_FORM = "multipart/form-data"
108+
PLAIN_TEXT = "text/plain"
109+
HTML = "text/html"
110+
PDF = "application/pdf"
111+
PNG = "image/png"
112+
JPEG = "image/jpeg"
113+
GIF = "image/gif"
114+
SVG = "image/svg+xml"
115+
AVIF = "image/avif"
116+
BMP = "image/bmp"
117+
WEBP = "image/webp"
118+
Image = "image/*"
119+
BINARY = "application/octet-stream"
119120

120121

121122
@unique
122123
class SecurityType(Enum):
123-
API_KEY = 'apiKey'
124-
HTTP = 'http'
125-
OAUTH2 = 'oauth2'
126-
OPEN_ID_CONNECT = 'openIdConnect'
124+
API_KEY = "apiKey"
125+
HTTP = "http"
126+
OAUTH2 = "oauth2"
127+
OPEN_ID_CONNECT = "openIdConnect"
127128

128129

129130
@unique
130131
class AuthenticationScheme(Enum):
131-
BASIC = 'basic'
132-
BEARER = 'bearer'
133-
DIGEST = 'digest'
134-
HOBA = 'hoba'
135-
MUTUAL = 'mutual'
136-
NEGOTIATE = 'negotiate'
137-
OAUTH = 'oauth'
138-
SCRAM_SHA1 = 'scram-sha-1'
139-
SCRAM_SHA256 = 'scram-sha-256'
140-
VAPID = 'vapid'
132+
BASIC = "basic"
133+
BEARER = "bearer"
134+
DIGEST = "digest"
135+
HOBA = "hoba"
136+
MUTUAL = "mutual"
137+
NEGOTIATE = "negotiate"
138+
OAUTH = "oauth"
139+
SCRAM_SHA1 = "scram-sha-1"
140+
SCRAM_SHA256 = "scram-sha-256"
141+
VAPID = "vapid"
141142

142143

143144
@unique
144145
class OAuthFlowType(Enum):
145-
IMPLICIT = 'implicit'
146-
PASSWORD = 'password'
147-
CLIENT_CREDENTIALS = 'clientCredentials'
148-
AUTHORIZATION_CODE = 'authorizationCode'
146+
IMPLICIT = "implicit"
147+
PASSWORD = "password"
148+
CLIENT_CREDENTIALS = "clientCredentials"
149+
AUTHORIZATION_CODE = "authorizationCode"

tests/test_enumeration.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313

1414

15-
@pytest.mark.parametrize(['string_value', 'expected'], data_type_provider)
15+
@pytest.mark.parametrize(["string_value", "expected"], data_type_provider)
1616
def test_data_type(string_value: str, expected: DataType) -> None:
1717
assert DataType(string_value) == expected
1818

@@ -28,7 +28,7 @@ def test_data_type_error() -> None:
2828
)
2929

3030

31-
@pytest.mark.parametrize(['string_value', 'expected'], integer_format_provider)
31+
@pytest.mark.parametrize(["string_value", "expected"], integer_format_provider)
3232
def test_integer_format(string_value: str, expected: IntegerFormat) -> None:
3333
assert IntegerFormat(string_value) == expected
3434

@@ -44,7 +44,7 @@ def test_integer_format_error() -> None:
4444
)
4545

4646

47-
@pytest.mark.parametrize(['string_value', 'expected'], number_format_provider)
47+
@pytest.mark.parametrize(["string_value", "expected"], number_format_provider)
4848
def test_number_format(string_value: str, expected: NumberFormat) -> None:
4949
assert NumberFormat(string_value) == expected
5050

@@ -67,10 +67,11 @@ def test_number_format_error() -> None:
6767
("ipv4", StringFormat.IPV4),
6868
("ipv6", StringFormat.IPV6),
6969
("url", StringFormat.URL),
70+
("time", StringFormat.TIME),
7071
)
7172

7273

73-
@pytest.mark.parametrize(['string_value', 'expected'], string_format_provider)
74+
@pytest.mark.parametrize(["string_value", "expected"], string_format_provider)
7475
def test_string_format(string_value: str, expected: StringFormat) -> None:
7576
assert StringFormat(string_value) == expected
7677

@@ -92,7 +93,7 @@ def test_string_format_error() -> None:
9293
)
9394

9495

95-
@pytest.mark.parametrize(['string_value', 'expected'], operation_method_provider)
96+
@pytest.mark.parametrize(["string_value", "expected"], operation_method_provider)
9697
def test_operation_method(string_value: str, expected: OperationMethod) -> None:
9798
assert OperationMethod(string_value) == expected
9899

@@ -109,7 +110,7 @@ def test_operation_method_error() -> None:
109110
)
110111

111112

112-
@pytest.mark.parametrize(['string_value', 'expected'], base_location_provider)
113+
@pytest.mark.parametrize(["string_value", "expected"], base_location_provider)
113114
def test_base_location(string_value: str, expected: BaseLocation) -> None:
114115
assert BaseLocation(string_value) == expected
115116

@@ -127,7 +128,7 @@ def test_base_location_error() -> None:
127128
)
128129

129130

130-
@pytest.mark.parametrize(['string_value', 'expected'], parameter_location_provider)
131+
@pytest.mark.parametrize(["string_value", "expected"], parameter_location_provider)
131132
def test_parameter_location(string_value: str, expected: ParameterLocation) -> None:
132133
assert ParameterLocation(string_value) == expected
133134

@@ -160,7 +161,7 @@ def test_parameter_location_error() -> None:
160161
)
161162

162163

163-
@pytest.mark.parametrize(['string_value', 'expected'], media_type_provider)
164+
@pytest.mark.parametrize(["string_value", "expected"], media_type_provider)
164165
def test_media_type(string_value: str, expected: ContentType) -> None:
165166
assert ContentType(string_value) == expected
166167

@@ -178,7 +179,7 @@ def test_media_type_error() -> None:
178179
)
179180

180181

181-
@pytest.mark.parametrize(['string_value', 'expected'], security_type_provider)
182+
@pytest.mark.parametrize(["string_value", "expected"], security_type_provider)
182183
def test_security_type(string_value: str, expected: SecurityType) -> None:
183184
assert SecurityType(string_value) == expected
184185

@@ -202,7 +203,7 @@ def test_security_type_error() -> None:
202203
)
203204

204205

205-
@pytest.mark.parametrize(['string_value', 'expected'], auth_schema_provider)
206+
@pytest.mark.parametrize(["string_value", "expected"], auth_schema_provider)
206207
def test_auth_schema(string_value: str, expected: AuthenticationScheme) -> None:
207208
assert AuthenticationScheme(string_value) == expected
208209

@@ -220,7 +221,7 @@ def test_auth_schema_error() -> None:
220221
)
221222

222223

223-
@pytest.mark.parametrize(['string_value', 'expected'], auth_flow_provider)
224+
@pytest.mark.parametrize(["string_value", "expected"], auth_flow_provider)
224225
def test_auth_flow(string_value: str, expected: OAuthFlowType) -> None:
225226
assert OAuthFlowType(string_value) == expected
226227

0 commit comments

Comments
 (0)