-
Notifications
You must be signed in to change notification settings - Fork 188
updated any type array handling #1190
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
WalkthroughThis change updates the default fallback type for array items across multiple SDK language generators when an inner item type is unspecified. Defaults shift from string-like to generic/unknown types: PHP/JS/TS targets (CLI, Deno, JS, Node, ReactNative, Web) switch from string[] to any[]; Go from []string to []interface{}; Python from List[str] to List[Any]; GraphQL from [String] to Json. Logic that uses a defined inner type (e.g., getTypeName(parameter['array']) variants) remains unchanged. No public API signatures were modified. ✨ 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 (
|
Co-authored-by: Jake Barnby <[email protected]>
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/SDK/Language/GraphQL.php (1)
37-45
: Inconsistent JSON scalar casing (Json vs JSON) will cause schema/type drift
TYPE_ARRAY
fallback usesJson
whileTYPE_OBJECT
returnsJSON
. Pick one. Given this change introducesJson
, align object toJson
for consistency.- case self::TYPE_OBJECT: - $type = 'JSON'; + case self::TYPE_OBJECT: + $type = 'Json';
🧹 Nitpick comments (3)
src/SDK/Language/Web.php (1)
233-233
: Consider unknown[] over any[] for stricter TS safetyIf you want to avoid explicit-any warnings, prefer unknown[].
- return 'any[]'; + return 'unknown[]';src/SDK/Language/CLI.php (1)
371-374
: Array fallback changed to any[]: OK; consider unknown[] for safer typingThis widens types as intended and aligns with other generators. If you want stricter safety without losing flexibility, consider
unknown[]
instead ofany[]
.- : 'any[]', + : 'unknown[]',src/SDK/Language/Node.php (1)
45-49
: Fallback to any[] accepted; consider unknown[] to avoid unsoundness
any[]
matches the PR’s goal; if you want safer typings without restricting callers,unknown[]
is a low-risk upgrade.- return 'any[]'; + return 'unknown[]';
📜 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 selected for processing (9)
src/SDK/Language/CLI.php
(1 hunks)src/SDK/Language/Deno.php
(1 hunks)src/SDK/Language/Go.php
(1 hunks)src/SDK/Language/GraphQL.php
(1 hunks)src/SDK/Language/JS.php
(1 hunks)src/SDK/Language/Node.php
(1 hunks)src/SDK/Language/Python.php
(1 hunks)src/SDK/Language/ReactNative.php
(1 hunks)src/SDK/Language/Web.php
(1 hunks)
🔇 Additional comments (8)
src/SDK/Language/Web.php (1)
233-233
: TS fallback to any[]: LGTMConsistent with the PR’s goal and other TS targets.
src/SDK/Language/JS.php (2)
146-146
: JS/TS fallback to any[]: LGTMAligns behavior across JS-family generators.
143-147
: JS-family array fallback usesany[]
consistently; nostring[]
remains Snapshots and documentation should be updated accordingly.src/SDK/Language/Deno.php (1)
149-152
: Deno: any[] fallback: LGTMMatches JS/Web targets; keeps behavior uniform.
src/SDK/Language/ReactNative.php (1)
151-151
: ReactNative: any[] fallback: LGTMKeeps RN aligned with Web/JS.
src/SDK/Language/Go.php (1)
155-158
: Go: fallback to []interface{}: LGTMIdiomatic for unknown element types and consistent with the PR’s intent.
src/SDK/Language/GraphQL.php (1)
37-43
: Verifyitems.type
for all array parameters
Untyped arrays (those without an explicititems.type
) now map to GraphQLJson
instead of a list type (e.g.[String]
). Ensure everytype: array
in your OpenAPI specs includes anitems.type
to prevent breaking client expectations.src/SDK/Language/Python.php (1)
245-249
: No missing typing imports
Theservice.py.twig
template already includesfrom typing import List, Dict, Any
, covering bothList
andAny
.
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit