Skip to content

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

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 Go part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.

Example Before After
examples/web/main.go web -> pdf html -> pdf (parameters), same url and filename
examples/chaining/main.go jpg -> zip file -> zip (parameters), same files parameter

Both files also get the final newline gofmt wants. The other Go examples already call documented converters (docx -> pdf, docx -> jpg, pptx -> pdf, pdf -> split, pdf -> merge, html -> txt, pdf -> jpg).

Verified against production (2026-11-09)

Go 1.27.3 in Docker (golang:1.27): go vet ./... and go build ./... pass, and gofmt -l lists neither changed file. Each example ran with go run ./examples/<name> from the repo root, once on main (719594d) and once on this branch, with the token in API_TOKEN.

examples/chaining, same output before and after:

Converting PDF to JPG and compressing result files with ZIP
DOCX -> JPG conversion cost:  1
DOCX -> JPG conversion result file count:  2
JPG -> ZIP conversion cost:  1
ZIP file saved to:  /tmp/result.zip

Both runs saved a 711,617-byte result.zip with test.jpg and test-2.jpg; the JPGs are byte-identical before and after.

examples/web, same output before and after:

Converting WEB page to PDF
PDF file saved to:  /tmp/web-example.pdf

The PDF text: on main, and in the first run on this branch, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words). A second run on this branch got the article (3 pages, 1,925 words, title "Data conversion"). The rate limiting does not depend on the converter: in the same hour the same html -> pdf call also rendered the article from the Python, PHP and Ruby examples, and the old web -> pdf call got the error page from every SDK. The demo URL is being looked at separately.

Seen, not changed: examples/chaining prints "Converting PDF to JPG" but converts assets/test.docx.

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 jpg -> zip converter. examples/web now converts the URL
with html -> pdf (same url and filename parameters), and examples/chaining
zips the JPG results with file -> zip (same files parameter). Both files
now end with a newline (gofmt).

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 converter updates in the two Go examples.

No open issues 🎉

What changed in this PR

Updates two Go examples to use documented ConvertAPI converters while preserving their existing inputs and output settings.

Changes:

  • Switches the web-to-PDF example from web -> pdf to html -> pdf.
  • Switches the chaining example’s ZIP step from jpg -> zip to file -> zip.
  • Adds final newlines to both files.
File Description
examples/​web/​main.go Uses html -> pdf with the existing URL and filename.
examples/​chaining/​main.go Uses file -> zip with the existing chained JPG results.

Review effort: Balanced

@tomasr78
tomasr78 merged commit 0d6d680 into main Nov 9, 2026
4 checks passed
@tomasr78
tomasr78 deleted the examples-documented-converters branch November 9, 2026 14:17
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