GeezerVison is showing github.com — feat(codegen): prototype generating request classes from the OpenAPI spec by dargmuesli · Pull Request #486 · spotify-web-api-java/spotify-web-api-java
Conversation
dargmuesli
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Draft / prototype. This is step 5 of the plan discussed in #461. It is stacked on #485, so the diff shows only the codegen commit. The intended destination is v11 on beta; see "Next step" below.
What it does
- Descriptor:
codegen/requests.yaml maps each request class to a spec operation in one line, e.g. GetAlbumRequest: {operation: get-an-album}.
- Generator:
codegen/generate-requests.py reads everything else from spec/openapi.yaml:
- verb, path and parameters;
- Java types (
market becomes CountryCode, integers become Integer, …);
- the assertion-only argument checks, such as limit ranges and the maximum number of IDs;
- Javadoc, converted from the spec's Markdown and passing doclint;
- deprecation, and how the response is parsed (single object, array or page, plus the wrapper field when the response nests it).
- Committed output: the generated classes are checked in, so the Maven build needs no Python. A new CI step,
generate-requests.py --check, fails if a listed class no longer matches what the generator produces.
- Survey:
codegen/survey.py generates every hand-written data request and compares its public setters and return type with the existing class.
Result
All 8 albums requests are now generated:
- Public API unchanged: japicmp against 10.1.0 finds no incompatible change.
- All 420 tests pass; Javadoc, the examples build and
check-docs.py pass.
- The Javadoc text now follows Spotify's wording, and the argument checks are consistent across classes.
- It surfaced one disagreement: the spec caps
ids for saving or removing albums at 20, while the hand-written classes asserted 50.
Survey across all requests, with nothing configured beyond the operation:
| Outcome |
Requests |
| Identical public API |
54 of 111 |
| Generator fails on an unsupported feature |
31 |
| Public API would differ |
21 |
| Not comparable (no fixed path/verb or no spec operation) |
5 |
The gaps fall into a few groups:
- Spec schema names that don't follow the model-class naming convention (e.g.
PrivateUserObject → User).
- Request bodies, which affect about 10 requests.
- Response shapes not handled yet: snapshot IDs, cursor paging, and search (one spec operation, nine classes here).
- Parameters the library types as enums.
- Return types where the library deliberately differs from the spec.
- A few setters the hand-written classes omit.
Next step (proposal)
For v11 on beta, I'd rather not keep the compatibility workarounds this prototype carries. Instead, generate a clean, uniform shape from the spec and let the generated API be the reference, recording any renames in MIGRATION.md. This PR stays as the evaluation of the approach.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KSXwvJcGsHkEQQs7VNmYpR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…spec
codegen/generate-requests.py renders a request class from a one-line entry in
codegen/requests.yaml (class name -> spec operationId). Verb, path,
parameters, their types, Javadoc, deprecation and the response parsing all
come from spec/openapi.yaml. The eight albums requests are now generated:
their public API is unchanged (japicmp against 10.1.0), all tests pass and
the Javadoc passes doclint. CI fails when a listed class is out of sync.
codegen/survey.py renders every other data request the same way and
compares the result with the hand-written class: 54 of 111 already come out
with an identical public API.
Refs #461
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KSXwvJcGsHkEQQs7VNmYpR
|
❌ Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.25%. Comparing base (c5165d6) to head (829539d).
Additional details and impacted files
@@ Coverage Diff @@
## dargmuesli/intelligent-allen-glwbik #486 +/- ##
=========================================================================
+ Coverage 47.23% 47.25% +0.01%
Complexity 721 721
=========================================================================
Files 212 212
Lines 6195 6201 +6
Branches 574 576 +2
=========================================================================
+ Hits 2926 2930 +4
Misses 2890 2890
- Partials 379 381 +2
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|