swagger-coverage 3.5.2__tar.gz → 3.6.0.post1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/MANIFEST.in +3 -1
- {swagger_coverage-3.5.2/swagger_coverage.egg-info → swagger_coverage-3.6.0.post1}/PKG-INFO +27 -12
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/README.md +25 -11
- swagger_coverage-3.6.0.post1/examples/exclusions/swagger-coverage-config-refresh.json +28 -0
- swagger_coverage-3.6.0.post1/examples/exclusions/swagger-coverage-output/localhost_8080/call-1.json +19 -0
- swagger_coverage-3.6.0.post1/examples/exclusions/swagger-coverage-output/localhost_8080/call-2.json +19 -0
- swagger_coverage-3.6.0.post1/examples/exclusions/swagger-doc-refresh.json +46 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/setup.py +2 -1
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1/swagger_coverage.egg-info}/PKG-INFO +27 -12
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/SOURCES.txt +6 -1
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/requires.txt +1 -0
- swagger_coverage-3.6.0.post1/swagger_coverage_py/docs_writers/api_doc_writer.py +22 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/reporter.py +12 -44
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/results_writers/base_schemas_manager.py +3 -10
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/bin/swagger-coverage-commandline.bat +1 -1
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-coverage-commandline-1.0-SNAPSHOT.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-coverage-commons-1.0-SNAPSHOT.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/uri.py +7 -0
- swagger_coverage-3.6.0.post1/tests/test_exclusions.py +92 -0
- swagger_coverage-3.5.2/swagger_coverage_py/docs_writers/api_doc_writer.py +0 -56
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/LICENSE +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/setup.cfg +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/dependency_links.txt +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/top_level.txt +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/__init__.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/configs.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/docs_writers/__init__.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/listener.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/request_schema_handler.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/results_writers/__init__.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/results_writers/openapi_schemas_manager.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/results_writers/swagger_schemas_manager.py +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/bin/swagger-coverage-commandline +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/btf-1.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/checker-compat-qual-2.5.5.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/checker-qual-3.12.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-codec-1.11.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-codec-1.9.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-io-2.11.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-io-2.6.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-lang3-3.12.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-lang3-3.7.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/commons-logging-1.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/error_prone_annotations-2.3.4.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/error_prone_annotations-2.7.1.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/failureaccess-1.0.1.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/freemarker-2.3.31.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/guava-28.2-android.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/guava-31.0.1-android.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/httpclient-4.5.13.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/httpclient-4.5.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/httpcore-4.4.13.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/httpcore-4.4.4.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/j2objc-annotations-1.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-annotations-2.12.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-core-2.12.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-coreutils-2.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-coreutils-equivalence-1.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-databind-2.12.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-dataformat-yaml-2.12.3.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jackson-datatype-jsr310-2.9.8.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jakarta.activation-api-1.2.1.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jakarta.validation-api-2.0.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jakarta.xml.bind-api-2.3.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jcommander-1.81.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/joda-time-2.10.5.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jopt-simple-5.0.4.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/json-patch-1.13.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/json-schema-core-1.2.14.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/json-schema-validator-2.2.14.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/jsr305-3.0.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/libphonenumber-8.11.1.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/logback-classic-1.2.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/logback-core-1.2.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/mailapi-1.6.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/msg-simple-1.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/rhino-1.7.7.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/slf4j-api-1.7.32.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/slf4j-ext-1.7.28.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/snakeyaml-1.27.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/spring-beans-5.3.7.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/spring-core-5.3.7.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/spring-jcl-5.3.7.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/spring-web-5.3.7.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-annotations-1.6.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-annotations-1.6.6.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-annotations-2.1.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-annotations-2.2.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-compat-spec-parser-1.0.54.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-compat-spec-parser-1.0.59.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-core-1.6.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-core-1.6.6.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-core-2.1.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-core-2.2.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-models-1.6.2.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-models-1.6.6.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-models-2.1.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-models-2.2.0.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-1.0.54.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-1.0.59.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-2.0.25.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-2.0.32.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-core-2.0.25.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-core-2.0.32.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v2-converter-2.0.25.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v2-converter-2.0.32.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v3-2.0.25.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v3-2.0.32.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/uri-template-0.10.jar +0 -0
- {swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/swagger-coverage-commandline/lib/validation-api-1.1.0.Final.jar +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
include swagger_coverage_py/swagger-coverage-commandline/bin/swagger-coverage-commandline
|
|
2
2
|
include swagger_coverage_py/swagger-coverage-commandline/bin/swagger-coverage-commandline.bat
|
|
3
|
-
include swagger_coverage_py/swagger-coverage-commandline/lib/*.jar
|
|
3
|
+
include swagger_coverage_py/swagger-coverage-commandline/lib/*.jar
|
|
4
|
+
recursive-include examples/exclusions *.json
|
|
5
|
+
include tests/test_exclusions.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swagger-coverage
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.6.0.post1
|
|
4
4
|
Summary: Python adapter for "swagger-coverage" tool
|
|
5
5
|
Home-page: https://github.com/JamalZeynalov/swagger-coverage-py
|
|
6
6
|
Author: Jamal Zeinalov
|
|
@@ -17,6 +17,7 @@ Requires-Dist: setuptools>=69.0.3
|
|
|
17
17
|
Requires-Dist: PyYAML>=6.0
|
|
18
18
|
Requires-Dist: python-dotenv>=0.21.0
|
|
19
19
|
Requires-Dist: rootpath==0.1.0
|
|
20
|
+
Requires-Dist: six
|
|
20
21
|
Requires-Dist: environs>=9.5.0
|
|
21
22
|
Dynamic: author
|
|
22
23
|
Dynamic: author-email
|
|
@@ -30,12 +31,14 @@ Dynamic: requires-python
|
|
|
30
31
|
Dynamic: summary
|
|
31
32
|
|
|
32
33
|

|
|
33
|
-

|
|
34
35
|
|
|
35
36
|
# swagger-coverage-py
|
|
36
37
|
|
|
37
38
|
#### This project is the adapter that allows using [swagger-coverage](https://github.com/viclovsky/swagger-coverage) tool in Python projects (PyTest+Requests).
|
|
38
39
|
|
|
40
|
+
Since version 3.6.0, the package supports [report exclusions](#report-exclusions) by path, HTTP method, and condition name.
|
|
41
|
+
|
|
39
42
|
## Original description summary:
|
|
40
43
|
|
|
41
44
|
> Swagger-coverage gives a full picture about coverage of API tests (regression) based on OAS 2 (Swagger). By saying
|
|
@@ -165,12 +168,6 @@ def setup_swagger_coverage():
|
|
|
165
168
|
],
|
|
166
169
|
"filter": []
|
|
167
170
|
},
|
|
168
|
-
"paths": {
|
|
169
|
-
"enable": true,
|
|
170
|
-
"ignore": [
|
|
171
|
-
"/user/{username}"
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
171
|
"only-declared-status": {
|
|
175
172
|
"enable": false
|
|
176
173
|
},
|
|
@@ -178,6 +175,14 @@ def setup_swagger_coverage():
|
|
|
178
175
|
"enable": true
|
|
179
176
|
}
|
|
180
177
|
},
|
|
178
|
+
"exclusions": [
|
|
179
|
+
{ "path": "^/user/\\{username\\}$" },
|
|
180
|
+
{
|
|
181
|
+
"method": "POST",
|
|
182
|
+
"path": "^/auth/user/refresh$",
|
|
183
|
+
"condition": "^HTTP status 400$"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
181
186
|
"writers": {
|
|
182
187
|
"html": {
|
|
183
188
|
"locale": "en",
|
|
@@ -186,10 +191,7 @@ def setup_swagger_coverage():
|
|
|
186
191
|
}
|
|
187
192
|
}
|
|
188
193
|
```
|
|
189
|
-
|
|
190
|
-
To do this, you need to set `enable` parameter to `true` and specify a list of endpoints (as you see them in the swagger doc) in the `ignore` section.
|
|
191
|
-
Then these endpoints will be removed from the API doc before it is saved locally.<br>
|
|
192
|
-
Note: Remove already downloaded API docs before running a new version of this lib.
|
|
194
|
+
|
|
193
195
|
|
|
194
196
|
> ### If you have more than 1 API then this config MUST:
|
|
195
197
|
> #### 1. Be created for each microservice which you track using `CoverageListener`.
|
|
@@ -198,6 +200,19 @@ Note: Remove already downloaded API docs before running a new version of this li
|
|
|
198
200
|
> #### 2. Contain `writers` section with filename in the format: `swagger-coverage-report-<api_name>.html`
|
|
199
201
|
> #### 3. Be placed in the root of your project
|
|
200
202
|
|
|
203
|
+
#### Report exclusions
|
|
204
|
+
|
|
205
|
+
Use the top-level `exclusions` list to filter operations or individual coverage conditions. Each entry accepts a Java regex for the OpenAPI `path`, an optional uppercase HTTP `method`, and a Java regex for the displayed `condition` name. At least one of `path` or `condition` is required. Regexes use substring search; anchor with `^` and `$` for an exact match.
|
|
206
|
+
|
|
207
|
+
- `{"path":"^/auth/user/refresh$"}` excludes all methods on this path, including their recorded calls, from coverage and Missed.
|
|
208
|
+
- Adding `"method":"POST"` limits the exclusion to POST.
|
|
209
|
+
- Adding `"condition":"^HTTP status 400$"` keeps the operation and call counts, excluding only that check from the numerator and denominator.
|
|
210
|
+
- `{"condition":"contains a value outside enum"}` excludes the matching condition across the API.
|
|
211
|
+
|
|
212
|
+
The [offline refresh example](https://github.com/JamalZeynalov/swagger-coverage-py/blob/v.3.6.0/examples/exclusions/swagger-coverage-config-refresh.json) excludes `HTTP status 400` and `not empty body request` for `POST /auth/user/refresh`. With the same two recorded calls, coverage changes from 3/7 to 3/5 (60%).
|
|
213
|
+
|
|
214
|
+
Legacy `rules.paths` entries with `enable: true` are converted to exact path exclusions when the analyzer reads the configuration. All HTTP methods on those paths are skipped. If an older adapter saved a specification with paths removed, fetch the full specification once to restore them.
|
|
215
|
+
|
|
201
216
|
More examples of configuration options you can find in
|
|
202
217
|
the [Configuration options](https://github.com/JamalZeynalov/swagger-coverage#configuration-options) section of the
|
|
203
218
|
documentation.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|

|
|
2
|
-

|
|
3
3
|
|
|
4
4
|
# swagger-coverage-py
|
|
5
5
|
|
|
6
6
|
#### This project is the adapter that allows using [swagger-coverage](https://github.com/viclovsky/swagger-coverage) tool in Python projects (PyTest+Requests).
|
|
7
7
|
|
|
8
|
+
Since version 3.6.0, the package supports [report exclusions](#report-exclusions) by path, HTTP method, and condition name.
|
|
9
|
+
|
|
8
10
|
## Original description summary:
|
|
9
11
|
|
|
10
12
|
> Swagger-coverage gives a full picture about coverage of API tests (regression) based on OAS 2 (Swagger). By saying
|
|
@@ -134,12 +136,6 @@ def setup_swagger_coverage():
|
|
|
134
136
|
],
|
|
135
137
|
"filter": []
|
|
136
138
|
},
|
|
137
|
-
"paths": {
|
|
138
|
-
"enable": true,
|
|
139
|
-
"ignore": [
|
|
140
|
-
"/user/{username}"
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
139
|
"only-declared-status": {
|
|
144
140
|
"enable": false
|
|
145
141
|
},
|
|
@@ -147,6 +143,14 @@ def setup_swagger_coverage():
|
|
|
147
143
|
"enable": true
|
|
148
144
|
}
|
|
149
145
|
},
|
|
146
|
+
"exclusions": [
|
|
147
|
+
{ "path": "^/user/\\{username\\}$" },
|
|
148
|
+
{
|
|
149
|
+
"method": "POST",
|
|
150
|
+
"path": "^/auth/user/refresh$",
|
|
151
|
+
"condition": "^HTTP status 400$"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
150
154
|
"writers": {
|
|
151
155
|
"html": {
|
|
152
156
|
"locale": "en",
|
|
@@ -155,10 +159,7 @@ def setup_swagger_coverage():
|
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
```
|
|
158
|
-
|
|
159
|
-
To do this, you need to set `enable` parameter to `true` and specify a list of endpoints (as you see them in the swagger doc) in the `ignore` section.
|
|
160
|
-
Then these endpoints will be removed from the API doc before it is saved locally.<br>
|
|
161
|
-
Note: Remove already downloaded API docs before running a new version of this lib.
|
|
162
|
+
|
|
162
163
|
|
|
163
164
|
> ### If you have more than 1 API then this config MUST:
|
|
164
165
|
> #### 1. Be created for each microservice which you track using `CoverageListener`.
|
|
@@ -167,6 +168,19 @@ Note: Remove already downloaded API docs before running a new version of this li
|
|
|
167
168
|
> #### 2. Contain `writers` section with filename in the format: `swagger-coverage-report-<api_name>.html`
|
|
168
169
|
> #### 3. Be placed in the root of your project
|
|
169
170
|
|
|
171
|
+
#### Report exclusions
|
|
172
|
+
|
|
173
|
+
Use the top-level `exclusions` list to filter operations or individual coverage conditions. Each entry accepts a Java regex for the OpenAPI `path`, an optional uppercase HTTP `method`, and a Java regex for the displayed `condition` name. At least one of `path` or `condition` is required. Regexes use substring search; anchor with `^` and `$` for an exact match.
|
|
174
|
+
|
|
175
|
+
- `{"path":"^/auth/user/refresh$"}` excludes all methods on this path, including their recorded calls, from coverage and Missed.
|
|
176
|
+
- Adding `"method":"POST"` limits the exclusion to POST.
|
|
177
|
+
- Adding `"condition":"^HTTP status 400$"` keeps the operation and call counts, excluding only that check from the numerator and denominator.
|
|
178
|
+
- `{"condition":"contains a value outside enum"}` excludes the matching condition across the API.
|
|
179
|
+
|
|
180
|
+
The [offline refresh example](https://github.com/JamalZeynalov/swagger-coverage-py/blob/v.3.6.0/examples/exclusions/swagger-coverage-config-refresh.json) excludes `HTTP status 400` and `not empty body request` for `POST /auth/user/refresh`. With the same two recorded calls, coverage changes from 3/7 to 3/5 (60%).
|
|
181
|
+
|
|
182
|
+
Legacy `rules.paths` entries with `enable: true` are converted to exact path exclusions when the analyzer reads the configuration. All HTTP methods on those paths are skipped. If an older adapter saved a specification with paths removed, fetch the full specification once to restore them.
|
|
183
|
+
|
|
170
184
|
More examples of configuration options you can find in
|
|
171
185
|
the [Configuration options](https://github.com/JamalZeynalov/swagger-coverage#configuration-options) section of the
|
|
172
186
|
documentation.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": {
|
|
3
|
+
"only-declared-status": {
|
|
4
|
+
"enable": false
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"exclusions": [
|
|
8
|
+
{
|
|
9
|
+
"method": "POST",
|
|
10
|
+
"path": "^/auth/user/refresh$",
|
|
11
|
+
"condition": "^HTTP status 400$"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"method": "POST",
|
|
15
|
+
"path": "^/auth/user/refresh$",
|
|
16
|
+
"condition": "^not empty body request$"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"writers": {
|
|
20
|
+
"html": {
|
|
21
|
+
"locale": "en",
|
|
22
|
+
"filename": "report.html"
|
|
23
|
+
},
|
|
24
|
+
"json": {
|
|
25
|
+
"filename": "results.json"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
swagger_coverage-3.6.0.post1/examples/exclusions/swagger-coverage-output/localhost_8080/call-1.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Synthetic refresh example",
|
|
5
|
+
"version": "1"
|
|
6
|
+
},
|
|
7
|
+
"paths": {
|
|
8
|
+
"/auth/user/refresh": {
|
|
9
|
+
"post": {
|
|
10
|
+
"parameters": [],
|
|
11
|
+
"responses": {
|
|
12
|
+
"202": {
|
|
13
|
+
"description": "Accepted"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
swagger_coverage-3.6.0.post1/examples/exclusions/swagger-coverage-output/localhost_8080/call-2.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Synthetic refresh example",
|
|
5
|
+
"version": "1"
|
|
6
|
+
},
|
|
7
|
+
"paths": {
|
|
8
|
+
"/auth/user/refresh": {
|
|
9
|
+
"post": {
|
|
10
|
+
"parameters": [],
|
|
11
|
+
"responses": {
|
|
12
|
+
"202": {
|
|
13
|
+
"description": "Accepted"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Synthetic refresh example",
|
|
5
|
+
"version": "1"
|
|
6
|
+
},
|
|
7
|
+
"paths": {
|
|
8
|
+
"/auth/user/refresh": {
|
|
9
|
+
"post": {
|
|
10
|
+
"parameters": [
|
|
11
|
+
{
|
|
12
|
+
"name": "cs_refresh_token",
|
|
13
|
+
"in": "header",
|
|
14
|
+
"schema": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Host",
|
|
20
|
+
"in": "header",
|
|
21
|
+
"schema": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"requestBody": {
|
|
27
|
+
"content": {
|
|
28
|
+
"application/json": {
|
|
29
|
+
"schema": {
|
|
30
|
+
"type": "object"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"responses": {
|
|
36
|
+
"202": {
|
|
37
|
+
"description": "Accepted"
|
|
38
|
+
},
|
|
39
|
+
"400": {
|
|
40
|
+
"description": "Bad request"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="swagger-coverage",
|
|
8
|
-
version="3.
|
|
8
|
+
version="3.6.0.post1",
|
|
9
9
|
author="Jamal Zeinalov",
|
|
10
10
|
author_email="jamal.zeynalov@gmail.com",
|
|
11
11
|
description='Python adapter for "swagger-coverage" tool',
|
|
@@ -25,6 +25,7 @@ setup(
|
|
|
25
25
|
"PyYAML>=6.0",
|
|
26
26
|
"python-dotenv>=0.21.0",
|
|
27
27
|
"rootpath==0.1.0",
|
|
28
|
+
"six",
|
|
28
29
|
"environs>=9.5.0",
|
|
29
30
|
],
|
|
30
31
|
python_requires=">=3.6",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swagger-coverage
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.6.0.post1
|
|
4
4
|
Summary: Python adapter for "swagger-coverage" tool
|
|
5
5
|
Home-page: https://github.com/JamalZeynalov/swagger-coverage-py
|
|
6
6
|
Author: Jamal Zeinalov
|
|
@@ -17,6 +17,7 @@ Requires-Dist: setuptools>=69.0.3
|
|
|
17
17
|
Requires-Dist: PyYAML>=6.0
|
|
18
18
|
Requires-Dist: python-dotenv>=0.21.0
|
|
19
19
|
Requires-Dist: rootpath==0.1.0
|
|
20
|
+
Requires-Dist: six
|
|
20
21
|
Requires-Dist: environs>=9.5.0
|
|
21
22
|
Dynamic: author
|
|
22
23
|
Dynamic: author-email
|
|
@@ -30,12 +31,14 @@ Dynamic: requires-python
|
|
|
30
31
|
Dynamic: summary
|
|
31
32
|
|
|
32
33
|

|
|
33
|
-

|
|
34
35
|
|
|
35
36
|
# swagger-coverage-py
|
|
36
37
|
|
|
37
38
|
#### This project is the adapter that allows using [swagger-coverage](https://github.com/viclovsky/swagger-coverage) tool in Python projects (PyTest+Requests).
|
|
38
39
|
|
|
40
|
+
Since version 3.6.0, the package supports [report exclusions](#report-exclusions) by path, HTTP method, and condition name.
|
|
41
|
+
|
|
39
42
|
## Original description summary:
|
|
40
43
|
|
|
41
44
|
> Swagger-coverage gives a full picture about coverage of API tests (regression) based on OAS 2 (Swagger). By saying
|
|
@@ -165,12 +168,6 @@ def setup_swagger_coverage():
|
|
|
165
168
|
],
|
|
166
169
|
"filter": []
|
|
167
170
|
},
|
|
168
|
-
"paths": {
|
|
169
|
-
"enable": true,
|
|
170
|
-
"ignore": [
|
|
171
|
-
"/user/{username}"
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
171
|
"only-declared-status": {
|
|
175
172
|
"enable": false
|
|
176
173
|
},
|
|
@@ -178,6 +175,14 @@ def setup_swagger_coverage():
|
|
|
178
175
|
"enable": true
|
|
179
176
|
}
|
|
180
177
|
},
|
|
178
|
+
"exclusions": [
|
|
179
|
+
{ "path": "^/user/\\{username\\}$" },
|
|
180
|
+
{
|
|
181
|
+
"method": "POST",
|
|
182
|
+
"path": "^/auth/user/refresh$",
|
|
183
|
+
"condition": "^HTTP status 400$"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
181
186
|
"writers": {
|
|
182
187
|
"html": {
|
|
183
188
|
"locale": "en",
|
|
@@ -186,10 +191,7 @@ def setup_swagger_coverage():
|
|
|
186
191
|
}
|
|
187
192
|
}
|
|
188
193
|
```
|
|
189
|
-
|
|
190
|
-
To do this, you need to set `enable` parameter to `true` and specify a list of endpoints (as you see them in the swagger doc) in the `ignore` section.
|
|
191
|
-
Then these endpoints will be removed from the API doc before it is saved locally.<br>
|
|
192
|
-
Note: Remove already downloaded API docs before running a new version of this lib.
|
|
194
|
+
|
|
193
195
|
|
|
194
196
|
> ### If you have more than 1 API then this config MUST:
|
|
195
197
|
> #### 1. Be created for each microservice which you track using `CoverageListener`.
|
|
@@ -198,6 +200,19 @@ Note: Remove already downloaded API docs before running a new version of this li
|
|
|
198
200
|
> #### 2. Contain `writers` section with filename in the format: `swagger-coverage-report-<api_name>.html`
|
|
199
201
|
> #### 3. Be placed in the root of your project
|
|
200
202
|
|
|
203
|
+
#### Report exclusions
|
|
204
|
+
|
|
205
|
+
Use the top-level `exclusions` list to filter operations or individual coverage conditions. Each entry accepts a Java regex for the OpenAPI `path`, an optional uppercase HTTP `method`, and a Java regex for the displayed `condition` name. At least one of `path` or `condition` is required. Regexes use substring search; anchor with `^` and `$` for an exact match.
|
|
206
|
+
|
|
207
|
+
- `{"path":"^/auth/user/refresh$"}` excludes all methods on this path, including their recorded calls, from coverage and Missed.
|
|
208
|
+
- Adding `"method":"POST"` limits the exclusion to POST.
|
|
209
|
+
- Adding `"condition":"^HTTP status 400$"` keeps the operation and call counts, excluding only that check from the numerator and denominator.
|
|
210
|
+
- `{"condition":"contains a value outside enum"}` excludes the matching condition across the API.
|
|
211
|
+
|
|
212
|
+
The [offline refresh example](https://github.com/JamalZeynalov/swagger-coverage-py/blob/v.3.6.0/examples/exclusions/swagger-coverage-config-refresh.json) excludes `HTTP status 400` and `not empty body request` for `POST /auth/user/refresh`. With the same two recorded calls, coverage changes from 3/7 to 3/5 (60%).
|
|
213
|
+
|
|
214
|
+
Legacy `rules.paths` entries with `enable: true` are converted to exact path exclusions when the analyzer reads the configuration. All HTTP methods on those paths are skipped. If an older adapter saved a specification with paths removed, fetch the full specification once to restore them.
|
|
215
|
+
|
|
201
216
|
More examples of configuration options you can find in
|
|
202
217
|
the [Configuration options](https://github.com/JamalZeynalov/swagger-coverage#configuration-options) section of the
|
|
203
218
|
documentation.
|
{swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/SOURCES.txt
RENAMED
|
@@ -2,6 +2,10 @@ LICENSE
|
|
|
2
2
|
MANIFEST.in
|
|
3
3
|
README.md
|
|
4
4
|
setup.py
|
|
5
|
+
examples/exclusions/swagger-coverage-config-refresh.json
|
|
6
|
+
examples/exclusions/swagger-doc-refresh.json
|
|
7
|
+
examples/exclusions/swagger-coverage-output/localhost_8080/call-1.json
|
|
8
|
+
examples/exclusions/swagger-coverage-output/localhost_8080/call-2.json
|
|
5
9
|
swagger_coverage.egg-info/PKG-INFO
|
|
6
10
|
swagger_coverage.egg-info/SOURCES.txt
|
|
7
11
|
swagger_coverage.egg-info/dependency_links.txt
|
|
@@ -100,4 +104,5 @@ swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v2-converter
|
|
|
100
104
|
swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v3-2.0.25.jar
|
|
101
105
|
swagger_coverage_py/swagger-coverage-commandline/lib/swagger-parser-v3-2.0.32.jar
|
|
102
106
|
swagger_coverage_py/swagger-coverage-commandline/lib/uri-template-0.10.jar
|
|
103
|
-
swagger_coverage_py/swagger-coverage-commandline/lib/validation-api-1.1.0.Final.jar
|
|
107
|
+
swagger_coverage_py/swagger-coverage-commandline/lib/validation-api-1.1.0.Final.jar
|
|
108
|
+
tests/test_exclusions.py
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
from swagger_coverage_py.configs import API_DOCS_FORMAT, API_DOCS_TYPE
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def write_api_doc_to_file(file_path: str, api_doc_data: requests.Response):
|
|
10
|
+
if API_DOCS_FORMAT == "json":
|
|
11
|
+
data = api_doc_data.json()
|
|
12
|
+
else:
|
|
13
|
+
data = yaml.safe_load(api_doc_data.text)
|
|
14
|
+
|
|
15
|
+
if API_DOCS_TYPE == "swagger" and not data.get("swagger"):
|
|
16
|
+
data["swagger"] = "2.0"
|
|
17
|
+
|
|
18
|
+
with open(file_path, "w") as file:
|
|
19
|
+
if API_DOCS_FORMAT == "json":
|
|
20
|
+
json.dump(data, file)
|
|
21
|
+
else:
|
|
22
|
+
yaml.safe_dump(data, file, indent=4, sort_keys=False)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import json
|
|
2
1
|
import os
|
|
3
2
|
import platform
|
|
4
|
-
import re
|
|
5
3
|
import shutil
|
|
6
4
|
import subprocess
|
|
7
5
|
from pathlib import Path
|
|
8
|
-
from typing import List
|
|
9
6
|
|
|
10
7
|
import requests
|
|
11
8
|
|
|
12
9
|
from swagger_coverage_py.configs import API_DOCS_FORMAT, DEBUG_MODE
|
|
13
10
|
from swagger_coverage_py.docs_writers.api_doc_writer import write_api_doc_to_file
|
|
11
|
+
from swagger_coverage_py.uri import coverage_output_dir
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class CoverageReporter:
|
|
@@ -18,33 +16,8 @@ class CoverageReporter:
|
|
|
18
16
|
self.host = host
|
|
19
17
|
self.verify = verify
|
|
20
18
|
self.swagger_doc_file = f"swagger-doc-{api_name}.{API_DOCS_FORMAT}"
|
|
21
|
-
self.output_dir =
|
|
19
|
+
self.output_dir = coverage_output_dir(host)
|
|
22
20
|
self.swagger_coverage_config = f"swagger-coverage-config-{api_name}.json"
|
|
23
|
-
self.ignored_paths = self.__get_ignored_paths_from_config()
|
|
24
|
-
|
|
25
|
-
def __get_output_dir(self):
|
|
26
|
-
output_dir = "swagger-coverage-output"
|
|
27
|
-
subdir = re.match(r"(^\w*)://(.*)", self.host).group(2)
|
|
28
|
-
if "/" in subdir:
|
|
29
|
-
subdir = subdir.replace("/", "-")
|
|
30
|
-
return f"{output_dir}/{subdir}"
|
|
31
|
-
|
|
32
|
-
def __get_ignored_paths_from_config(self) -> List[str]:
|
|
33
|
-
"""Reads the swagger-coverage-config-<api_name>.json file and returns
|
|
34
|
-
a list of endpoints/paths to exclude from the report
|
|
35
|
-
|
|
36
|
-
"""
|
|
37
|
-
paths_to_ignore = []
|
|
38
|
-
if not self.swagger_coverage_config:
|
|
39
|
-
return paths_to_ignore
|
|
40
|
-
|
|
41
|
-
with open(self.swagger_coverage_config, "r") as file:
|
|
42
|
-
data = json.load(file)
|
|
43
|
-
paths = data.get("rules").get("paths", {})
|
|
44
|
-
if paths.get("enable", False):
|
|
45
|
-
paths_to_ignore = paths.get("ignore")
|
|
46
|
-
|
|
47
|
-
return paths_to_ignore
|
|
48
21
|
|
|
49
22
|
def setup(
|
|
50
23
|
self, path_to_swagger_json: str, auth: object = None, cookies: dict = None
|
|
@@ -70,32 +43,27 @@ class CoverageReporter:
|
|
|
70
43
|
write_api_doc_to_file(
|
|
71
44
|
self.swagger_doc_file,
|
|
72
45
|
api_doc_data=response,
|
|
73
|
-
paths_to_delete=self.ignored_paths,
|
|
74
46
|
)
|
|
75
47
|
|
|
76
48
|
def generate_report(self):
|
|
77
|
-
|
|
49
|
+
script_name = "swagger-coverage-commandline"
|
|
50
|
+
if platform.system() == "Windows":
|
|
51
|
+
script_name += ".bat"
|
|
52
|
+
cmd_path = Path(__file__).parent / "swagger-coverage-commandline" / "bin" / script_name
|
|
53
|
+
assert cmd_path.exists(), f"No commandline tool found at {cmd_path}"
|
|
78
54
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
).exists(), (
|
|
83
|
-
f"No commandline tools is found in following locations:\n{cmd_path}\n"
|
|
84
|
-
)
|
|
85
|
-
command = [cmd_path, "-s", self.swagger_doc_file, "-i", self.output_dir]
|
|
55
|
+
spec = Path(self.swagger_doc_file)
|
|
56
|
+
spec_arg = spec.as_uri() if spec.is_absolute() else self.swagger_doc_file
|
|
57
|
+
command = [str(cmd_path), "-s", spec_arg, "-i", self.output_dir]
|
|
86
58
|
if self.swagger_coverage_config:
|
|
87
59
|
command.extend(["-c", self.swagger_coverage_config])
|
|
88
60
|
|
|
89
|
-
# Adjust the file paths for Windows
|
|
90
|
-
if platform.system() == "Windows":
|
|
91
|
-
command = [arg.replace("/", "\\") for arg in command]
|
|
92
|
-
|
|
93
61
|
# Suppress all output if not in debug mode
|
|
94
62
|
if not DEBUG_MODE:
|
|
95
63
|
with open(os.devnull, "w") as devnull:
|
|
96
|
-
subprocess.run(command, stdout=devnull, stderr=devnull)
|
|
64
|
+
subprocess.run(command, stdout=devnull, stderr=devnull, check=True)
|
|
97
65
|
else:
|
|
98
|
-
subprocess.run(command)
|
|
66
|
+
subprocess.run(command, check=True)
|
|
99
67
|
|
|
100
68
|
def cleanup_input_files(self):
|
|
101
69
|
shutil.rmtree(self.output_dir, ignore_errors=True)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
import platform
|
|
4
|
-
import re
|
|
5
4
|
import urllib
|
|
6
5
|
|
|
7
6
|
import yaml
|
|
@@ -9,7 +8,7 @@ from faker import Faker
|
|
|
9
8
|
from requests import Response
|
|
10
9
|
|
|
11
10
|
from swagger_coverage_py.configs import API_DOCS_FORMAT
|
|
12
|
-
from swagger_coverage_py.uri import URI
|
|
11
|
+
from swagger_coverage_py.uri import URI, coverage_output_dir
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class ApiDocsManagerBase:
|
|
@@ -55,7 +54,7 @@ class ApiDocsManagerBase:
|
|
|
55
54
|
value = urllib.parse.unquote(str(v))
|
|
56
55
|
else:
|
|
57
56
|
value = v
|
|
58
|
-
properties[k] = {
|
|
57
|
+
properties[k] = {"example": value, "type": value_type}
|
|
59
58
|
|
|
60
59
|
request_body: dict = {
|
|
61
60
|
"content": {
|
|
@@ -127,19 +126,13 @@ class ApiDocsManagerBase:
|
|
|
127
126
|
def _get_header_params(self) -> list:
|
|
128
127
|
return self._get_other_request_params(params_key="headers", params_in="header")
|
|
129
128
|
|
|
130
|
-
def __get_output_subdir(self):
|
|
131
|
-
subdir = re.match(r"(^\w*)://(.*)", self._uri.host).group(2)
|
|
132
|
-
if "/" in subdir:
|
|
133
|
-
subdir = subdir.replace("/", "-")
|
|
134
|
-
return subdir
|
|
135
|
-
|
|
136
129
|
def write_schema(self):
|
|
137
130
|
schema_dict = self._get_schema()
|
|
138
131
|
rnd = Faker().pystr(min_chars=5, max_chars=5)
|
|
139
132
|
file_name = f"{self._method.upper()} {self._uri.formatted[1::]}".replace(
|
|
140
133
|
"/", "-"
|
|
141
134
|
).replace(":", "_")
|
|
142
|
-
path_ =
|
|
135
|
+
path_ = coverage_output_dir(self._uri.host)
|
|
143
136
|
file_path = f"{path_}/{file_name}".split("?")[0]
|
|
144
137
|
file_path = f"{file_path} ({rnd}).{API_DOCS_FORMAT}"
|
|
145
138
|
|
|
@@ -68,7 +68,7 @@ goto fail
|
|
|
68
68
|
:execute
|
|
69
69
|
@rem Setup the command line
|
|
70
70
|
|
|
71
|
-
set CLASSPATH=%APP_HOME%\lib\swagger-coverage-commandline-1.0-SNAPSHOT.jar
|
|
71
|
+
set "CLASSPATH=%APP_HOME%\lib\swagger-coverage-commandline-1.0-SNAPSHOT.jar"
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
@rem Execute swagger-coverage-commandline
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
def coverage_output_dir(host: str) -> str:
|
|
2
|
+
_, url = host.split("://", 1)
|
|
3
|
+
authority, separator, path = url.partition("/")
|
|
4
|
+
subdir = (authority.replace(":", "_") + separator + path).replace("/", "-")
|
|
5
|
+
return f"swagger-coverage-output/{subdir}"
|
|
6
|
+
|
|
7
|
+
|
|
1
8
|
class URI:
|
|
2
9
|
def __init__(self, host: str, base_path, unformatted_path: str, **uri_params):
|
|
3
10
|
self.host = host
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Offline integration tests for the Java analyzer shipped by the adapter."""
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
from swagger_coverage_py.reporter import CoverageReporter
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
EXAMPLE = Path(__file__).resolve().parents[1] / "examples" / "exclusions"
|
|
13
|
+
REFRESH = "/auth/user/refresh"
|
|
14
|
+
EXACT = "^/auth/user/refresh$"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ReportExclusionsTest(unittest.TestCase):
|
|
18
|
+
def setUp(self):
|
|
19
|
+
directory = tempfile.TemporaryDirectory()
|
|
20
|
+
self.addCleanup(directory.cleanup)
|
|
21
|
+
self.root = Path(directory.name)
|
|
22
|
+
self.spec = json.loads((EXAMPLE / "swagger-doc-refresh.json").read_text(encoding="utf-8"))
|
|
23
|
+
self.config = json.loads((EXAMPLE / "swagger-coverage-config-refresh.json").read_text(encoding="utf-8"))
|
|
24
|
+
self.inputs = self.root / "records"
|
|
25
|
+
shutil.copytree(EXAMPLE / "swagger-coverage-output/localhost_8080", self.inputs)
|
|
26
|
+
self.reporter = CoverageReporter("refresh", "http://localhost:8080")
|
|
27
|
+
self.reporter.output_dir = str(self.inputs)
|
|
28
|
+
self.reporter.swagger_doc_file = str(self.root / "spec.json")
|
|
29
|
+
self.reporter.swagger_coverage_config = str(self.root / "config.json")
|
|
30
|
+
self.config["writers"] = {"json": {"filename": str(self.root / "result.json")}}
|
|
31
|
+
|
|
32
|
+
def generate(self):
|
|
33
|
+
config_path = Path(self.reporter.swagger_coverage_config)
|
|
34
|
+
config = json.dumps(self.config)
|
|
35
|
+
config_path.write_text(config)
|
|
36
|
+
Path(self.reporter.swagger_doc_file).write_text(json.dumps(self.spec))
|
|
37
|
+
self.reporter.generate_report()
|
|
38
|
+
self.assertEqual(config_path.read_text(encoding="utf-8"), config)
|
|
39
|
+
return json.loads((self.root / "result.json").read_text(encoding="utf-8"))
|
|
40
|
+
|
|
41
|
+
def add_call(self, method, path):
|
|
42
|
+
data = json.loads((self.inputs / "call-1.json").read_text(encoding="utf-8"))
|
|
43
|
+
operation = data["paths"][REFRESH]["post"]
|
|
44
|
+
data["paths"] = {path: {method: operation}}
|
|
45
|
+
(self.inputs / (method + ".json")).write_text(json.dumps(data))
|
|
46
|
+
|
|
47
|
+
def test_condition_exclusions(self):
|
|
48
|
+
result = self.generate()
|
|
49
|
+
op = result["operations"][REFRESH + " POST"]
|
|
50
|
+
self.assertEqual((op["coveredConditionCount"], op["allConditionCount"], op["processCount"]), (3, 5, 2))
|
|
51
|
+
self.assertEqual(result["conditionCounter"]["all"], 5)
|
|
52
|
+
self.assertTrue({"HTTP status 400", "not empty body request"}.isdisjoint(c["name"] for c in op["conditions"]))
|
|
53
|
+
|
|
54
|
+
def test_path_and_method_exclusions(self):
|
|
55
|
+
self.spec["paths"][REFRESH]["get"] = {"responses": {"202": {"description": "Accepted"}}}
|
|
56
|
+
self.add_call("get", REFRESH)
|
|
57
|
+
self.add_call("delete", REFRESH)
|
|
58
|
+
self.add_call("patch", "/unrelated")
|
|
59
|
+
self.config["exclusions"] = [{"path": EXACT}]
|
|
60
|
+
result = self.generate()
|
|
61
|
+
self.assertFalse(result["operations"])
|
|
62
|
+
self.assertFalse(result["flatOperations"])
|
|
63
|
+
self.assertEqual(set(result["missed"]), {"/unrelated PATCH"})
|
|
64
|
+
self.assertEqual(result["conditionCounter"]["all"], 0)
|
|
65
|
+
self.config["exclusions"][0]["method"] = "POST"
|
|
66
|
+
result = self.generate()
|
|
67
|
+
self.assertEqual(set(result["operations"]), {REFRESH + " GET"})
|
|
68
|
+
self.assertIn(REFRESH + " DELETE", result["missed"])
|
|
69
|
+
|
|
70
|
+
def test_legacy_paths_are_literal_and_combine_with_new_rules(self):
|
|
71
|
+
template = "/api.v1/{id}"
|
|
72
|
+
self.spec["paths"][template] = self.spec["paths"][REFRESH]
|
|
73
|
+
self.spec["paths"]["/apiXv1/{id}"] = self.spec["paths"][REFRESH]
|
|
74
|
+
self.add_call("delete", "/api.v1/123")
|
|
75
|
+
self.config["rules"]["paths"] = {"enable": True, "ignore": [template]}
|
|
76
|
+
result = self.generate()
|
|
77
|
+
self.assertNotIn(template + " POST", result["operations"])
|
|
78
|
+
self.assertFalse(result["missed"])
|
|
79
|
+
self.assertIn("/apiXv1/{id} POST", result["operations"])
|
|
80
|
+
self.assertEqual(result["operations"][REFRESH + " POST"]["allConditionCount"], 5)
|
|
81
|
+
for enable in [False, None]:
|
|
82
|
+
self.config["rules"]["paths"] = {"ignore": [template]}
|
|
83
|
+
if enable is not None:
|
|
84
|
+
self.config["rules"]["paths"]["enable"] = enable
|
|
85
|
+
self.assertIn(template + " POST", self.generate()["operations"])
|
|
86
|
+
|
|
87
|
+
def test_invalid_or_empty_exclusion_is_rejected(self):
|
|
88
|
+
for rule in [{}, {"path": "["}, {"condition": ""}]:
|
|
89
|
+
with self.subTest(rule=rule):
|
|
90
|
+
self.config["exclusions"] = [rule]
|
|
91
|
+
with self.assertRaises(subprocess.CalledProcessError):
|
|
92
|
+
self.generate()
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
|
|
3
|
-
import requests
|
|
4
|
-
import yaml
|
|
5
|
-
|
|
6
|
-
from swagger_coverage_py.configs import API_DOCS_FORMAT, API_DOCS_TYPE
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def __delete_ignored_paths_from_json(
|
|
10
|
-
api_doc_data: requests.Response, paths_to_delete: list
|
|
11
|
-
) -> dict:
|
|
12
|
-
data: dict = api_doc_data.json()
|
|
13
|
-
for path in paths_to_delete:
|
|
14
|
-
if path in data["paths"]:
|
|
15
|
-
del data["paths"][path]
|
|
16
|
-
return data
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def __delete_ignored_paths_from_yaml(
|
|
20
|
-
api_doc_data: requests.Response, paths_to_delete: list
|
|
21
|
-
) -> dict:
|
|
22
|
-
data: dict = yaml.safe_load(str(api_doc_data.text))
|
|
23
|
-
for path in paths_to_delete:
|
|
24
|
-
if path in data["paths"]:
|
|
25
|
-
del data["paths"][path]
|
|
26
|
-
return data
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def __write_api_doc_to_json(
|
|
30
|
-
file_path: str, api_doc_data: requests.Response, paths_to_delete: list
|
|
31
|
-
):
|
|
32
|
-
api_doc_data = __delete_ignored_paths_from_json(api_doc_data, paths_to_delete)
|
|
33
|
-
if API_DOCS_TYPE == "swagger" and not api_doc_data.get("swagger", None):
|
|
34
|
-
api_doc_data["swagger"] = "2.0"
|
|
35
|
-
|
|
36
|
-
with open(file_path, "w+") as file:
|
|
37
|
-
file.write(json.dumps(api_doc_data))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def __write_api_doc_to_yaml(
|
|
41
|
-
file_path: str, api_doc_data: requests.Response, paths_to_delete: list
|
|
42
|
-
):
|
|
43
|
-
data = __delete_ignored_paths_from_yaml(api_doc_data, paths_to_delete)
|
|
44
|
-
|
|
45
|
-
if API_DOCS_TYPE == "swagger" and not data.get("swagger", None):
|
|
46
|
-
data["swagger"] = "2.0"
|
|
47
|
-
|
|
48
|
-
with open(file_path, "w+") as file:
|
|
49
|
-
file.write(yaml.safe_dump(data, indent=4, sort_keys=False))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def write_api_doc_to_file(file_path: str, api_doc_data: dict, paths_to_delete: list):
|
|
53
|
-
if API_DOCS_FORMAT == "json":
|
|
54
|
-
__write_api_doc_to_json(file_path, api_doc_data, paths_to_delete)
|
|
55
|
-
else:
|
|
56
|
-
__write_api_doc_to_yaml(file_path, api_doc_data, paths_to_delete)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{swagger_coverage-3.5.2 → swagger_coverage-3.6.0.post1}/swagger_coverage_py/docs_writers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|