Keep form data without removing in Swagger - api

I am using swagger to describe and document my ASP.Net web API. After running the API on browser, I can enter the input parameters and test my endpoint. But after closing the browser and running the API, I have to add all the input parameters again and again. My question is, Is there a way to keep previous input parameters without removing?

As per my knowledge, there is no direct way to save the data in Swagger. However, you can use Postman to solve your issue. It helps end to end in API development, debugging, testing, and documentation.

Related

Is Swagger UI like a sandbox? How does Swagger UI work

I'm trying to understand how Swagger UI works and what kind of scenario it suits for.
Per my understanding, it's not a sandbox when integrating with Swagger UI. That means Swagger UI manipulates real data. Is that correct?
So usually I have to build a dedicated test environment for Swagger UI, right? Sounds not right to me.
Even there is a test environment for Swagger UI, since it's open to lots of people. Does that mean the dummy data posted by someone will be saved forever and visible to others?
I was expecting Swagger UI behaves like a sandbox which only saves and manipulate the data for the current session. Once the user closes the session then re-open it, it should be brand-new.
I would like to know the typical scenario in which Swagger UI is used.
It's in the name, isn't it? It generates a UI for your API.
It does not spin up a demo environment for your API with the accompanying back-end, including a test database that contains dummy data and/or is periodically wiped.
If you want the latter, you'd have to build that your own.
Does that mean the dummy data posted by someone will be saved forever and visible to others?
Given that your API uses authentication, you will need authentication in order for Swagger UI to make calls. If you do not separate authenticated users' data, then that's a problem in your API, not a problem of Swagger.
Consider that Swagger UI presents you with a visual way to call your API. Anything you can do with Swagger, you can do with any REST/HTTP client, and so can your potential consumers.

How to call Google NLP Api from a Google Chrome extension

My aim is to select some text from a web page, start a google chrome extension and give the text to a google cloud api (Natural Language API) in my case.
I want to do some sentimental analysis and then get back the result to mark/ highlight positive sentences in green and negative ones in red.
I am new to this and do not know how to start.
The extension consists of manifest, popup etc. How should I call an API from there that does Natural Language Processing?
Should I create a Google Cloud Application with an API_KEY to call? In that case I would have to upload my credentials right?
Sorry sounds a bit confusing I know but I just don't know how I can bring this 2 things together an would be more than happy about any help
The best way to authenticate your app will depend on the specific needs and use cases of your application. You can see an overview of all the different methods here.
If you are not planning on identifying users nor on using a back end server that handles authenticating (as I assume to be your case), the best option would indeed be to use API keys. They do not identify the user, but are enough for the Natural Language APIs.
To do this you will need to create an API key for the services you want and add the necessary restrictions to make the key as secure as possible. Detailed instructions on how to do this and how to use the key in a url can be found here.
The API call could be made from within the Chrome extension with any JavaScript method capable of performing POST requests. For example using XMLHttpRequest or the Fetch API. You can find an example of the parameters that need to be included in the request here.
You may run into CORS issues when making the request directly from the extension. I recommend reading this answer, where a couple of workarounds for these issues are suggested.

Selenium and Postman integration or other approach?

I am looking for general idea, approach and subsequently a right tool.
I plan to start testing administration panel. Stable parts of it can be tested by mean of selenium-python scripts. But the challange starts when before testing some funcionalities in panel I need to sent a batch of data via Postman to API endpoint.
As you know Postman is a native app, so it doesn't offer a url which selenium driver could access (browser extension is deprecated.
So the question is. Would it be possible to integrate and automate the process in one selenium script?
Is it possible to do it with Postman or there is another tool that can send a request to endpoint and can be integrated with selenium script?
One more thing. The best approach would be: Sending request and few second after that action start selenium test on data which have been delivered via request to panel. I need to fully automate the process and set those actions with no sighnificant time delay.
Curious about possible solutions.
For API Automation purpose, Use Rest Assured. Its easy to learn, implement. You'll be able to fully automate apis(both JSON & XML). All the validation will be done in seconds. If you integrate RestAssured & Selenium, you'll be able to validate data with API & front end.
Please let me know if you need to know more on this.
Sample GET Code :-
RestAssured.baseURI="base url Eg :- https://www.google.com/";given().header("Accept","application/json").header("Authorization","Value").when().get("rest of the part of the url").then().assertThat().statusCode(200).and().contentType(ContentType.JSON).and().body("name[0]",equalTo("Location"));
Sample POST Code :-
RestAssured.baseURI="https://www.google.com/";
Response res=given().header("Authorization","Value").header("cache-control","no-cache").header("content-type","application/json").body("{"+"\"format\":[\"live-blog\",\"video-story\",\"Photo Gallery\",\"photo-gallery\",\"blank\",\"breaking-news\",\"photo-story\"],"+"\"language\": \"english\""+"}").when().post("Rest of the url`enter code here`").
then().assertThat().statusCode(200).and().contentType(ContentType.JSON).extract().response();
String res_string= res.asString();
System.out.println(res_string);
JsonPath jpath = new JsonPath(res_string);
String articleid = jpath.get("[0].articleId");
System.out.println(articleid);
You can find all the jar files online.
Apologies for the format.
Selenium purpose is not testing your app's APIs, but web. I would suggest as someone commented here, use Java with Rest-Assured, it's very reliable, easy to learn, and fast.
You can use Java's API call if you need anything specific for your web testing, as a requirement or something else.
Since you are using Python already, you could easily use the 'requests' python package to send your API requests and parse the responses as required. This would allow you to easily integrate this into your overall script, sending the api requests, ensuring the necessary response, then starting the selenium steps.

Active Collab API doesn't show all reports

I'm fetching all the open reports tagged as CHECKPOINT using the collab API and it's working fine. Although, when I run a custom report for the tasks, at Active Collab website, I get more and different results than what I fetched.
What I need is to get exactly the same results shown when running a custom report. Does anyone know how can I fix it or if it's a problem with the API itself?
Open browser console and see which requests ActiveCollab's web interface is making when making fetching data to build a report. Compre this with requests that you are making and see where the differences are.
Web interface gets served by the same API as your app is, so both can be made to work the same. As long as they are making the same requests, as same users.
Solution by OP.
By creating a data filter, it shows all the reports if "include_all_projects": true! Simple is that

Do any Google Voice APIs still work?

I am interested in writing a simple CLI program that will send an SMS using Google Voice.
There are several scripts and an API or two available, but I have run into an issue that none of them seem to work any longer; as they mostly rely on parsing returned web pages.
Is anyone familiar with a current API that works so that I can send an SMS on Google Voice?
Thanks!
Looks like Google Voice changed the login procedure, and it now expects you to pass back a cookie. This issue for the Python wrapper sums it up: http://code.google.com/p/pygooglevoice/issues/detail?id=60
UPDATE AND FIX: Actually all that needs to happen is to change the login URL in your code:
Old URL - https://www.google.com/accounts/ServiceLoginAuth?service=grandcentral
New URL - https://accounts.google.com/ServiceLogin?service=grandcentral