Azure / autorest.azure-functions-python

Python Code Generation for Azure Functions using Autorest
MIT License
8 stars 6 forks source link

KeyError when generating v3 python sdk #2

Open josh-oakes opened 4 years ago

josh-oakes commented 4 years ago

When trying to generate the python sdk against an openapi3 spec swagger json I'm getting the following error (swagger file attached)...

Stacktrace:

ERROR: [main.Process:51] Python generator raised an exception
Traceback (most recent call last):
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\jsonrpc\server.py", line 49, in Process
    return plugin.process()
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\init.py", line 54, in process
    self.update_yaml(yaml_data)
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\namer\init.py", line 25, in update_yaml
    NameConverter.convert_yaml_names(yaml_data)
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\namer\name_converter.py", line 25, in convert_yaml_names
    NameConverter._convert_operation_groups(yaml_data['operationGroups'], yaml_data['info']['pascal_case_title'])
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\namer\name_converter.py", line 57, in _convert_operation_groups
    NameConverter._convert_language_default_python_case(parameter, pad_string=PadType.Parameter)
  File "C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1\node_modules\@autorest\python\autorest\namer\name_converter.py", line 136, in _convert_language_default_python_case
    schema_description = schema["language"]["default"]["description"].strip()
KeyError: 'description'
  Error: Plugin namer reported failure.

Autorest Info:

$ autorest --info
AutoRest code generation utility [cli version: 3.0.6187; node: v12.18.1, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest

Showing All Installed Extensions

 Type       Extension Name                           Version      Location
 core       @autorest/core                           3.0.6306     C:\Users\joakes\.autorest\@autorest_core@3.0.6306
 extension  @autorest/modelerfour                    4.15.410     C:\Users\joakes\.autorest\@autorest_modelerfour@4.15.410
 extension  @autorest/python                         5.2.0-preview.1 C:\Users\joakes\.autorest\@autorest_python@5.2.0-preview.1
 core       @microsoft.azure/autorest-core           2.0.4417     C:\Users\joakes\.autorest\@microsoft.azure_autorest-core@2.0.4417
 extension  @microsoft.azure/autorest.modeler        2.3.44       C:\Users\joakes\.autorest\@microsoft.azure_autorest.modeler@2.3.44
 extension  @microsoft.azure/autorest.python         3.0.62       C:\Users\joakes\.autorest\@microsoft.azure_autorest.python@3.0.62

The error is a bit generic and I'm not really sure what to look for. Any information that would point me in the right direction would be appreciated!

swagger.txt

alainfonhof commented 3 years ago

The issue seems to be caused by a requestBody with content multipart/form-data. The method _convert_language_default_python_case expects a description for each property in a multipart/form-data schema. I have added "description": "abcd" to each property and then autorest seems to work. I have provided the 'fixed' swagger spec in the attachment.

swagger.txt