Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
112 stars 78 forks source link

`-OutFile` parameter is no longer generated in v3 #1149

Closed peombwa closed 8 months ago

peombwa commented 1 year ago

AutoREST.PowerShell v2, would generate -OutFile parameters for OpenAPI operations that had stream response. This is no longer the case with AutoREST.PowerShell v3.

Repro Steps

Using the sample at https://gist.github.com/peombwa/86bda868b27540fba3d9c08bf8f150f3, generate PowerShell modules using:

paths:
  '/reports/microsoft.graph.getEmailActivityCounts(period=''{period}'')':
    get:
      tags:
        - reports.Functions
      summary: Invoke getEmailActivityCounts function
      operationId: reports_getEmailActivityCounts
      parameters:
        - name: period
          in: path
          description: 'Usage: period=''{period}'''
          required: true
          style: simple
          schema:
            type: string
      responses:
        '2XX':
          description: Success
          content:
            application/octet-stream: # octet-stream media type in no longer considered a binary response.
              schema:
                type: object
                properties:
                  value:
                    type: string
                    format: base64url
                additionalProperties:
                  type: object

Using AutoREST.PowerShell v2.x

  1. Generate module using the sample above:
    autorest --powershell --use:@autorest/powershell@2.x --input-file:"https://gist.githubusercontent.com/peombwa/86bda868b27540fba3d9c08bf8f150f3/raw/a728cfe288156b301cd843b8556beb8539a13c85/Reports.yml" --output-folder:V2
  2. Inspect the generate C# cmdlet in ./V2/generated/cmdlets/GetReportEmailActivityCount_Get.cs.
  3. -OutFile parameter is generated as expected.
    /// <summary>Path to write output file to.</summary>
    [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Path to write output file to")]
    [global::System.Management.Automation.ValidateNotNull]
    [global::Sample.API.Category(global::Sample.API.ParameterCategory.Body)]
    public global::System.String OutFile { get; set; }

Using AutoREST.PowerShell v3.x

  1. Generate module using the sample above:
    autorest --powershell --use:@autorest/powershell@3.x --input-file:"https://gist.githubusercontent.com/peombwa/86bda868b27540fba3d9c08bf8f150f3/raw/a728cfe288156b301cd843b8556beb8539a13c85/Reports.yml" --output-folder:V3
  2. Inspect the generate C# cmdlet in ./V3/generated/cmdlets/GetReportEmailActivityCount_Get.cs.
  3. -OutFile parameter is not generated.

Additional Notes

The issue appears to be in: https://github.com/Azure/autorest.powershell/blob/a638a03496b72ea7053a3b09c60cab77b226aed2/powershell/cmdlets/class.ts#L393-L399

dolauli commented 1 year ago

Looks like a regression issue. Will try to fix it in autorest powershell v4.

dolauli commented 1 year ago

The issue is in modelerfour instead of autorest.powershell. Schema is missing as below.

        responses:
          - language:
              default:
                name: ''
                description: Success
            protocol:
              http:
                statusCodes:
                  - 2XX

And after the issue is fixed in modelerfour, we will need to update the modelerfour version accordingly.

dolauli commented 1 year ago

Move label v4 since we need the issue is fixed in modelerfour first.