Repository navigation
Examples: use the converters the API spec documents - #43
Merged
Merged
Conversation
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>
This was referenced Nov 9, 2026
There was a problem hiding this comment.
🟢 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
htmlsource format for URL-to-PDF conversion and updates the documentation comment link. - Uses explicit
filesource 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
convert_url_to_pdf.rbweb -> pdf, comment links /web-to-pdfhtml -> pdf(parameters), sameUrlandFileName; comment links https://www.convertapi.com/html-to-pdfconversions_chaining.rbany -> zip: with no source format the library sends everyzipconversion toanyfile -> zip(parameters):from_format: 'file', sameFileshttps://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 -> extractstep 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 withruby -I../lib <name>.rbfromexamples/, once onmain(7e10d69) and once on this branch, with the token inAPI_TOKENandTMPDIR=/out. The[trace]lines come from a-rhelper that prints each request's path; they are not part of the examples' output.conversions_chaining.rb on this branch:
On
mainthe output is the same except the ZIP request,POST v2.convertapi.com/convert/any/to/zip. Both runs saved a 775,249-bytetest.zipwithtest.jpgtotest-6.jpg; the JPGs are byte-identical before and after.convert_url_to_pdf.rb on this branch (on
mainthe request was/convert/web/to/pdf, the rest the same):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:
anyfor everyziptarget (lib/convert_api/format_detector.rb) andurlwhen the parameters have aUrl(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