-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:OpenAPI: change style property from enum to string in image requests #62
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
WalkthroughUpdated the OpenAPI spec to change the style property from an enum reference to a plain string in three request schemas: GenerateImageRequest, ImageToImageRequest, and TransformImageRequest. No other components, including the ImageStyle enum, were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 3
📜 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 settings in your CodeRabbit configuration.
⛔ Files ignored due to path filters (9)
src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.Models.GenerateImageRequest.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.g.csis excluded by!**/generated/**src/libs/Recraft/Generated/Recraft.Models.TransformImageRequest.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/Recraft/openapi.yaml(3 hunks)
| $ref: '#/components/schemas/ImageSize' | ||
| style: | ||
| $ref: '#/components/schemas/ImageStyle' | ||
| type: string |
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.
💡 Verification agent
🧩 Analysis chain
Avoid losing validation for style: reference a shared StyleInput (oneOf enum|string) instead of plain string
Switching to a bare string removes all validation and weakens SDK typings. Recommend keeping known values via enum while allowing future/custom strings via oneOf. Also keeps requests consistent across endpoints.
Apply this minimal change at this location:
- type: string
+ $ref: '#/components/schemas/StyleInput'Then add this schema under components.schemas (outside this hunk):
StyleInput:
description: Accepts any of the predefined ImageStyle enum values or a custom style string for forward compatibility.
oneOf:
- $ref: '#/components/schemas/ImageStyle'
- type: stringVerification script to surface any other request properties that still use the enum directly (adjust if you adopt StyleInput):
🏁 Script executed:
#!/bin/bash
# Show all style occurrences with their immediate definition lines
rg -n -A 2 $'^\\s*style:\\s*$' src/libs/Recraft/openapi.yamlLength of output: 570
Replace bare style: type: string with a shared StyleInput (preserve ImageStyle enum + allow custom strings)
Bare strings remove validation and weaken SDK typings. Replace plain type: string occurrences for style with a shared StyleInput schema that oneOfs the existing ImageStyle enum and string.
Files/locations to update in src/libs/Recraft/openapi.yaml:
- Replace plain string occurrences:
- lines 434-436 (style: type: string)
- lines 673-675 (style: type: string)
- lines 819-821 (style: type: string)
- Already using ImageStyle (optional to migrate for consistency):
- lines 358-360, 375-377, 756-758
Apply this minimal change at each plain-string location:
- type: string
+ $ref: '#/components/schemas/StyleInput'Add this schema under components.schemas:
StyleInput:
description: Accepts any of the predefined ImageStyle enum values or a custom style string for forward compatibility.
oneOf:
- $ref: '#/components/schemas/ImageStyle'
- type: stringSuggested verification (already run once — repeat after edits):
rg -n -A 2 $'^\s*style:\s*$' src/libs/Recraft/openapi.yaml| type: number | ||
| style: | ||
| $ref: '#/components/schemas/ImageStyle' | ||
| type: string |
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.
🛠️ Refactor suggestion
Keep request-style validation while allowing custom values
Mirror the same approach here to avoid weakening schema guarantees and generated client typings.
Apply:
- type: string
+ $ref: '#/components/schemas/StyleInput'Note: This keeps ImageToImageRequest aligned with GenerateImageRequest and prevents divergence in client SDKs.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| type: string | |
| $ref: '#/components/schemas/StyleInput' |
🤖 Prompt for AI Agents
In src/libs/Recraft/openapi.yaml around line 674 the property is declared as a
bare "type: string", which weakens validation and will diverge client typings;
replace this simple string with the same schema pattern used by
GenerateImageRequest (i.e., a oneOf/anyOf that includes the strict enum/ref
version and a permissive string variant) so the request keeps enum validation
but still allows custom values, and update the reference to the shared
enum/schema name so ImageToImageRequest stays aligned with GenerateImageRequest
and generated SDK types remain consistent.
| $ref: '#/components/schemas/ResponseFormat' | ||
| style: | ||
| $ref: '#/components/schemas/ImageStyle' | ||
| type: string |
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.
💡 Verification agent
🧩 Analysis chain
Align TransformImageRequest.style with shared StyleInput for consistency
Consistent schema across all three request types reduces client confusion and prevents type drift vs. BasicStyle/CreateStyle/Style responses that still use ImageStyle.
Apply:
- type: string
+ $ref: '#/components/schemas/StyleInput'Optional follow-up: If both style and style_id can be provided, consider documenting precedence or enforcing mutual exclusivity at the object level with oneOf variants. I can draft that if desired.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="src/libs/Recraft/openapi.yaml"
if [ ! -f "$file" ]; then
echo "MISSING_FILE"
exit 0
fi
echo "===== Showing lines 760-900 ====="
sed -n '760,900p' "$file" || true
echo
echo "===== Grep for style-related symbols ====="
rg -n "TransformImageRequest|StyleInput|ImageStyle|CreateStyle|BasicStyle|style_id|style:" "$file" || true
echo
for sym in StyleInput ImageStyle TransformImageRequest CreateStyle BasicStyle; do
echo "===== Context for $sym ====="
rg -n -A 12 -B 4 "$sym" "$file" || true
echo
doneLength of output: 12906
Align TransformImageRequest.style with existing ImageStyle enum (not a nonexistent StyleInput)
TransformImageRequest currently uses a raw string for style while other schemas use ImageStyle. I couldn't find a StyleInput schema in the repo — use the existing enum to avoid type drift.
- File: src/libs/Recraft/openapi.yaml — components.schemas.TransformImageRequest.properties.style (≈ line 819)
Apply:
- type: string
+ $ref: '#/components/schemas/ImageStyle'Optional: If both style and style_id can be provided, document precedence or enforce mutual exclusivity (oneOf) at the object level. I can draft that if you want.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| type: string | |
| $ref: '#/components/schemas/ImageStyle' |
🤖 Prompt for AI Agents
In src/libs/Recraft/openapi.yaml around line 820, the
TransformImageRequest.properties.style is defined as a plain string but should
use the existing ImageStyle enum; change the schema for style to reference the
ImageStyle component (e.g. $ref: '#/components/schemas/ImageStyle') so it
matches other schemas and prevents type drift, and optionally add a oneOf or
clear precedence/mutual-exclusivity rule between style and style_id at the
object level if both may be provided.
Summary by CodeRabbit
New Features
Chores