Skip to content

Examples: use the converters the API spec documents - #43

Merged
tomasr78 merged 1 commit into
mainfrom
examples-documented-converters
Nov 9, 2026
Merged

tomasr78 merged 1 commit into
mainfrom
examples-documented-converters

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Two examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. Both still convert today, but developers copy these examples and the how-to guides on convertapi.com reuse them, so they should call documented converters. This is the Ruby part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.

Example Before After
convert_url_to_pdf.rb web -> pdf, comment links /web-to-pdf html -> pdf (parameters), same Url and FileName; comment links https://www.convertapi.com/html-to-pdf
conversions_chaining.rb any -> zip: with no source format the library sends every zip conversion to any file -> zip (parameters): from_format: 'file', same Files

https://www.convertapi.com/web-to-pdf is not in the site's sitemap; https://www.convertapi.com/html-to-pdf is. The other examples already call documented converters; the pdf -> extract step of create_pdf_thumbnail.rb goes away with #42.

Verified against production (2026-11-09)

Ruby 3.4.12 in Docker (ruby:3.4-slim): each example ran with ruby -I../lib <name>.rb from examples/, once on main (7e10d69) and once on this branch, with the token in API_TOKEN and TMPDIR=/out. The [trace] lines come from a -r helper that prints each request's path; they are not part of the examples' output.

conversions_chaining.rb on this branch:

Converting PDF to JPG and compressing result files with ZIP
[trace] POST v2.convertapi.com/upload -> HTTP 200
[trace] POST v2.convertapi.com/convert/pdf/to/jpg -> HTTP 200
Conversions done. Cost: 1. Total files created: 6
[trace] POST v2.convertapi.com/convert/file/to/zip -> HTTP 200
Conversions done. Cost: 1. Total files created: 1
File saved to ["/out/test.zip"]

On main the output is the same except the ZIP request, POST v2.convertapi.com/convert/any/to/zip. Both runs saved a 775,249-byte test.zip with test.jpg to test-6.jpg; the JPGs are byte-identical before and after.

convert_url_to_pdf.rb on this branch (on main the request was /convert/web/to/pdf, the rest the same):

[trace] POST v2.convertapi.com/convert/html/to/pdf -> HTTP 200
The web page PDF saved to ["/out/web-example.pdf"]

The PDF text: on this branch the PDF is the article (3 pages, 1,925 words, title "Data conversion"). On main, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words); that rate limiting comes and goes for both converters and is being looked at separately.

Seen, not changed: the library itself still picks undocumented converters when no source format is given: any for every zip target (lib/convert_api/format_detector.rb) and url when the parameters have a Url (lib/convert_api/task.rb). The examples now pass the source format, so they do not depend on it.

Same change in the other SDKs

🤖 Generated with Claude Code

The production API spec (https://v2.convertapi.com/info/openapi) has no
web -> pdf and no any -> zip converter. convert_url_to_pdf.rb now converts
the URL with html -> pdf (same Url and FileName parameters) and links the
html-to-pdf page. conversions_chaining.rb passes from_format: 'file' to
the ZIP step: without a source format the library sends every zip
conversion to any -> zip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the updates to the two ConvertAPI examples.

No open issues 🎉

What changed in this PR

Updates two Ruby examples to use documented ConvertAPI converters without changing library behavior or conversion parameters.

Changes:

  • Uses explicit html source format for URL-to-PDF conversion and updates the documentation comment link.
  • Uses explicit file source format when compressing converted JPG files into ZIP.
File Description
examples/​convert_url_to_pdf.rb Switches from web to html and links to the HTML-to-PDF documentation.
examples/​conversions_chaining.rb Sets from_format: 'file' to avoid the implicit any-to-ZIP converter.

Review effort: Balanced

@tomasr78
tomasr78 merged commit 032d625 into main Nov 9, 2026
6 checks passed
@tomasr78
tomasr78 deleted the examples-documented-converters branch November 9, 2026 14:18
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