-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:Add POST /v1/images/variateImage and VariateImageRequest schema #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
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. Comment |
There was a problem hiding this 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: uint32Optional: 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: trueto indicate a payload is mandatory- Under
multipart/form-data, add anencodingsection for theimagefield 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.
⛔ Files ignored due to path filters (5)
src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/Recraft/openapi.yaml(2 hunks)
Summary by CodeRabbit