Repository navigation
Conversation
Adds a Format namespace of media-type string constants so the types accepted by convert() are discoverable via autocomplete, including JPEG XL (image/jxl), which the API already accepts. String constants rather than a language-level enum: the JSON body must carry the media type verbatim, and an enum would serialize as its name. Existing callers passing raw strings are unaffected.
There was a problem hiding this comment.
🟢 Approval recommended
The change is additive and low-risk with test coverage, with only a minor documentation wording mismatch noted.
Pull request overview
Adds a TinifyAPI.Format static class of string media-type constants to make Source.Convert’s accepted type values discoverable via autocomplete (including JPEG XL / image/jxl), with accompanying unit tests and a changelog entry.
Changes:
- Introduced
TinifyAPI.Formatconstants for supported convert media types (image/webp,image/png,image/jpeg,image/jpg,image/avif,image/jxl,*/*). - Added NUnit tests asserting the constants and verifying
ConvertserializesFormatvalues correctly (single and multiple types). - Documented the addition in
CHANGES.mdunder “Unreleased”.
File summaries
| File | Description |
|---|---|
| test/Tinify.Tests/FormatTest.cs | Adds unit tests for Format constants and Convert request serialization using them. |
| src/Tinify/Format.cs | Introduces the Format constants API (including image/jxl) with XML documentation. |
| CHANGES.md | Notes the new Format constants in the unreleased changelog. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /// <summary>JPEG, <c>image/jpeg</c>.</summary> | ||
| public const string Jpeg = "image/jpeg"; | ||
|
|
||
| /// <summary>JPEG, <c>image/jpg</c>. An alias of <see cref="Jpeg"/>.</summary> |
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.
Adds a
Formatnamespace of media-type constants so the types accepted byconvertare discoverable via autocomplete — including JPEG XL(
image/jxl), which the API already accepts but no client surfaced.image/jxlis already in the API allowlist (apps/api/src/schemas/optimizations.tsand
apps/opt-api/src/constants/content-types.ts), so this is a client-sidediscoverability change only. There is no API-side work outstanding.
Members
WEBP,PNG,JPEG,JPG,AVIF,JXL,ANY(*/*) — mirroring theAPI allowlist exactly.
Why string constants and not an enum
The JSON body has to carry the media type verbatim. A language-level enum
serializes as its name or ordinal, not
image/jxl. String constants also keepthis fully backward compatible: callers passing raw strings are unaffected.
Verification
Full suite green locally:
dotnet test -f net9.0→ 86 passed, 2 pre-existing skips, including 3 newFormatTestcases.Note: the
net8.0target could not run locally (that runtime isn't installed on this machine) — CI covers it.Part of a coordinated change across all six Tinify client libraries, so the
same
FormatAPI is available in each.