Additional '/' getting added in the operation when VS is created from Swagger specification
search cancel

Additional '/' getting added in the operation when VS is created from Swagger specification

book

Article ID: 106052

calendar_today

Updated On:

Products

CA Application Test CA Continuous Application Insight (PathFinder) Service Virtualization

Issue/Introduction

When creating VS using Swagger document, the VSI is created with an extra '/' in the operation. For example, the transactions are shown as below:

GET //v2/{URLPARAM0}/{URLPARAM1}/
POST //v2/Test12/

Environment

All supported DevTest releases.

Cause

Basepath defined in the Swagger doc causes the issue.

Resolution

. Removing the "basepath":"/" in the Swagger doc will resolve the issue. 

Additional Information

Here is some information on basepath and host per Swagger specification: 

basepath: Per swagger 2 specification at "https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerBasePath", "A relative path to an individual endpoint. The field name MUST begin with a slash. The path is appended to the basepath in order to construct the full URL." 

host: Per swagger 2 specification at "https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerHost", "The base path on which the API is served, which is relative to the host. If it is not included, the API is served directly under the host. The value MUST start with a leading slash (/).  

For example, 
. If Swagger doc has the "basepath": "/v2" after the "host":"tmobile.cm", then /v2 is added to all the transactions like /v2/api/testcase/test12, /v2/api/testvi,.. 
. If Swagger doc has the "basepath": "/v2/" after the "host":"tmobile.cm", then /v2/ is added to all the transactions like //v2/api/testcase/test12, //v2/api/testvi,.. (This is the issue you have)