Skip to content

MT-20050: Add new examples#23

Merged
DagonWat merged 2 commits intomainfrom
MT-20050-add-new-ruby-code-examples-to-open-api-specs
Mar 18, 2026
Merged

MT-20050: Add new examples#23
DagonWat merged 2 commits 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

  • Documentation
    • Added Ruby code examples across API docs for account management, email sending, sandbox, contacts, and templates.
    • Examples demonstrate listing and managing accounts/access, billing usage, sending domain operations, sandbox inbox/message workflows, contact imports/status, and printing template/results to show runtime output.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Added Ruby code samples and runtime print statements across multiple OpenAPI spec files; no changes to endpoint definitions, schemas, or API behavior.

Changes

Cohort / File(s) Summary
Account Management samples
specs/account-management.openapi.yml
Inserted Ruby x-codeSamples showing account listing, account accesses listing/deletion, and billing usage examples; only sample code added.
Email Sending samples
specs/email-sending.openapi.yml
Added numerous Ruby examples for sending-domain and related endpoints (create/list/get/delete, stats, setup instructions); samples only, no API/schema edits.
Sandbox samples
specs/sandbox.openapi.yml
Added Ruby snippets for sandbox inboxes and messages (list/create/update/delete, clean, mark read, reset credentials, attachments); sample-only additions.
Contacts & Templates samples
specs/contacts.openapi.yml, specs/templates.openapi.yml
Minor Ruby sample changes to print runtime results (import job/status, lists, template outputs); no functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • leonid-shevtsov
  • IgorDobryn
  • yanchuk

Poem

🐰 I hopped through specs with a nimble tap,
Placed Ruby snippets on each API map.
From accounts to inboxes, prints now gleam,
Developers sip code like carrot cream. 🥕✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete compared to the template; it lacks detailed change breakdown, testing instructions, and visual documentation sections required by the template. Expand the description to include specific files modified, detailed list of changes, testing procedures, and complete the template sections for 'How to test' and 'Images and GIFs'.
Title check ❓ Inconclusive The title 'MT-20050: Add new examples' is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes made to the OpenAPI specs. Revise the title to be more specific, such as 'Add Ruby code samples to OpenAPI specifications' or similar, to better describe the actual scope of changes.
✅ Passed checks (1 passed)
Check name Status Explanation
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

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@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.

Copy link
Contributor

@piobeny piobeny left a comment

Choose a reason for hiding this comment

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

I think we should be consistent with the examples, either leave just statement at the end:
messages.html_source(MESSAGE_ID)

or print it:

  domain = sending_domains.get(DOMAIN_ID)

  puts "Domain: #{domain.name}"

@DagonWat
Copy link
Contributor Author

Hi @piobeny you are absolutely right, I tried making this task with AI to automate the documentation update based on Ruby SDK updates.

I now updated and added puts where necessary

@DagonWat DagonWat requested a review from piobeny March 16, 2026 10:14
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

♻️ Duplicate comments (1)
specs/email-sending.openapi.yml (1)

124-134: ⚠️ Potential issue | 🟠 Major

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

These three Ruby examples access a non-matching field and should print domain.domain_name for consistency with the Ruby SDK model.

Proposed fix
-            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}"
#!/bin/bash
set -euo pipefail

# Verify fields in the official Mailtrap Ruby sending domain model.
curl -fsSL https://raw.githubusercontent.com/mailtrap/mailtrap-ruby/main/lib/mailtrap/sending_domain.rb | sed -n '1,200p'

Based on learnings: Use official Mailtrap SDKs for language-specific code examples in x-codeSamples; if SDK doesn't support a method, use GitBook generation or add a comment noting SDK limitations.

Also applies to: 267-277, 385-395

