Skip to content

feat: add wirespec-baker integration with code emitters and example#1938

Open
wilmveel wants to merge 3 commits into
ing-bank:masterfrom
flock-community:wirespec
Open

feat: add wirespec-baker integration with code emitters and example#1938
wilmveel wants to merge 3 commits into
ing-bank:masterfrom
flock-community:wirespec

Conversation

@wilmveel
Copy link
Copy Markdown
Contributor

@wilmveel wilmveel commented Apr 4, 2026

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-wirespec

  • BakerKotlinEmitter — A wirespec LanguageEmitter that generates Kotlin Baker interactions from wirespec endpoint definitions. For each endpoint it produces:

    • A suspend Interaction interface with an apply() method whose parameters are flattened from the request body fields and path/query parameters
    • Response event classes (one per HTTP status code) with fields flattened from the response body
    • @FiresEvent annotations linking interactions to their possible outcomes
    • Package declarations and proper type imports
  • BakerJavaEmitter — A wirespec LanguageEmitter that generates Java Baker interaction interfaces with:

    • @FiresEvent annotated interaction interfaces
    • Outcome interfaces and response classes per HTTP status code
    • Standard Java bean patterns
  • Comprehensive 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-example

A complete working example demonstrating the end-to-end flow for a "Create Current Account" use case that orchestrates three API calls:

  1. CreateUser (wirespec definition in user.ws)
  2. CreateProfile (OpenAPI definition in profile-api.json, converted via wirespec)
  3. CreateAccount (wirespec definition in account.ws)

Key components:

  • Recipe.kt — Baker recipe wiring the three interactions with ingredient name overrides, required event ordering, and a Finish checkpoint event
  • Application.kt — Entrypoint that creates an InMemoryBaker, registers interaction implementations backed by HTTP transport, and compiles the recipe
  • Transportation.kt — Generic HTTP transport layer using JDK HttpClient that:
    • Defines a Transportation typealias (suspend (RawRequest) -> RawResponse)
    • Provides a handle() function that uses java.lang.reflect.Proxy to bridge wirespec's Wirespec.Handler interfaces to the transport layer via Wirespec.ClientEdge
    • Implements jvmTransportation() for actual HTTP calls and defaultSerialization() using Jackson
  • Events.kt — Sensory event definition for the recipe
  • ApplicationTest.kt — Integration test using WireMock to stub all three endpoints and verify the full Baker recipe execution
  • WireMockExtensions.kt — Helper extensions for setting up WireMock stubs from wirespec handler responses

Build configuration

  • New core/baker-wirespec/pom.xml with wirespec compiler dependency
  • New examples/baker-wirespec-example/pom.xml with wirespec Maven plugin configured for both .ws and OpenAPI sources, plus Jackson serialization and WireMock test dependencies
  • Parent pom.xml updated to include both new modules

Test plan

  • BakerKotlinEmitterTest — verifies generated Kotlin interaction code for various endpoint shapes
  • BakerJavaEmitterTest — verifies generated Java interaction code
  • ApplicationTest — 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

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>
@wilmveel wilmveel changed the title feat: wirespec example with Application entrypoint and WireMock tests feat: add wirespec-baker integration with code emitters and example Apr 4, 2026
wilmveel and others added 2 commits April 4, 2026 17:25
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant