Skip to content

Commit 3b9010e

Browse files
authored
fix(config): rename access_token to api_key, add first-class scope kwargs (#45)
* fix(config): rename access_token to api_key, add first-class scope kwargs * fix(config): drop access_token, make api_key a plain attribute
1 parent d3806b6 commit 3b9010e

3 files changed

Lines changed: 871 additions & 0 deletions

File tree

.github/workflows/regenerate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
-i openapi.yaml \
3939
-g python \
4040
-o . \
41+
-t .openapi-generator-templates \
4142
--additional-properties=packageName=hotdata,projectName=hotdata \
4243
--skip-validate-spec
4344
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Mustache template override
2+
3+
Two Hotdata-specific DX tweaks applied to the Python `configuration.mustache`:
4+
5+
1. **`api_key` is the bearer token** — matching Hotdata's docs and CLI
6+
(`--api-key`, `HOTDATA_API_KEY`). Stock openapi-generator calls the
7+
bearer token `access_token`; we drop that name entirely and replace it
8+
with `api_key`. Internal `auth_settings()` is patched to read
9+
`self.api_key`.
10+
11+
2. **`workspace_id` and `session_id` are first-class kwargs and
12+
attributes.** Stock openapi-generator exposes apiKey security schemes
13+
only via an opaque `api_key: Dict[str, str]` dict keyed by scheme name.
14+
That's a footgun — callers have to know the generator's
15+
`apiKey`-security machinery to set a workspace scope. The template
16+
adds typed `workspace_id` / `session_id` kwargs (and properties) that
17+
store into a renamed `self.api_keys` dict.
18+
19+
Net caller DX:
20+
21+
```python
22+
cfg = hotdata.Configuration(
23+
api_key="sk_live_...",
24+
workspace_id="ws_abc",
25+
session_id="sb_xyz",
26+
)
27+
```
28+
29+
## Drift tripwire
30+
31+
The regenerate workflow runs `import hotdata` and relies on
32+
`openapi-generator` 7.20.0 (pinned in `openapitools.json`). If a future
33+
release renames the mustache vars our patch references (`authMethods`,
34+
`isApiKey`, `isBasicBearer`, `isOAuth`, `name`, `keyParamName`), the
35+
import will fail and the regen PR will be obviously broken rather than
36+
shipping subtly wrong code.
37+
38+
Bumping the pinned generator version should include a diff of this
39+
template against upstream's
40+
`modules/openapi-generator/src/main/resources/python/configuration.mustache`.

0 commit comments

Comments
 (0)