CLI-1745: Resolve $ref in requestBody and property schema for api:private-networks:create command.#1973
CLI-1745: Resolve $ref in requestBody and property schema for api:private-networks:create command.#1973vishalkhode1 wants to merge 6 commits intoacquia:mainfrom
$ref in requestBody and property schema for api:private-networks:create command.#1973Conversation
api:private-networks:create command.
api:private-networks:create command.$ref in requestBody and property schema for api:private-networks:create command.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1973 +/- ##
=========================================
Coverage 92.33% 92.34%
- Complexity 1932 1940 +8
=========================================
Files 122 122
Lines 7035 7051 +16
=========================================
+ Hits 6496 6511 +15
- Misses 539 540 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1973/acli.phar |
There was a problem hiding this comment.
Pull request overview
Fixes warnings and improves parameter/example handling for generated API CLI commands when the OpenAPI spec uses $ref in requestBody and in request-body property schemas (notably for api:private-networks:create).
Changes:
- Resolve
$refat therequestBodylevel and for$ref’d properties within the request-body schema before building CLI parameters. - Add fallback support for requestBody examples located at
content.<type>.schema.example(common with$ref-based requestBodies). - Use
getParamType()incastParamType()to avoid"Undefined array key type"warnings for array types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Command/Api/ApiCommandHelper.php |
Adds $ref resolution for request bodies/properties and improves example extraction for usage generation. |
src/Command/Api/ApiBaseCommand.php |
Uses getParamType() to avoid direct access to missing type keys during casting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
$ref in requestBody and property schema for api:private-networks:create command.$ref in requestBody and property schema for api:private-networks:create command.
There was a problem hiding this comment.
Pull request overview
Fixes warnings and improves requestBody parameter handling for generated API CLI commands, especially when OpenAPI requestBody and its properties are defined via $ref (notably for api:private-networks:create).
Changes:
- Resolve
$refat therequestBodylevel before processing request body parameters. - Resolve
$refwithin individualrequestBodyschema properties to ensure a usable spec (incl.type) downstream. - Extend example discovery to also read
content.*.schema.example(in addition tocontent.*.example) and update PHPUnit coverage for the private networks create command.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/phpunit/src/Commands/Api/ApiCommandTest.php | Adds coverage for $ref requestBody example extraction and the private-networks create usage expectation. |
| src/Command/Api/ApiCommandHelper.php | Adds $ref resolution for requestBodies and property schemas; falls back to schema.example for usage generation. |
| src/Command/Api/ApiBaseCommand.php | Uses getParamType() in castParamType() to avoid undefined type access. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@anujkaushal - could you review this today? |
Motivation
Fixes
Undefined array key "type"warning that appears when running commandacli api:private-networks:create.Proposed changes
$refinrequestBodyobject before processing parameters. For ex:$refin individual property definitions fromrequestBodyschema. For ex:schema.examplefor$refresolved requestBodies.getParamType()helper incastParamType()instead of direct$paramSpec['type']access to fix"Undefined array key type"warning.Alternatives considered
N/A.
Testing steps
./bin/acli api:private-networks:create --helpand you should proper example as added inacquia-spec.json../bin/acli ckc