GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@dargmuesli dargmuesli commented Nov 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@claude
feat(codegen): prototype generating request classes from the OpenAPI …
829539d
…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
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ 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).

Files with missing lines Patch % Lines
...fy/requests/data/albums/GetAlbumTracksRequest.java 25.00% 0 Missing and 3 partials ⚠️
...fy/requests/data/albums/GetNewReleasesRequest.java 0.00% 0 Missing and 2 partials ⚠️
...quests/data/albums/GetUsersSavedAlbumsRequest.java 0.00% 0 Missing and 2 partials ⚠️
...ests/data/albums/CheckUsersSavedAlbumsRequest.java 66.66% 0 Missing and 1 partial ⚠️
...data/albums/RemoveAlbumsForCurrentUserRequest.java 50.00% 0 Missing and 1 partial ⚠️
...s/data/albums/SaveAlbumsForCurrentUserRequest.java 50.00% 0 Missing and 1 partial ⚠️
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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dargmuesli dargmuesli mentioned this pull request Nov 3, 2026
feat(codegen)!: generate the data requests and their SpotifyApi methods from the spec #487
Merged
@dargmuesli dargmuesli closed this Nov 4, 2026
@dargmuesli
dargmuesli deleted the prototype/request-codegen branch November 4, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@dargmuesli @claude
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.