@@ -33,6 +33,13 @@ Installation
3333
3434 $ pip install openapi-spec-validator
3535
36+ Alternatively you can download the code and install from the repository:
37+
38+ .. code-block :: bash
39+
40+ $ pip install -e git+https://github.com/p1c2u/openapi-spec-validator.git#egg=openapi_spec_validator
41+
42+
3643 Usage
3744#####
3845
@@ -43,25 +50,25 @@ Straight forward way:
4350
4451.. code :: bash
4552
46- $ openapi-spec-validator some .yaml
53+ $ openapi-spec-validator openapi .yaml
4754
4855 pipes way:
4956
5057.. code :: bash
5158
52- $ cat some .yaml | openapi-spec-validator -
59+ $ cat openapi .yaml | openapi-spec-validator -
5360
5461 docker way:
5562
5663.. code :: bash
5764
58- $ docker run -v path/to/some .yaml:/some .yaml --rm p1c2u/openapi-spec-validator /some .yaml
65+ $ docker run -v path/to/openapi .yaml:/openapi .yaml --rm p1c2u/openapi-spec-validator /openapi .yaml
5966
6067 or more pythonic way:
6168
6269.. code :: bash
6370
64- $ python -m openapi_spec_validator some .yaml
71+ $ python -m openapi_spec_validator openapi .yaml
6572
6673 Examples
6774********
@@ -70,34 +77,39 @@ Validate spec:
7077
7178.. code :: python
7279
73-
7480 from openapi_spec_validator import validate_spec
81+ from openapi_spec_validator.readers import read_from_filename
82+
83+ spec_dict, spec_url = read_from_filename(' openapi.yaml' )
7584
85+ # If no exception is raised by validate_spec(), the spec is valid.
7686 validate_spec(spec_dict)
7787
78- Add `` spec_url `` to validate spec with relative files:
88+ validate_spec({})
7989
80- .. code :: python
90+ Traceback (most recent call last):
91+ ...
92+ OpenAPIValidationError: ' openapi' is a required property
8193
94+ Add ``spec_url `` to validate spec with relative files:
8295
83- from openapi_spec_validator import validate_spec
96+ .. code :: python
8497
8598 validate_spec(spec_dict, spec_url = ' file:///path/to/spec/openapi.yaml' )
8699
87100 You can also validate spec from url:
88101
89102.. code :: python
90103
91-
92104 from openapi_spec_validator import validate_spec_url
93105
106+ # If no exception is raised by validate_spec_url(), the spec is valid.
94107 validate_spec_url(' http://example.com/openapi.json' )
95108
96109 If you want to iterate through validation errors:
97110
98111.. code :: python
99112
100-
101113 from openapi_spec_validator import openapi_v3_spec_validator
102114
103115 errors_iterator = openapi_v3_spec_validator.iter_errors(spec)
0 commit comments