micro-integrator
micro-integrator copied to clipboard
"Illegal base64 character 3a" when using a "publishSwagger" on RestAPI
I'm trying to use a Custom Swagger Document as described here: https://apim.docs.wso2.com/en/latest/integrate/examples/rest_api_examples/publishing-a-swagger-api/#publishing-a-custom-swagger-document
But I'm getting the following error:
checkout-gateway_1 | [2021-10-15 10:41:28,312] ERROR {PassThroughNHttpGetProcessor} - Error processing request java.lang.IllegalArgumentException: Illegal base64 character 3a checkout-gateway_1 | at java.base/java.util.Base64$Decoder.decode0(Base64.java:746) checkout-gateway_1 | at java.base/java.util.Base64$Decoder.decode(Base64.java:538) checkout-gateway_1 | at java.base/java.util.Base64$Decoder.decode(Base64.java:561) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.utils.SwaggerUtils.fetchSwaggerFromRegistry(SwaggerUtils.java:334) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.utils.SwaggerUtils.retrieveAPISwaggerFromRegistry(SwaggerUtils.java:406) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.utils.SwaggerUtils.getAPISwagger(SwaggerUtils.java:351) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.requestprocessors.swagger.format.SwaggerJsonProcessor.process(SwaggerJsonProcessor.java:51) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.PassThroughNHttpGetProcessor.processWithGetProcessor(PassThroughNHttpGetProcessor.java:147) checkout-gateway_1 | at org.wso2.micro.integrator.transport.handlers.PassThroughNHttpGetProcessor.process(PassThroughNHttpGetProcessor.java:317) checkout-gateway_1 | at org.apache.synapse.transport.passthru.ServerWorker.processHttpRequestUri(ServerWorker.java:777) checkout-gateway_1 | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:169) checkout-gateway_1 | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) checkout-gateway_1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) checkout-gateway_1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Thr
This is the swagger document: https://app.swaggerhub.com/apis/thiagobonfante/CartServiceAPI_v1/1.0.0
Based on this response of StakOverflow: https://stackoverflow.com/questions/57264433/illegal-argument-exception-illegal-base64-character-3a-when-decoding-string-val
I think the problem can be fixed here: https://github.com/wso2/micro-integrator/blob/0cbc20d6a8bf45cefcd04d9db54dbe1e97d8413a/components/mediation/extensions/org.wso2.micro.integrator.transport.handlers/src/main/java/org/wso2/micro/integrator/transport/handlers/utils/SwaggerUtils.java#L334
Changing it to:
byte[] decodedBytes = Base64.getMimeDecoder().decode(defString);