wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
845 stars 785 forks source link

Wrong sample payload generated for SOAP to REST API #10616

Open vithu30 opened 3 years ago

vithu30 commented 3 years ago

Description:

When creating a REST API using SOAP back-end - [1], for checkPhoneNumbers resource, the payload is generated as follows (in tryout console in Devportal):

{
  "CheckPhoneNumbers": {
    "PhoneNumbers": {
      "string": [
        "18006785432"
      ]
    },
    "LicenseKey": "0"
  }
}

When invoking the resource using above payload, the error response received as:

{
  "CheckPhoneNumbersResponse": {
    "CheckPhoneNumbersResult": null
  }
}

The correct response received if the payload is modified as shown below:

{
  "CheckPhoneNumbers": {
    "PhoneNumbers": [
        "18006785432"
      ],
    "LicenseKey": "0"
  }
}

The correct response received:

{
  "CheckPhoneNumbersResponse": {
    "CheckPhoneNumbersResult": {
      "PhoneReturn": {
        "Company": "Toll Free",
        "Valid": true,
        "Use": "Assigned to a code holder for normal use.",
        "State": "TF",
        "RC": null,
        "OCN": null,
        "OriginalNumber": 18006785432,
        "CleanNumber": 8006785432,
        "SwitchName": null,
        "SwitchType": null,
        "Country": "United States",
        "CLLI": null,
        "PrefixType": "Landline",
        "LATA": null,
        "sms": "Landline",
        "Email": null,
        "AssignDate": "Unknown",
        "TelecomCity": null,
        "TelecomCounty": null,
        "TelecomState": "TF",
        "TelecomZip": null,
        "TimeZone": null,
        "Lat": null,
        "Long": null,
        "Wireless": false,
        "LRN": null
      }
    }
  }
}

Seems, there is an issue in the generated swagger.

[1] http://ws.cdyne.com/phoneverify/phoneverify.asmx?wsdl

YasasRangika commented 3 years ago

This issue is in progress

YasasRangika commented 3 years ago

Debug notes: class name: SOAPOperationBindingUtils.java This issue can reproduce in API-M pack 3.2.0 also. Issue is raising at the point we generate swagger using getSoapOperationMappingForUrl method passing SOAP back-end url or passing wsdl archive extracted path or wsdl content directly to the getSoapOperationMapping method.

CheckPhoneNumbers:
    type: object
    properties:
      PhoneNumbers:
        $ref: '#/definitions/ArrayOfString'
      LicenseKey:
        type: string
ArrayOfString:
    type: object
    properties:
      string:
        type: array
        items:
          type: string

suggested solution: If the API definition is changed as below, then the issue will solve.

CheckPhoneNumbers:
    type: object
    properties:
      PhoneNumbers:
        type: array
        items: 
          type: string
      LicenseKey:
        type: string

Since this is working correctly with other SOAP end-points we can reduce the priority.