vmware / vmware-openapi-generator

VMware-openapi-generator tool generates open-api documents from vapi metamodel format.
Other
23 stars 19 forks source link

handle_request_mapping() missing 1 required positional argument: 'spec' #70

Open garanews opened 3 years ago

garanews commented 3 years ago

Hello, I am trying this script running as

python3 vmsgen.py -vc 192.168.178.60 -k --host 192.168.178.60 -dsr  -o swagger/

Product: VMware vCenter Server Version: 7.0.1.00300 Build number 17491101

but getting an error:

Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trusted-clusters/kms/services-applied-config?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trusted-clusters/kms/services-applied-config"],"default_message":"Unable to find operations for URL: /com/vmware/vcenter/trusted-infrastructure/es-applied-config.","id":"com.vmware.vapi.rest.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trusted-clusters/kms/services?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trusted-clusters/kms/services"],"default_message":"Unable to find operations for URL: /com/vmware/vcenter/trusted-infrastructure/trusted-clusters/kms/services.t.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/kms/services?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/kms/services"],"default_message":"Unable to find operations for URL: /com/vmware/vcenter/trusted-infrastructure/kms/services.","id":"com.vmware.vapi.rest.operationsForUrlNotFou
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/trusted-peer-certificates?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/trusted-peer-certificates"],"default_message":"Unable to find operations for URL: /cofrastructure/trust-authority-clusters/kms/providers/trusted-peer-certificates.","id":"com.vmware.vapi.rest.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/client-certificate?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/client-certificate"],"default_message":"Unable to find operations for URL: /com/vmware/vcentrust-authority-clusters/kms/providers/client-certificate.","id":"com.vmware.vapi.rest.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/credential?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/credential"],"default_message":"Unable to find operations for URL: /com/vmware/vcenter/trusted-infralusters/kms/providers/credential.","id":"com.vmware.vapi.rest.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/current-peer-certificates?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/trust-authority-clusters/kms/providers/current-peer-certificates"],"default_message":"Unable to find operations for URL: /cofrastructure/trust-authority-clusters/kms/providers/current-peer-certificates.","id":"com.vmware.vapi.rest.operationsForUrlNotFound"}]}}'
Cannot Load https://192.168.178.60/rest/com/vmware/vcenter/trusted-infrastructure/attestation/services?~method=OPTIONS - b'{"type":"com.vmware.vapi.std.errors.not_found","value":{"error_type":"NOT_FOUND","messages":[{"args":["/com/vmware/vcenter/trusted-infrastructure/attestation/services"],"default_message":"Unable to find operations for URL: /com/vmware/vcenter/trusted-infrastructure/attestation/services.","id":"com.vmware.vapi.res}]}}'
processing package appliance

processing package vcenter

processing package cis

processing package vapi

processing package appliance

processing package vcenter

Traceback (most recent call last):
  File "vmsgen.py", line 166, in <module>
    main()
  File "vmsgen.py", line 150, in main
    api_package_spec_dict = {package: future.result() for package, future in
  File "vmsgen.py", line 150, in <dictcomp>
    api_package_spec_dict = {package: future.result() for package, future in
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/osboxes/Documents/vmware-openapi-generator/lib/api_endpoint/api_metadata_processor.py", line 75, in get_path_and_type_dicts
    path = openapi.get_path(
  File "/home/osboxes/Documents/vmware-openapi-generator/lib/api_endpoint/oas3/api_metamodel2openapi.py", line 32, in get_path
    par_array, url = self.handle_request_mapping(url, http_method, service_name,
TypeError: handle_request_mapping() missing 1 required positional argument: 'spec'
thepvguy commented 2 years ago

Wanted to add that I am also experiencing this issue.

When I run the following:

python vmsgen.py -vc 10.0.100.100 -o .\out

The following error occurs:

Could not fetch structure info for com.vmware.vcenter.task.query_spec
Could not fetch structure info for com.vmware.vcenter.task.result_data
Could not fetch structure info for com.vmware.vcenter.task.task_info
Traceback (most recent call last):
  File "C:\Users\abrewer\Downloads\vmware-openapi-generator-master\vmsgen.py", line 166, in <module>
    main()
  File "C:\Users\abrewer\Downloads\vmware-openapi-generator-master\vmsgen.py", line 150, in main
    api_package_spec_dict = {package: future.result() for package, future in
  File "C:\Users\abrewer\Downloads\vmware-openapi-generator-master\vmsgen.py", line 150, in <dictcomp>
    api_package_spec_dict = {package: future.result() for package, future in
  File "C:\Python310\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "C:\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result
    raise self._exception
  File "C:\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\abrewer\Downloads\vmware-openapi-generator-master\lib\api_endpoint\api_metadata_processor.py", line 75, in get_path_and_type_dicts
    path = openapi.get_path(
  File "C:\Users\abrewer\Downloads\vmware-openapi-generator-master\lib\api_endpoint\oas3\api_metamodel2openapi.py", line 32, in get_path
    par_array, url = self.handle_request_mapping(url, http_method, service_name,
TypeError: ApiMetamodel2Spec.handle_request_mapping() missing 1 required positional argument: 'spec'

Product: VMware vCenter Server Version: 7.0.3 Build: 20395099

thepvguy commented 2 years ago

After doing a little digging, it seems that the call to self.handle_request_mapping in ApiMetamodel2Openapi does not pass in the content_type argument (should come right after the params argument). I worked around this by passing in op_metadata.get("consumes") judging off what is happening in other areas of the code base; fortunately it got the command to run through.

I have no idea if this behavior is correct. However, it works well enough for my purposes.