Skip to content

Commit ae19cfe

Browse files
committed
Added Openapi2 aka Swagger support
1 parent ab9beb5 commit ae19cfe

File tree

5 files changed

+1791
-1
lines changed

5 files changed

+1791
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## About
1111

12-
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the [OpenAPI 3.0.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) specification. The validator aims to check for full compliance with the Specification.
12+
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the [OpenAPI 2.0 (aka Swagger](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and [OpenAPI 3.0.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) specification. The validator aims to check for full compliance with the Specification.
1313

1414
## Installation
1515

openapi_spec_validator/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,22 @@
3030
openapi_v3_validator_factory,
3131
resolver_handlers=default_handlers,
3232
)
33+
34+
schema_v2, schema_v2_url = get_openapi_schema('2.0')
35+
openapi_v2_validator_factory = JSONSpecValidatorFactory(
36+
schema_v2, schema_v2_url,
37+
resolver_handlers=default_handlers,
38+
)
39+
openapi_v2_spec_validator = SpecValidator(
40+
openapi_v2_validator_factory,
41+
resolver_handlers=default_handlers,
42+
)
43+
3344
# shortcuts
45+
validate_v2_spec = validate_spec_factory(openapi_v2_spec_validator.validate)
46+
validate_v2_spec_url = validate_spec_url_factory(
47+
openapi_v2_spec_validator.validate, default_handlers)
48+
3449
validate_spec = validate_spec_factory(openapi_v3_spec_validator.validate)
3550
validate_spec_url = validate_spec_url_factory(
3651
openapi_v3_spec_validator.validate, default_handlers)

0 commit comments

Comments
 (0)