Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
112 stars 83 forks source link

Powershell generator errors on freeform object #989

Open kieran-turnbull opened 2 years ago

kieran-turnbull commented 2 years ago

Before filling a bug

Describe the bug Running autorest --powershell throws an error when a freeform object is defined in the specification.

debug   | [4.67 s] detecting high level commands...
PLUGIN FAILURE: Cannot read properties of null (reading 'language'), TypeError: Cannot read properties of null (reading 'language')
    at C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@autorest\powershell\plugins\create-commands-v2.ts:437:149
    at Object.<anonymous> (C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@azure-tools\linq\new-linq.ts:280:11)
    at Generator.next (<anonymous>)
    at Generator.toArray (C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@azure-tools\linq\new-linq.ts:336:14)
    at Inferrer.addVariants (C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@autorest\powershell\plugins\create-commands-v2.ts:437:176)
    at Inferrer.createCommands (C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@autorest\powershell\plugins\create-commands-v2.ts:167:22)
    at createCommandsV2 (C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@autorest\powershell\plugins\create-commands-v2.ts:502:77)
    at C:\Users\user\.autorest\@autorest_powershell@3.0.493\node_modules\@azure-tools\autorest-extension-base\extension-base.ts:68:9, {}
fatal   | TypeError: Cannot read properties of null (reading 'language')
fatal   | Process() cancelled due to exception : Plugin create-commands-v2 reported failure. / Error: Plugin create-commands-v2 reported failure.
    at C:\Users\user\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:2817:19
    at ScheduleNode (C:\Users\user\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:1351:29)
error   |   Error: Plugin create-commands-v2 reported failure.
error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.     
debug   | [4.73 s] Shutting Down.
debug   | [4.73 s] Exiting.

OpenAPI method

requestBody:
  required: true
  content:
    application/json:
      schema:
        allOf:
        - $ref: "#/components/schemas/Authorization"
        - type: object
          properties:
            id:
              readOnly: true
            authorizers:
              readOnly: true
            status:
              readOnly: true
            authorizationData:
              readOnly: true
        - required:
          - approvalResult
responses:
  '200':
    description: OK
  '404':
    description: A request with the specified ID or authorization with the specified ID was not found.

Schema:

Authorization:
  type: object
  properties:
    id:
      type: string
      format: uuid
    authorizers:
      type: array
      items:
        type: string
        format: uuid
    approvalResult:
      type: boolean
    status:
      type: string
    authorizationData:
      type: object

Expected behavior Generation with support for freeform object.

dolauli commented 1 year ago

@kieran-turnbull Would you post the full version of your swagger which I could use to reproduce the issue.