Skip to content

MT-20050: Add new examples#23

Open
DagonWat wants to merge 1 commit intomainfrom
MT-20050-add-new-ruby-code-examples-to-open-api-specs
Open

MT-20050: Add new examples#23
DagonWat wants to merge 1 commit intomainfrom
MT-20050-add-new-ruby-code-examples-to-open-api-specs

Conversation

@DagonWat
Copy link
Contributor

@DagonWat DagonWat commented Mar 13, 2026

Motivation

https://railsware.atlassian.net/browse/MT-20050

Changes

  • Add new code examples since Ruby SDK changes

Summary by CodeRabbit

Release Notes

  • Documentation
    • Added Ruby code examples across API documentation for account management, email sending, and sandbox functionality. Examples demonstrate listing accounts, managing access, configuring sending domains, and sandbox operations to help developers integrate using the Ruby client.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Added Ruby code samples across three OpenAPI specification files (account-management, email-sending, and sandbox) demonstrating usage of the Mailtrap Ruby client library for various API operations without modifying endpoint definitions or schemas.

Changes

Cohort / File(s) Summary
Ruby Code Samples in OpenAPI Specs
specs/account-management.openapi.yml, specs/email-sending.openapi.yml, specs/sandbox.openapi.yml
Added Ruby code samples demonstrating client library usage for account management, email sending domain operations, and sandbox API interactions. Examples show account listing, access management, domain operations, inbox management, and message retrieval using Mailtrap Ruby client classes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • leonid-shevtsov
  • IgorDobryn
  • i7an

Poem

🐰 Ruby samples now adorn the specs so bright,
Mailtrap clients dancing in the documentation light,
From accounts to emails, inboxes to the core,
Code examples hopping—developers learn more! 📚✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'MT-20050: Add new examples' is vague and generic, using non-descriptive terms like 'new examples' that don't convey what was actually added or why. Specify what type of examples were added (e.g., 'MT-20050: Add Ruby code examples to OpenAPI specifications') for better clarity.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description addresses the template's Motivation and Changes sections but lacks detail and omits most template sections like 'How to test' and 'Images and GIFs'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch MT-20050-add-new-ruby-code-examples-to-open-api-specs
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

@DagonWat DagonWat requested review from mklocek and piobeny March 13, 2026 11:31
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
specs/sandbox.openapi.yml (1)

941-941: Unify placeholder naming in Ruby samples for copy/paste clarity.

Line 941 uses PROJECT_ID, while other placeholders use the YOUR_* style (e.g., YOUR_ACCOUNT_ID). The same mixed pattern appears in other new snippets (INBOX_ID, MESSAGE_ID, ATTACHMENT_ID). Consider standardizing to YOUR_PROJECT_ID, YOUR_INBOX_ID, etc.

Based on learnings "replace actual environment variable references with clear placeholders (e.g., YOUR_API_KEY, YOUR_ACCOUNT_ID) to avoid leaking secrets in documentation."

Also applies to: 1067-1067, 1178-1178, 1324-1324, 1453-1453, 1570-1570, 1687-1687, 2066-2066, 2308-2308, 2524-2524, 2749-2751, 2941-2941, 3112-3112, 3295-3295, 3427-3427, 3603-3603, 3754-3754, 3909-3909, 4085-4085, 4212-4212, 4374-4375, 4535-4535

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/sandbox.openapi.yml` at line 941, The Ruby sample uses inconsistent
placeholder names (e.g., inboxes.create(... project_id: PROJECT_ID)) which
should be standardized to the YOUR_* style; update PROJECT_ID → YOUR_PROJECT_ID
and similarly replace INBOX_ID, MESSAGE_ID, ATTACHMENT_ID, ACCOUNT_ID, API_KEY,
etc. in the affected snippets (look for calls like inboxes.create(name: 'My Test
Inbox', project_id: PROJECT_ID), messages.get(INBOX_ID, MESSAGE_ID),
attachments.upload(ATTACHMENT_ID), and any other occurrences listed in the
comment) so all placeholders read like YOUR_PROJECT_ID, YOUR_INBOX_ID,
YOUR_MESSAGE_ID, YOUR_ATTACHMENT_ID, YOUR_ACCOUNT_ID, YOUR_API_KEY for
consistent copy/paste safety.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@specs/email-sending.openapi.yml`:
- Around line 124-135: The Ruby examples that create a sending domain use the
wrong field name: replace domain.name with domain.domain_name in every Ruby
snippet that instantiates Mailtrap::Client and uses
Mailtrap::SendingDomainsAPI#create (look for the snippets that call
Mailtrap::SendingDomainsAPI.new(YOUR_ACCOUNT_ID, client) and assign the result
to domain); update all three occurrences so the output prints domain.domain_name
instead of domain.name.

