Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Sep 5, 2025

Summary by CodeRabbit

  • New Features
    • Added an Image Variation API endpoint to generate variations from an uploaded image.
    • Supports specifying output size, image format, number of results, random seed for reproducibility, and response format.
    • Includes an optional expiry flag for generated assets.
    • Returns results in JSON for easy integration.

@coderabbitai
Copy link

coderabbitai bot commented Sep 5, 2025

Walkthrough

Adds a new OpenAPI endpoint POST /v1/images/variateImage with multipart/form-data input referencing VariateImageRequest and a 200 JSON response using GenerateImageResponse. Introduces the VariateImageRequest schema with required fields image and size plus optional controls (expire, image_format, n, random_seed, response_format).

Changes

Cohort / File(s) Summary
OpenAPI spec
src/libs/Recraft/openapi.yaml
Added POST /v1/images/variateImage (operationId: VariateImage) accepting multipart/form-data with VariateImageRequest; returns 200 with GenerateImageResponse. Added schema VariateImageRequest (required: image, size; optional: expire, image_format, n, random_seed, response_format).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant C as Client
    participant API as Recraft API
    participant SVC as Image Variations Service
    participant ST as Storage

    Note over C,API: New endpoint: POST /v1/images/variateImage (multipart/form-data)
    C->>API: POST variateImage<br/>form-data: image, size, [expire, image_format, n, random_seed, response_format]
    API->>SVC: Validate & forward VariateImageRequest
    alt image provided
        SVC->>ST: Read uploaded image binary
        ST-->>SVC: Image bytes
    end
    SVC-->>API: GenerateImageResponse (JSON)
    API-->>C: 200 OK JSON
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at endpoints new,
A hop to variate a view—
Multipart dreams in pixel light,
Seeds that scatter into night.
I nibble specs, JSON delight,
Return with images crisp and bright.
Thump-thump: shipped just right! 🐇🖼️

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202509052108

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.

@github-actions github-actions bot merged commit e710ff6 into main Sep 5, 2025
3 of 4 checks passed
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add POST /v1/images/variateImage and VariateImageRequest schema Sep 5, 2025
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: 0

🧹 Nitpick comments (2)
src/libs/Recraft/openapi.yaml (2)

916-937: Schema is fine; prefer DRY via composition and add light validation (min/defaults).

Reuse ProcessImageRequest and extend with variation-specific params. Also add a minimum/default for n. This keeps schemas consistent and reduces duplication.

Apply within this block:

-    VariateImageRequest:
-      required:
-        - image
-        - size
-      type: object
-      properties:
-        expire:
-          type: boolean
-        image:
-          type: string
-          format: binary
-        image_format:
-          $ref: '#/components/schemas/ImageFormat'
-        n:
-          type: integer
-        random_seed:
-          type: integer
-          format: uint32
-        response_format:
-          $ref: '#/components/schemas/ResponseFormat'
-        size:
-          $ref: '#/components/schemas/ImageSize'
+    VariateImageRequest:
+      allOf:
+        - $ref: '#/components/schemas/ProcessImageRequest'
+        - required:
+            - image
+            - size
+          type: object
+          properties:
+            size:
+              $ref: '#/components/schemas/ImageSize'
+            n:
+              type: integer
+              minimum: 1
+              default: 1
+            random_seed:
+              type: integer
+              format: uint32

Optional: if you want size to default to the source image (mirroring ImageToImage behavior), drop it from required and document the default.


227-244: Require requestBody and constrain image upload MIME types

  • Set requestBody.required: true to indicate a payload is mandatory
  • Under multipart/form-data, add an encoding section for the image field to restrict accepted types
   /v1/images/variateImage:
     post:
       tags:
         - image
       summary: Variate Image
       operationId: VariateImage
       requestBody:
+        required: true
         content:
           multipart/form-data:
             schema:
               $ref: '#/components/schemas/VariateImageRequest'
+            encoding:
+              image:
+                contentType: image/png, image/webp
       responses:
         '200':
           description: OK
           content:
             application/json:
               schema:
                 $ref: '#/components/schemas/GenerateImageResponse'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ce3d191 and 02b8dc9.

⛔ Files ignored due to path filters (5)
  • src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs is excluded by !**/generated/**
  • src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs is excluded by !**/generated/**
  • src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.cs is excluded by !**/generated/**
  • src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Recraft/openapi.yaml (2 hunks)

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