🤖 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 - 134, Replace the
incorrect `domain.name` property with `domain.domain_name` in the Ruby
sending-domain samples: update the usage on the `domain` variable returned by
`Mailtrap::SendingDomainsAPI#create` so the examples print `domain.domain_name`;
apply the same change to the other Ruby examples that construct a
`Mailtrap::SendingDomainsAPI` client and reference `domain` (the other
occurrences noted in the review).
🤖 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/sandbox.openapi.yml`:
- Around line 123-133: Ruby sample placeholders like YOUR_ACCOUNT_ID, INBOX_ID,
MESSAGE_ID, PROJECT_ID, and ATTACHMENT_ID are unquoted constants and will raise
NameError when executed; update every Ruby snippet that uses these bare
identifiers (e.g., Mailtrap::InboxesAPI.new(YOUR_ACCOUNT_ID, client),
inbox.messages.get(INBOX_ID, MESSAGE_ID), Mailtrap::ProjectsAPI.new(PROJECT_ID,
client), attachments.get(PROJECT_ID, ATTACHMENT_ID), etc.) to use quoted strings
(e.g., 'YOUR_ACCOUNT_ID', 'INBOX_ID', 'MESSAGE_ID', 'PROJECT_ID',
'ATTACHMENT_ID') so the examples run as-is. Ensure you replace all occurrences
of those placeholder symbols throughout the Ruby code blocks in the file.

---

Duplicate comments:
In `@specs/email-sending.openapi.yml`:
- Around line 124-134: Replace the incorrect `domain.name` property with
`domain.domain_name` in the Ruby sending-domain samples: update the usage on the
`domain` variable returned by `Mailtrap::SendingDomainsAPI#create` so the
examples print `domain.domain_name`; apply the same change to the other Ruby
examples that construct a `Mailtrap::SendingDomainsAPI` client and reference
`domain` (the other occurrences noted in the review).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a508af22-286d-4d8e-bf6d-19b7263f0971

📥 Commits

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

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

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

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

inboxes.list.each do |inbox|
puts "Inbox: #{inbox.name} (ID: #{inbox.id})"
end
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Detect bare placeholder constants in Ruby sample lines.
python - <<'PY'
from pathlib import Path

p = Path("specs/sandbox.openapi.yml")
tokens = ["YOUR_ACCOUNT_ID", "PROJECT_ID", "INBOX_ID", "MESSAGE_ID", "ATTACHMENT_ID"]
for i, line in enumerate(p.read_text().splitlines(), 1):
    if "source: |" in line:
        continue
    for t in tokens:
        if t in line and f"'{t}'" not in line and f'"{t}"' not in line:
            print(f"{i}: {line.rstrip()}")
            break
PY

Repository: mailtrap/mailtrap-openapi

Length of output: 7460


Quote placeholder IDs in Ruby samples to prevent NameError when examples are executed.

Ruby code samples use bare constants (e.g., YOUR_ACCOUNT_ID, INBOX_ID, MESSAGE_ID, PROJECT_ID, ATTACHMENT_ID) without quotes. In valid Ruby, these are treated as constants and will raise NameError if undefined when the code is run. Placeholder IDs must be quoted strings to match Mailtrap's documentation standards.

Fix pattern
- inboxes = Mailtrap::InboxesAPI.new(YOUR_ACCOUNT_ID, client)
+ inboxes = Mailtrap::InboxesAPI.new('YOUR_ACCOUNT_ID', client)

- inbox = inboxes.get(INBOX_ID)
+ inbox = inboxes.get('INBOX_ID')

- message = messages.get(MESSAGE_ID)
+ message = messages.get('MESSAGE_ID')

Affects all Ruby samples in this file: lines 129, 939, 941, 1067, 1179, 1325, 1454, 1571, 1688, 2065, 2067, 2308, 2310, 2524, 2526, 2744, 2941, 2943, 3112, 3114, 3295, 3297, 3427, 3429, 3603, 3605, 3754, 3756, 3909, 3911, 4085, 4087, 4212, 4214, 4376, 4534, 4537.

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

In `@specs/sandbox.openapi.yml` around lines 123 - 133, Ruby sample placeholders
like YOUR_ACCOUNT_ID, INBOX_ID, MESSAGE_ID, PROJECT_ID, and ATTACHMENT_ID are
unquoted constants and will raise NameError when executed; update every Ruby
snippet that uses these bare identifiers (e.g.,
Mailtrap::InboxesAPI.new(YOUR_ACCOUNT_ID, client), inbox.messages.get(INBOX_ID,
MESSAGE_ID), Mailtrap::ProjectsAPI.new(PROJECT_ID, client),
attachments.get(PROJECT_ID, ATTACHMENT_ID), etc.) to use quoted strings (e.g.,
'YOUR_ACCOUNT_ID', 'INBOX_ID', 'MESSAGE_ID', 'PROJECT_ID', 'ATTACHMENT_ID') so
the examples run as-is. Ensure you replace all occurrences of those placeholder
symbols throughout the Ruby code blocks in the file.

@DagonWat DagonWat merged commit 219a4a6 into main Mar 18, 2026
2 checks passed
@DagonWat DagonWat deleted the MT-20050-add-new-ruby-code-examples-to-open-api-specs branch March 18, 2026 08:56
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.

3 participants