Repository navigation
feat(codegen): prototype generating request classes from the OpenAPI spec - #486
Closed
dargmuesli wants to merge 1 commit into
Closed
dargmuesli wants to merge 1 commit into
dargmuesli wants to merge 1 commit into
Conversation
…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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KSXwvJcGsHkEQQs7VNmYpR
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
codegen/requests.yamlmaps each request class to a spec operation in one line, e.g.GetAlbumRequest: {operation: get-an-album}.codegen/generate-requests.pyreads everything else fromspec/openapi.yaml:marketbecomesCountryCode, integers becomeInteger, …);generate-requests.py --check, fails if a listed class no longer matches what the generator produces.codegen/survey.pygenerates every hand-written data request and compares its public setters and return type with the existing class.Result
All 8
albumsrequests are now generated:check-docs.pypass.idsfor saving or removing albums at 20, while the hand-written classes asserted 50.Survey across all requests, with nothing configured beyond the operation:
The gaps fall into a few groups:
PrivateUserObject→User).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 inMIGRATION.md. This PR stays as the evaluation of the approach.🤖 Generated with Claude Code
https://claude.ai/code/session_01KSXwvJcGsHkEQQs7VNmYpR