@@ -25,54 +25,61 @@ against the `OpenAPI 2.0 (aka Swagger)
25
25
and `OpenAPI 3.1 <https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md >`__
26
26
specification. The validator aims to check for full compliance with the Specification.
27
27
28
+
29
+ Documentation
30
+ #############
31
+
32
+ Check documentation to see more details about the features. All documentation is in the "docs" directory and online at `openapi-spec-validator.readthedocs.io <https://openapi-spec-validator.readthedocs.io >`__
33
+
34
+
28
35
Installation
29
36
############
30
37
31
- ::
38
+ .. code-block :: console
32
39
33
- $ pip install openapi-spec-validator
40
+ pip install openapi-spec-validator
34
41
35
42
Alternatively you can download the code and install from the repository:
36
43
37
44
.. code-block :: bash
38
45
39
- $ pip install -e git+https://github.com/p1c2u/openapi-spec-validator.git#egg=openapi_spec_validator
46
+ pip install -e git+https://github.com/p1c2u/openapi-spec-validator.git#egg=openapi_spec_validator
40
47
41
48
42
49
Usage
43
50
#####
44
51
45
- Command Line Interface
46
- **********************
52
+ CLI ( Command Line Interface)
53
+ ****************************
47
54
48
55
Straight forward way:
49
56
50
- .. code :: bash
57
+ .. code-block :: bash
51
58
52
- $ openapi-spec-validator openapi.yaml
59
+ openapi-spec-validator openapi.yaml
53
60
54
61
pipes way:
55
62
56
- .. code :: bash
63
+ .. code-block :: bash
57
64
58
- $ cat openapi.yaml | openapi-spec-validator -
65
+ cat openapi.yaml | openapi-spec-validator -
59
66
60
67
docker way:
61
68
62
- .. code :: bash
69
+ .. code-block :: bash
63
70
64
- $ docker run -v path/to/openapi.yaml:/openapi.yaml --rm p1c2u/openapi-spec-validator /openapi.yaml
71
+ docker run -v path/to/openapi.yaml:/openapi.yaml --rm p1c2u/openapi-spec-validator /openapi.yaml
65
72
66
73
or more pythonic way:
67
74
68
- .. code :: bash
75
+ .. code-block :: bash
69
76
70
- $ python -m openapi_spec_validator openapi.yaml
77
+ python -m openapi_spec_validator openapi.yaml
71
78
72
- Examples
73
- ********
79
+ For more details, read about `CLI (Command Line Interface) <https://openapi-spec-validator.readthedocs.io/en/latest/cli.html >`__.
74
80
75
- By default, OpenAPI spec version is detected. To validate spec:
81
+ Python package
82
+ **************
76
83
77
84
.. code :: python
78
85
@@ -89,53 +96,18 @@ By default, OpenAPI spec version is detected. To validate spec:
89
96
Traceback (most recent call last):
90
97
...
91
98
OpenAPIValidationError: ' info' is a required property
92
-
93
- Add ``spec_url `` to validate spec with relative files:
94
-
95
- .. code :: python
96
-
97
- validate_spec(spec_dict, spec_url = ' file:///path/to/spec/openapi.yaml' )
98
-
99
- You can also validate spec from url:
100
-
101
- .. code :: python
102
-
103
- from openapi_spec_validator import validate_spec_url
104
-
105
- # If no exception is raised by validate_spec_url(), the spec is valid.
106
- validate_spec_url(' http://example.com/openapi.json' )
107
-
108
- In order to explicitly validate a:
109
-
110
- * Swagger / OpenAPI 2.0 spec, import ``openapi_v2_spec_validator ``
111
- * OpenAPI 3.0 spec, import ``openapi_v30_spec_validator ``
112
- * OpenAPI 3.1 spec, import ``openapi_v31_spec_validator ``
113
-
114
- and pass the validator to ``validate_spec `` or ``validate_spec_url `` function:
115
-
116
- .. code :: python
117
-
118
- validate_spec(spec_dict, validator = openapi_v31_spec_validator)
119
-
120
- You can also explicitly import ``openapi_v3_spec_validator `` which is a shortcut to the latest v3 release.
121
-
122
- If you want to iterate through validation errors:
123
-
124
- .. code :: python
125
-
126
- from openapi_spec_validator import openapi_v3_spec_validator
127
99
128
- errors_iterator = openapi_v3_spec_validator.iter_errors( spec)
100
+ For more details, read about ` Python package < https://openapi- spec-validator.readthedocs.io/en/latest/python.html >`__.
129
101
130
102
Related projects
131
103
################
132
104
133
105
* `openapi-core <https://github.com/p1c2u/openapi-core >`__
134
- Python library that adds client-side and server-side support for the OpenAPI.
106
+ Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification .
135
107
* `openapi-schema-validator <https://github.com/p1c2u/openapi-schema-validator >`__
136
- Python library that validates schema against the OpenAPI Schema Specification v3.0.
108
+ Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1 .
137
109
138
110
License
139
111
#######
140
112
141
- Copyright (c) 2017-2022 , Artur Maciag, All rights reserved. Apache v2
113
+ Copyright (c) 2017-2023 , Artur Maciag, All rights reserved. Apache v2
0 commit comments