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
840 stars 784 forks source link

Import Swagger 3.0 OpenApi: Context Not Generated when import in wso2am-3.0.0 #7660

Open saranki opened 4 years ago

saranki commented 4 years ago

Describe your problem(s)

In APIM-3.0.0 we couldn't get the context value from the openapi 3.0.0(swagger 3.0.0) while importing it in the publisher portal to create an API. The context got retrieved from swagger 2.0. The issue was reproduced in wso2am-3.0.0+1581697020500. The name and version were fetched from the openapi 3.0.0 file but not the context. The basic difference between swagger 2.0 and openapi 3.0.0 (aka swagger 3.0.0) that is relevant to this ticket is as follows. In terms of the content architecture of these two versions, several components in swagger 2.0 have been combined as individual units in openapi 3.0.0. One such unit is "servers" in openapi 3.0.0. The host, basepath, and schemes in swagger 2.0 have been combined into one unit and names as "servers" in openapi 3.0.0. The "servers" component is an optional field in openapi 3.0.0.

Servers = schemes + host + basepath

Since the "servers" field is an optional field in openapi 3.0.0 it could be classified into mainly 4 cases as follows. Case 1: Without Servers field Case 2: Servers field with an empty array

"servers": []

Case 3: Servers field with complete URL This could be a single URL or multiple URLs.

"servers": [ { "url": "https://petstore.swagger.io/v2" }, { "url": "http://petstore.swagger.io/v2" } ]

Case 4: Servers field with variable mapping This is applicable not only for scheme elements but also for host and basepath. This will result in multiple URLs.

"servers": [ { "url": "{scheme}://developer.uspto.gov/{base}", "variables": { "scheme": { "description": "The Data Set API is accessible via https and http", "enum": ["https", "http"], "default": "https" }, "base": { "description": "The base paths are ds-api and ds-apiiiwow", "enum": ["ds-api", "ds-apiiwow"], "default": "ds-api" } } } ]

Openapi 3.0.0 is based on OAS3 specifications. Getting context value from the openapi 3.0.0 is a limitation in wso2am-3.0.0 due to the above-mentioned combinations in generating a URL. In several cases, we have multiple URLs with different context and in some other cases, we don't have any URLs at all. Due to this complex scenario, the context is not getting imported from openapi 3.0.0 in wso2am-3.0.0.

Describe your solution

Suggested Labels:

wso2am-3.0.0

tmkasun commented 4 years ago

Related to : https://github.com/wso2/product-apim/issues/7397

shamlymhd commented 2 years ago

The Context path needs to be added manually , therefore it would be better if this issue is sorted as soon as possible