Skip to content
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

Add Support for Parameter Objects with Content Property #4480

Open
peombwa opened this issue Mar 17, 2022 · 3 comments
Open

Add Support for Parameter Objects with Content Property #4480

peombwa opened this issue Mar 17, 2022 · 3 comments

Comments

@peombwa
Copy link

peombwa commented Mar 17, 2022

AutoREST.PowerShell fails with error | Error: Plugin modelerfour reported failure when the parameter object of an operation contains content property:
image

Repro Steps

  1. Use an OpenAPI description where the parameter object of an operation is defined as content. e.g., DeviceManagement.Functions.yml.
  2. 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
  3. 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\@autorest_modelerfour@4.15.414\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\@autorest_core@3.7.4\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js - FAILURE Error: Plugin modelerfour reported failure.
            at C:\Users\peter\.autorest\@autorest_core@3.7.4\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:2779:19
            at ScheduleNode (C:\Users\peter\.autorest\@autorest_core@3.7.4\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\@autorestcore@3.7.4\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:2779:19
            at ScheduleNode (C:\Users\peter\.autorest\@autorestcore@3.7.4\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.

@dolauli
Copy link
Contributor

dolauli commented Mar 18, 2022

It is a modelerfour issue. Transfer it to autorest.

@dolauli dolauli transferred this issue from Azure/autorest.powershell Mar 18, 2022
@timotheeguerin
Copy link
Member

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.

@peombwa
Copy link
Author

peombwa commented Mar 18, 2022

@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 microsoftgraph/microsoft-graph-devx-api#902 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants