feat: add wirespec-baker integration with code emitters and example#1938
Open
wilmveel wants to merge 3 commits into
Open
feat: add wirespec-baker integration with code emitters and example#1938wilmveel wants to merge 3 commits into
wilmveel wants to merge 3 commits into
Conversation
Add baker-wirespec module with BakerKotlinEmitter and BakerJavaEmitter that generate Baker interaction interfaces from wirespec endpoint definitions. Includes a full example demonstrating recipe orchestration with HTTP transportation and WireMock integration tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Moves generated Baker interaction code into a dedicated .interaction subpackage for better organization. Consolidates Application factory methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rewrites BakerJavaEmitter and BakerKotlinEmitter in Kotlin on top of wirespec's IrEmitter and IR DSL, with JavaGenerator/KotlinGenerator handling the final code rendering. Why: the IR DSL is the supported extension point going forward and replaces per-language StringBuilder assembly with a structured, language-agnostic IR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
This PR adds wirespec integration for Baker, enabling automatic generation of Baker interaction interfaces from wirespec endpoint definitions. It includes two code emitters and a full working example.
Core module:
core/baker-wirespecBakerKotlinEmitter— A wirespecLanguageEmitterthat generates Kotlin Baker interactions from wirespec endpoint definitions. For each endpoint it produces:Interactioninterface with anapply()method whose parameters are flattened from the request body fields and path/query parameters@FiresEventannotations linking interactions to their possible outcomesBakerJavaEmitter— A wirespecLanguageEmitterthat generates Java Baker interaction interfaces with:@FiresEventannotated interaction interfacesComprehensive test suites for both emitters covering simple GET/POST endpoints, path/query parameters, request/response bodies, multiple response codes, and edge cases (e.g., no response body).
Example module:
examples/baker-wirespec-exampleA complete working example demonstrating the end-to-end flow for a "Create Current Account" use case that orchestrates three API calls:
user.ws)profile-api.json, converted via wirespec)account.ws)Key components:
Recipe.kt— Baker recipe wiring the three interactions with ingredient name overrides, required event ordering, and aFinishcheckpoint eventApplication.kt— Entrypoint that creates anInMemoryBaker, registers interaction implementations backed by HTTP transport, and compiles the recipeTransportation.kt— Generic HTTP transport layer using JDKHttpClientthat:Transportationtypealias (suspend (RawRequest) -> RawResponse)handle()function that usesjava.lang.reflect.Proxyto bridge wirespec'sWirespec.Handlerinterfaces to the transport layer viaWirespec.ClientEdgejvmTransportation()for actual HTTP calls anddefaultSerialization()using JacksonEvents.kt— Sensory event definition for the recipeApplicationTest.kt— Integration test using WireMock to stub all three endpoints and verify the full Baker recipe executionWireMockExtensions.kt— Helper extensions for setting up WireMock stubs from wirespec handler responsesBuild configuration
core/baker-wirespec/pom.xmlwith wirespec compiler dependencyexamples/baker-wirespec-example/pom.xmlwith wirespec Maven plugin configured for both.wsand OpenAPI sources, plus Jackson serialization and WireMock test dependenciespom.xmlupdated to include both new modulesTest plan
BakerKotlinEmitterTest— verifies generated Kotlin interaction code for various endpoint shapesBakerJavaEmitterTest— verifies generated Java interaction codeApplicationTest— end-to-end test: fires sensory event, Baker orchestrates three WireMock-stubbed HTTP calls, verifies all events fire and ingredients flow correctly🤖 Generated with Claude Code