autorest
autorest copied to clipboard
Add Support for Parameter Objects with Content Property
AutoREST.PowerShell fails with error | Error: Plugin modelerfour reported failure when the parameter object of an operation contains content property:

Repro Steps
- Use an OpenAPI description where the parameter object of an operation is defined as
content. e.g., DeviceManagement.Functions.yml. - Run AutoREST to generate a module using the above OpenAPI file:
$OpenApiFile = "https://gist.githubusercontent.com/peombwa/8be839787ab6356d30366229f9fd9dc3/raw/bd442972339ea00b523ccb5c79c2e87ef5dd8aab/DeviceManagement.Functions.yml" autorest --powershell --input-file:$OpenApiFile --debug - AutoREST fails with:
AutoRest code generation utility [cli version: 3.6.0; node: v14.11.0] info | Loading AutoRest extension '@autorest/powershell' (~3.0.0->3.0.471) info | Loading AutoRest extension '@autorest/modelerfour' (4.15.414->4.15.414) ... C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\modelerfour\dist\modeler\plugin-modelerfour.js - FAILURE "Unresolved item." undefined PLUGIN FAILURE: undefined, undefined, "Unresolved item." fatal | Unresolved item. C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js - FAILURE Error: Plugin modelerfour reported failure. at C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:2779:19 at ScheduleNode (C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:1317:33) fatal | Process() cancelled due to exception : Plugin modelerfour reported failure. / Error: Plugin modelerfour reported failure. at C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:2779:19 at ScheduleNode (C:\Users\peter\.autorest\@[email protected]\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:1317:33) error | Error: Plugin modelerfour reported failure. debug | [2.56 s] Shutting Down. debug | [2.56 s] Exiting.
Expected behavior
AutoREST.PowerShell should generate a command for /deviceManagement/microsoft.graph.getRoleScopeTagsByIds(ids={ids}) that makes GET /deviceManagement/microsoft.graph.getRoleScopeTagsByIds(ids=["1","2","3"]) request.
According to the OpenAPI spec:
For more complex scenarios, the content property can define the media type and schema of the parameter. A parameter MUST contain either a schema property, or a content property, but not both.
It is a modelerfour issue. Transfer it to autorest.
Duplicate of #4303, is this a demand from services? I did brings this up in autorest scrum a while back and there wasn't much interest in supporting it in the generators without a real demand.
@timotheeguerin, yes, this is a demand from a service. MS Graph API supports GET /deviceManagement/microsoft.graph.getRoleScopeTagsByIds(ids=["1","2","3"]), which can only be described with a parameter object of Content.application/json. See the discussion in https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/902#issuecomment-1069133352.