Contributions
Re: swaggerui Undocumented Error: OK
I have downloaded Redux DevTools for Developers and I did manage to find the issue with the code. After fixing the code, the problem got resolved and I was able to load the image into the swaggerui. Error spotted using Redux DevTools: oldCode: <script> window.onload = function() { var appKey = ''; var idToken = ''; var accessToken = ''; var replaceAppKey = false; const ui = SwaggerUIBundle({ url: Drupal.settings.nsw_theme.swagger_url, dom_id: '#tryit', displayRequestDuration: true, withCredentials: true, filter: true, showExtensions: true, showCommonExtensions: true, validatorUrl: "https://validator.swagger.io/validator", presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], parameterMacro: function (operation, parameter) { if((parameter.name == "X-API-Key" || parameter.name == "apikey" || parameter.name == "x-apikey") && replaceAppKey) { parameter.example = appKey; }else if(parameter.name == "X-Id-Token") { parameter.example = idToken; }else if(parameter.name == "X-Access-Token") { parameter.example = accessToken; } }, onComplete: function(swaggerApi, swaggerUi) { // "ApiKeyAuth" is the key name of the security scheme in securityDefinitions var result = getApiKey(); if(result.httpStatusCode == 200 && result.appKey != ""){ appKey = result.appKey; appName = result.appName; Swal.fire({ title: 'Replace App key?', text: 'We found that one of your Apps (' + appName + ') have access to this API Product. We can replace all App keys in the OpenAPI Specs with your App Key.', icon: 'question', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, replace it!' }).then((result) => { if (result.value) { ui.preauthorizeApiKey("ApiKeyAuth", appKey); replaceAppKey = true; Swal.fire( 'Replaced!', 'All App keys have been replaced in the current OpenAPI specs.', 'success' ) } }); }else{ if(result.httpStatusCode != 200){ Swal.fire({ icon: 'error', title: 'Oops...' + result.httpStatusCode, html: result.message, footer: '<a href="/help">Why do I have this issue?</a>' }); } } }, requestInterceptor: function (request) { var headers = request.headers || {}; if (headers["X-Id-Token"]) { headers["X-Id-Token"] = idToken; }else if(headers["client_id"]) { headers["client_id"] = accessToken; } return request; }, responseInterceptor: function (response) { var headers = response.headers || {}; if (response.obj.IdToken) { idToken = response.obj.IdToken; }else if(response.obj.id_token) { idToken = response.obj.id_token; } if (response.obj.AccessToken) { accessToken = response.obj.AccessToken; }else if(response.obj.access_token) { accessToken = response.obj.access_token; } return response; } }) window.ui = ui } function getApiKey() { "use strict"; var domainName = window.location.hostname; var apiPath = "/app/developer_apps/app.json"; var apiURI = "https://test:test@" + domainName + apiPath; var apiMethod = "GET"; var httpStatusCode = ""; var message = ""; var appName = ""; var appKey = ""; var appSecret = ""; jQuery.ajax({ async: false, type: apiMethod, url: apiURI, dataType: "json", statusCode: { 200: function(responseData) { httpStatusCode = "200"; message = "Retrieved LoggedIn user summary list of Apps successfully"; }, 204: function(responseData) { httpStatusCode = "204"; message = `Retrieved LoggedIn user summary list of Apps is empty Please create an App to be able to experience what this API product can offer`; }, 401: function(responseData) { httpStatusCode = "401"; message = `Unable to retrieved LoggedIn user summary list of Apps. If you want, you can <a href="https://developer-dev.testservicensw.net/user/login">login</a> so that you can experience what this API product can offer to your App; otherwise just click Ok`; }, 403: function(responseData) { httpStatusCode = "403"; message = "Received unauthorized while trying to retrieved LoggedIn user summary list of Apps"; }, 404: function(responseData) { httpStatusCode = "404"; message = "Received resource not found while trying to retrieved LoggedIn user summary list of Apps"; } }, error: function(responseData){ httpStatusCode = responseData.status; message = "Received unknown error"; }, }).done(function(responseData){ if(httpStatusCode == 200) { jQuery.each(responseData, function(index, value) { var dotIndex = Drupal.settings.nsw_theme.swagger_file_name.indexOf("."); var apiProductName = Drupal.settings.nsw_theme.swagger_file_name.substring(0, dotIndex); if(apiProductName.toLowerCase() === value.apiProducts[0].toLowerCase()){ appName = value.appName; appKey = value.consumerKey; appSecret = value.consumerSecret; }else{ message = "Couldn't find a product match in your list of apps"; } }); } }); return { "httpStatusCode": httpStatusCode, "message": message, "appName": appName, "appKey": appKey, "appSecret": appSecret }; } </script> <!-- * * End of Swagger UI Configuration * ------------------------------- * --> NEWCode: The section that was changed was theresponseInterceptor section <script> window.onload = function() { var appKey = ''; var idToken = ''; var accessToken = ''; var replaceAppKey = false; const ui = SwaggerUIBundle({ url: Drupal.settings.nsw_theme.swagger_url, dom_id: '#tryit', displayRequestDuration: true, withCredentials: true, filter: true, showExtensions: true, showCommonExtensions: true, validatorUrl: "https://validator.swagger.io/validator", presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], parameterMacro: function (operation, parameter) { if((parameter.name == "X-API-Key" || parameter.name == "apikey" || parameter.name == "x-apikey") && replaceAppKey) { parameter.example = appKey; }else if(parameter.name == "X-Id-Token") { parameter.example = idToken; }else if(parameter.name == "X-Access-Token") { parameter.example = accessToken; } }, onComplete: function(swaggerApi, swaggerUi) { // "ApiKeyAuth" is the key name of the security scheme in securityDefinitions var result = getApiKey(); if(result.httpStatusCode == 200 && result.appKey != ""){ appKey = result.appKey; appName = result.appName; Swal.fire({ title: 'Replace App key?', text: 'We found that one of your Apps (' + appName + ') have access to this API Product. We can replace all App keys in the OpenAPI Specs with your App Key.', icon: 'question', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, replace it!' }).then((result) => { if (result.value) { ui.preauthorizeApiKey("ApiKeyAuth", appKey); replaceAppKey = true; Swal.fire( 'Replaced!', 'All App keys have been replaced in the current OpenAPI specs.', 'success' ) } }); }else{ if(result.httpStatusCode != 200){ Swal.fire({ icon: 'error', title: 'Oops...' + result.httpStatusCode, html: result.message, footer: '<a href="/help">Why do I have this issue?</a>' }); } } }, requestInterceptor: function (request) { var headers = request.headers || {}; if (headers["X-Id-Token"]) { headers["X-Id-Token"] = idToken; }else if(headers["client_id"]) { headers["client_id"] = accessToken; } if (headers["Use-Proxy"]) { if (headers["Use-Proxy"] != "") { request.url = headers["Use-Proxy"] + "?url=" + request.url; headers["Use-Proxy"] = ""; } } return request; }, responseInterceptor: function (response) { var headers = response.headers || {}; if (response.obj) { if ("IdToken" in response.obj) { idToken = response.obj.IdToken; }else if(response.obj.id_token) { idToken = response.obj.id_token; } if (response.obj.AccessToken) { accessToken = response.obj.AccessToken; }else if(response.obj.access_token) { accessToken = response.obj.access_token; } } return response; } }) window.ui = ui } function getApiKey() { "use strict"; var domainName = window.location.hostname; var apiPath = "/app/developer_apps/app.json"; var apiURI = "https://test:test@" + domainName + apiPath; var apiMethod = "GET"; var httpStatusCode = ""; var message = ""; var appName = ""; var appKey = ""; var appSecret = ""; jQuery.ajax({ async: false, type: apiMethod, url: apiURI, dataType: "json", statusCode: { 200: function(responseData) { httpStatusCode = "200"; message = "Retrieved LoggedIn user summary list of Apps successfully"; }, 204: function(responseData) { httpStatusCode = "204"; message = `Retrieved LoggedIn user summary list of Apps is empty Please create an App to be able to experience what this API product can offer`; }, 401: function(responseData) { httpStatusCode = "401"; message = `Unable to retrieved LoggedIn user summary list of Apps. If you want, you can <a href="https://developer-dev.testservicensw.net/user/login">login</a> so that you can experience what this API product can offer to your App; otherwise just click Ok`; }, 403: function(responseData) { httpStatusCode = "403"; message = "Received unauthorized while trying to retrieved LoggedIn user summary list of Apps"; }, 404: function(responseData) { httpStatusCode = "404"; message = "Received resource not found while trying to retrieved LoggedIn user summary list of Apps"; } }, error: function(responseData){ httpStatusCode = responseData.status; message = "Received unknown error"; }, }).done(function(responseData){ if(httpStatusCode == 200) { jQuery.each(responseData, function(index, value) { var dotIndex = Drupal.settings.nsw_theme.swagger_file_name.indexOf("."); var apiProductName = Drupal.settings.nsw_theme.swagger_file_name.substring(0, dotIndex); if(apiProductName.toLowerCase() === value.apiProducts[0].toLowerCase()){ appName = value.appName; appKey = value.consumerKey; appSecret = value.consumerSecret; }else{ message = "Couldn't find a product match in your list of apps"; } }); } }); return { "httpStatusCode": httpStatusCode, "message": message, "appName": appName, "appKey": appKey, "appSecret": appSecret }; } </script> <!-- * * End of Swagger UI Configuration * ------------------------------- * --> </div> Result after fixing the code:6.2KViews1like0Commentsswaggerui Undocumented Error: OK
Dear All, I have OpenAPI Specs 3.0 that has APIs doing the below: Get presigned url --> response is 307 redirect to AWS S3 to get the image Image is downloaded but not displayed and I get the below error: swaggerui Undocumented Error: OK When I click on the JS I found the beow but can't make sense out of it: _context.prev = 14;_context.next = 17;return (request.userFetch || fetch)(request.url, request);case 17:res = _context.sent;_context.next = 20;return http_self.serializeRes(res, url, request);case 20:res = _context.sent;if (!request.responseInterceptor) {_context.next = 28;break;}_context.next = 24;return request.responseInterceptor(res);case 24:_context.t1 = _context.sent;if (_context.t1) {_context.next = 27;break;}_context.t1 = res;case 27:res = _context.t1;case 28:_context.next = 38;break;case 30:_context.prev = 30;_context.t2 = _context["catch"](14);if (res) {_context.next = 34;break;}throw _context.t2;case 34:error = new Error(res.statusText);error.statusCode = error.status = res.status;error.responseError = _context.t2;throw error;case 38:if (res.ok) {_context.next = 43;break;}_error = new Error(res.statusText);_error.statusCode = _error.status = res.status;_error.response = res;throw _error;case 43:return _context.abrupt("return", res);case 44:case "end":return _context.stop();}}}, _callee, null, [[14, 30]]);}));return _http.apply(this, arguments);}var shouldDownloadAsText = function shouldDownloadAsText() {var contentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';return /(json|xml|yaml|text)\b/.test(contentType);};function parseBody(body, contentType) {if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {return JSON.parse(body);}return external_js_yaml_default.a.safeLoad(body);} // Serialize the response, returns a promise with headers and the body part of the hash Cheers, adamSolved6.4KViews0likes1CommentRe: automated testing - drive all test parameters (including http verb) from excel sheet
Hirichie I have published the framework with lots of details on Github. Please have a look and let me if addresses your concern about complex cases. All you need to do is to fill in the excel sheet for your test scenario. Github Repo:https://github.com/earth2digital/automated-api-ddt-framework LinkedIn Article:https://www.linkedin.com/pulse/how-boost-performance-your-apis-part-i-adam-ali-/ My blog Article:https://www.earth2.digital/blog/How-to-boost-the-performance-of-your-APIs-1-adam-ali.html Cheers, adam6 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.5KViews0likes0CommentsRe: automated testing - drive all test parameters (including http verb) from excel sheet
Thanks Richie, I gave it a go and came up with the above which working perfectly fine with a simple event groovy script. I even created a The whole project which also got tons of other automated features can be downloaded from herehttps://earth2.digital/GenericProject-readyapi-project.xml The project has simple 2 test cases: 1. To authenticate and get a token 2. Execute test cases by getting all parameters from a grid (can be modified to get from excel sheet). When I release v2 I will have it reading from an excel sheet. Here is the Event groovy script: // Check if the current test step is ScenarioDataSource if ( testStepResult.getTestStep().getName().equals("Start")) { if (context.expand( '${ScenarioDataSource#method}').equals("POST")) { testRunner.gotoStepByName( "POSTRequest") } else if (context.expand( '${ScenarioDataSource#method}').equals("GET")) { testRunner.gotoStepByName( "GETRequest") } else if (context.expand( '${ScenarioDataSource#method}').equals("PUT")) { testRunner.gotoStepByName( "PUTRequest") } else if (context.expand( '${ScenarioDataSource#method}').equals("DELETE")) { testRunner.gotoStepByName( "DELETERequest") } } else if ( testStepResult.getTestStep().getName().equals("POSTRequest") || testStepResult.getTestStep().getName().equals("GETRequest") || testStepResult.getTestStep().getName().equals("PUTRequest") || testStepResult.getTestStep().getName().equals("DELETERequest") ) { // Run the first test step in the loop testRunner.gotoStepByName( "ScenarioDataSourceLoop") //log.info ( "ScenarioDataSourceLoop" ) }6 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.6KViews1like2Commentsautomated testing - drive all test parameters (including http verb) from excel sheet
Hello, I'm trying to standup automated testing capability for APIs using ReadyAPI (soapUI, etc.). for the sake of speed, I need to be able to drive all request (REST request) parameters from excel sheet including the http verb. I did manage to get everything as a parameter from the excel sheet even assertions but I couldn't drive the http verb/method (POST, GET, PUT, & DELETE) from the excelsheet. My ultimate goal is to have a 4 step generic test case dataSourceLogin (Excel login) loginRequest dataSourceLoopLogin dataSourceScenarios (Excel) request (POST, GET, PUT or DELETE) dataSourceScenariosLoop As per the above, the test QA analyst afterdeveloping the test scenarios, all he/she needs to do is to just fill in a row for every scenario or multiple row for a complex scenario. After a chat with one of SmartBear engineers, he confirmed that it is impossible to do that as this is how it was designed. Now I'm in a very difficult situation as I'm half way through and I'm stuck. He said that different requests with different verbs have different composition. I was thinking to do the below workaround but I need some help: What if I define a generic loop that has 5 steps, 1 dataSource, 4 steps (REST Requests) and 1 dataSource Loop testScnariosDataSource PostRequest GetRequest PutRequest DeleteRequest testScenarioDataLoop The requests would all get their parameters (headers, and body if any from thetestScnariosDataSource) then in the testScnariosDataSource will have a column for http verb/method (POST, GET, PUT, Delete).at the runtime if the verb/method (plus "Request") in the datasource doesn't match the Step name, then I will skip it. The question is how can apply the above logic using Events and how can I skip a request step. Would appreciate any help with the above or even another idea to achieve the same. Another way I'm thinking about it which might do it but not so elegant, is to have 4 rows in the excel-sheet that correspond to the 4 requests and in the excel sheet, I fill one row with the active scenario I want to test and the rest of the 3 with dummy calls to a service (google.com or something) that always return success. Excel DataSource: POST Active test case GET Dummy PUT Dummy DELETE DummySolved6 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes4CommentsI'm configuring a whitelist for IP addresses where we receive requests (on our test server from swag
I'm configuring a whitelist for IP addresses where we receive requests (on our test server from swaggerHub "Try it now" feature proxy). I have the "Try it now" feature working and I want to limit access based on IP addresses. I have the list of IP addresses for swaggerHub "Try it now" proxy: 35.171.119.85/32,35.170.155.105/32,35.171.119.85/32,52.71.40.232/32,52.7.17.243/32 Do you have the offical IP address list and can we be informed if it changes.5.4KViews2likes10Comments