Skip to content

Commit cba42bb

Browse files
committed
Init cleanup
1 parent b506ab2 commit cba42bb

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

openapi_spec_validator/__init__.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,20 @@
1313
__url__ = 'https://github.com/p1c2u/openapi-spec-validator'
1414
__license__ = 'Apache License, Version 2.0'
1515

16-
__all__ = ['openapi_v3_validator', 'validate_spec', 'validate_spec_url']
16+
__all__ = [
17+
'openapi_v2_spec_validator', 'openapi_v3_spec_validator',
18+
'validate_v2_spec', 'validate_v3_spec', 'validate_spec',
19+
'validate_v2_spec_url', 'validate_v3_spec_url', 'validate_spec_url',
20+
]
1721

1822
default_handlers = {
1923
'<all_urls>': UrlHandler('http', 'https', 'file'),
2024
'http': UrlHandler('http'),
2125
'https': UrlHandler('https'),
2226
'file': UrlHandler('file'),
2327
}
24-
schema_v3, schema_v3_url = get_openapi_schema('3.0.0')
25-
openapi_v3_validator_factory = JSONSpecValidatorFactory(
26-
schema_v3, schema_v3_url,
27-
resolver_handlers=default_handlers,
28-
)
29-
openapi_v3_spec_validator = SpecValidator(
30-
openapi_v3_validator_factory,
31-
resolver_handlers=default_handlers,
32-
)
3328

29+
# v2.0 spec
3430
schema_v2, schema_v2_url = get_openapi_schema('2.0')
3531
openapi_v2_validator_factory = JSONSpecValidatorFactory(
3632
schema_v2, schema_v2_url,
@@ -41,11 +37,26 @@
4137
resolver_handlers=default_handlers,
4238
)
4339

40+
# v3.0.0 spec
41+
schema_v3, schema_v3_url = get_openapi_schema('3.0.0')
42+
openapi_v3_validator_factory = JSONSpecValidatorFactory(
43+
schema_v3, schema_v3_url,
44+
resolver_handlers=default_handlers,
45+
)
46+
openapi_v3_spec_validator = SpecValidator(
47+
openapi_v3_validator_factory,
48+
resolver_handlers=default_handlers,
49+
)
50+
4451
# shortcuts
4552
validate_v2_spec = validate_spec_factory(openapi_v2_spec_validator.validate)
4653
validate_v2_spec_url = validate_spec_url_factory(
4754
openapi_v2_spec_validator.validate, default_handlers)
4855

49-
validate_spec = validate_spec_factory(openapi_v3_spec_validator.validate)
50-
validate_spec_url = validate_spec_url_factory(
56+
validate_v3_spec = validate_spec_factory(openapi_v3_spec_validator.validate)
57+
validate_v3_spec_url = validate_spec_url_factory(
5158
openapi_v3_spec_validator.validate, default_handlers)
59+
60+
# aliases to the latest version
61+
validate_spec = validate_v3_spec
62+
validate_spec_url = validate_v3_spec_url

0 commit comments

Comments
 (0)