---

Nitpick comments:
In `@specs/sandbox.openapi.yml`:
- Line 941: The Ruby sample uses inconsistent placeholder names (e.g.,
inboxes.create(... project_id: PROJECT_ID)) which should be standardized to the
YOUR_* style; update PROJECT_ID → YOUR_PROJECT_ID and similarly replace
INBOX_ID, MESSAGE_ID, ATTACHMENT_ID, ACCOUNT_ID, API_KEY, etc. in the affected
snippets (look for calls like inboxes.create(name: 'My Test Inbox', project_id:
PROJECT_ID), messages.get(INBOX_ID, MESSAGE_ID),
attachments.upload(ATTACHMENT_ID), and any other occurrences listed in the
comment) so all placeholders read like YOUR_PROJECT_ID, YOUR_INBOX_ID,
YOUR_MESSAGE_ID, YOUR_ATTACHMENT_ID, YOUR_ACCOUNT_ID, YOUR_API_KEY for
consistent copy/paste safety.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20b70e43-b3da-46c6-8837-d85879f618d3

📥 Commits

Reviewing files that changed from the base of the PR and between 73a0136 and 09d3d11.

📒 Files selected for processing (3)
  • specs/account-management.openapi.yml
  • specs/email-sending.openapi.yml
  • specs/sandbox.openapi.yml

Comment on lines +124 to 135
- lang: ruby
label: Ruby
source: |
require 'mailtrap'

client = Mailtrap::Client.new(api_key: ENV['MAILTRAP_API_KEY'])
sending_domains = Mailtrap::SendingDomainsAPI.new(YOUR_ACCOUNT_ID, client)

domain = sending_domains.create(domain_name: 'example.com')

puts "Created domain: #{domain.name}"
- lang: csharp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify Mailtrap Ruby SendingDomain fields from the official SDK source.
curl -fsSL https://raw.githubusercontent.com/mailtrap/mailtrap-ruby/main/lib/mailtrap/sending_domain.rb | sed -n '1,120p'

Repository: mailtrap/mailtrap-openapi

Length of output: 1900


Use domain.domain_name instead of domain.name in Ruby sending-domain samples.

The Ruby Mailtrap::SendingDomain struct defines the field as domain_name, not name. Update the three code samples at lines 124-135, 267-277, and 385-395.

Required changes
-            puts "Created domain: #{domain.name}"
+            puts "Created domain: #{domain.domain_name}"
-              puts "Domain: #{domain.name}"
+              puts "Domain: #{domain.domain_name}"
-            puts "Domain: #{domain.name}"
+            puts "Domain: #{domain.domain_name}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- lang: ruby
label: Ruby
source: |
require 'mailtrap'
client = Mailtrap::Client.new(api_key: ENV['MAILTRAP_API_KEY'])
sending_domains = Mailtrap::SendingDomainsAPI.new(YOUR_ACCOUNT_ID, client)
domain = sending_domains.create(domain_name: 'example.com')
puts "Created domain: #{domain.name}"
- lang: csharp
- lang: ruby
label: Ruby
source: |
require 'mailtrap'
client = Mailtrap::Client.new(api_key: ENV['MAILTRAP_API_KEY'])
sending_domains = Mailtrap::SendingDomainsAPI.new(YOUR_ACCOUNT_ID, client)
domain = sending_domains.create(domain_name: 'example.com')
puts "Created domain: #{domain.domain_name}"
- lang: csharp
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/email-sending.openapi.yml` around lines 124 - 135, The Ruby examples
that create a sending domain use the wrong field name: replace domain.name with
domain.domain_name in every Ruby snippet that instantiates Mailtrap::Client and
uses Mailtrap::SendingDomainsAPI#create (look for the snippets that call
Mailtrap::SendingDomainsAPI.new(YOUR_ACCOUNT_ID, client) and assign the result
to domain); update all three occurrences so the output prints domain.domain_name
instead of domain.name.

client = Mailtrap::Client.new(api_key: ENV['MAILTRAP_API_KEY'])
billing = Mailtrap::BillingAPI.new(YOUR_ACCOUNT_ID, client)

billing.usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an expression, maybe we should print it? I see we do that in some examples and in some not, there's no consistency.

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.

2 participants