wso2wso2-api-manager

WSO2 API Manager (wso2am-4.3.0) - How to Disable OpenAPI Validation When Importing Swaggers?


I'm using wso2am-4.3.0 and I'm trying to import a swagger to create an API. However, due to OpenAPI validation errors, the API cannot be created. Since the swagger worked with older versions of the API Manager, it has too many methods with OpenAPI validation errors and the task has become too complicated to fix the swaggers one by one.

I tried to disable the validation by adding the following configuration to the deployment.toml but still the validation persists.

[apim.swagger]
validation_level = 0

Is it possible to disable the validation temporarily at least so that the older swaggers are compatible with the latest version of the API Manager? Thanks in advance.

Edit:

As per the below screenshot, the API cannot be created due to the linter errors in the first step itself. The next button is disabled.

next button disabled


Solution

  • The mentioned configuration is not available in the WSO2 API Manager 4.3.0, therefore, setting up the following will not solve the problem

    [apim.swagger]
    validation_level = 0
    

    The validation is enforced by default in the WSO2 API Manager 4.3.0, however, it is possible to set a System Property to relax the validation. Add the following System Property to the <wso2-home>/bin/api-manager.sh

    -DswaggerRelaxedValidation=true
    

    The api-manager.sh file looks like below after adding the above-mentioned configuration

    ...
        -Djdk.nio.zipfs.allowDotZipEntry=true \
        -DswaggerRelaxedValidation=true \
        org.wso2.carbon.bootstrap.Bootstrap $*
        status=$?
    done
    

    And restart the API Manager server to take effect on the configurations. You might still see some linter errors, however they can be ignored upto a certain level.

    Also, please check whether they have the "info" block and "title" block in it. Note that both "info" and "title" blocks are mandatory for WSO2 API Manager to do basic checks about the Swagger. For example

    ...
    "info": {
        "title": "Title"
    }
    ...
    

    If they are missing in the Swagger definition, please add those blocks and try importing.