Forum Discussion

sylock's avatar
sylock
New Contributor
5 months ago

Issue with INT ENUM types while generating for python

Hi,

I'm using Swagger Codegen OS 3.0.59.

I have issues with all ENUM of type integer.

Error:

File "<stdin>", line 1, in <module>
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/__init__.py", line 18, in <module>
    from gcsp_python_client_swagger.api.amq_clusters_api import AMQClustersApi
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/api/__init__.py", line 6, in <module>
    from gcsp_python_client_swagger.api.amq_clusters_api import AMQClustersApi
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/api/amq_clusters_api.py", line 20, in <module>
    from gcsp_python_client_swagger.api_client import ApiClient
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/api_client.py", line 26, in <module>
    import gcsp_python_client_swagger.models
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/models/__init__.py", line 35, in <module>
    from gcsp_python_client_swagger.models.blueprint_as_osb12 import BlueprintAsOsb12
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/models/blueprint_as_osb12.py", line 18, in <module>
    class BlueprintAsOsb12(object):
  File "/home/smals-nicmi/.local/lib/python3.9/site-packages/gcsp_python_client_swagger/models/blueprint_as_osb12.py", line 88, in BlueprintAsOsb12
    def __init__(self, admin_disk_size=None, admin_network=None, admin_nodes=0, admins=None, app_disk_size=None, app_nodes=0, availability_zone='auto', backup=True, bubble=None, compute_provider=None, contacts=None, cpu=CpuEnum._1, domain=None, environment='Test', extra_volumes=None, imputation_code=None, name=None, network=None, ram=RamEnum._4, root_volume_performance='gold', root_volume_replication=False, root_volume_size=Root_volume_sizeEnum._20, state='present', tags=None, users=None, vm_monitoring=None):  # noqa: E501
NameError: name 'CpuEnum' is not defined

Declaration in the Swagger spec file:

"cpu": {
            "type": "integer",
            "default": 1,
            "description": "The number of **virtual CPU** of the nodes of the cluster.",
            "enum": [
              1,
              2,
              4,
              6,
              8,
              12,
              16
            ],
            "example": 4,
            "nullable": false
          }

It seems a bug to me and I saw related bugs since 2014. Can you advice me on how to handle this?

Thank you.

No RepliesBe the first to reply