Skip to content

Add LLM guidance, scaffold generator, exchangerate.host example, and WebMock testing docs - #24

Merged
kalashnikovisme merged 2 commits into
mainfrom
codex/enhance-llm-integration-for-api-wrappers
Jan 24, 2026
Merged

kalashnikovisme merged 2 commits into
mainfrom
codex/enhance-llm-integration-for-api-wrappers

Conversation

@kalashnikovisme

Copy link
Copy Markdown
Member

Motivation

  • Make the repository LLM-friendly so agents and humans can reliably generate Purple::Client wrapper clients using a clear policy, examples, and mapping guidance.
  • Provide a real-world example (exchangerate.host) that demonstrates the DSL features (params, optional/blank, Purple::Boolean, response transforms) and a runnable spec pattern.
  • Provide an easy way to scaffold new wrapper skeletons to encourage consistent wrappers and reduce manual errors.
  • Use RSpec + WebMock for wrapper testing guidance (explicitly avoid VCR) and do not add any RBS/signature expansion work per constraints.

Description

  • Added an LLM-focused guide AGENTS.md that explains what a wrapper client is/is not, golden-path structure, naming conventions, modeling rules (params, body, response, optional/allow_blank, Purple::Boolean, :array_of), DO/DON'Ts for LLMs, and a copy-paste skeleton template.
  • Added OpenAPI-to-DSL mapping docs/openapi_mapping.md and testing guidance docs/testing_wrappers.md that show how OpenAPI concepts map to the Purple DSL and how to test with RSpec + WebMock (worked example included).
  • Added a real-world example under examples/real_world/exchangerate_host/ including client.rb (live, historical, convert, timeframe endpoints demonstrating required/optional params, nested response shapes, optional/allow_blank, Purple::Boolean, and a response transform) and README.md documenting how to run it.
  • Added a scaffold CLI bin/purple-client which implements bin/purple-client scaffold PROVIDER_NAME [--force] to generate lib/<provider>/client.rb, lib/<provider>/version.rb, lib/<provider>/README.md, and spec/<provider>/client_spec.rb while refusing to overwrite existing files unless --force is passed; made the CLI executable and documented the command in README.md.
  • Added WebMock to Gemfile and included a new wrapper spec spec/exchangerate_host/client_spec.rb using RSpec + WebMock to validate requests and responses.
  • Minor clarification edits: clarified that params is used to build request bodies for POST/PUT/PATCH and left body(...) for response schemas; adjusted the exchangerate example timeframe rates shape to use { type: Hash, allow_blank: true } to avoid overly strict validation.
  • File list (added/modified): AGENTS.md, docs/openapi_mapping.md, docs/testing_wrappers.md, examples/real_world/exchangerate_host/client.rb, examples/real_world/exchangerate_host/README.md, spec/exchangerate_host/client_spec.rb, bin/purple-client, Gemfile, and updates to README.md.

Testing

  • Attempted bundle install to fetch test deps but it failed due to a network/Gem::HTTP 403 from rubygems.org in this environment, so gems could not be installed (failure: network/403).
  • Attempted bundle exec rspec but it failed because bundler/executables were not available due to the failed install (failure: missing gems); nevertheless, RSpec spec files were added and follow the existing test style and WebMock stubbing pattern.
  • Verified scaffolder file output and permissions by creating bin/purple-client and making it executable, and validated generated file contents via inspection; the CLI will refuse to overwrite files unless --force is given.
  • Manual validations performed: lint-free file writes, README/docs links added, and example/spec source was exercised locally via static inspection; full automated test run requires successful bundle install in an environment with network access.

Run instructions

  • Install dependencies and run tests: bundle install then bundle exec rspec (note: in CI/dev with network access bundle install should succeed and specs will run).
  • Run exchangerate.host example (optional live calls): ruby -r "./examples/real_world/exchangerate_host/client" -e "puts ExchangerateHost::Client.live(base: 'USD', symbols: 'EUR').rates[:eur]".
  • Scaffold a wrapper: bin/purple-client scaffold my_provider and re-run with --force to overwrite.

Notes

  • Per requirements, no types/RBS expansion was added; testing guidance uses RSpec + WebMock (no VCR).

Codex Task

@kalashnikovisme
kalashnikovisme merged commit 907b4a4 into main Jan 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant