Extract all requests from Swagger documentation - api

I've been given a URL for the swagger frontend, offering the documentation for a number of POST, GET, PUT and DELETE requests and I need to extract all requests (possibly as cURL commands), without opening each of the items and manually copying the request.
How?

According to https://petstore.swagger.io/ the app is written in React and it's not possible to see the curl request before you click on the section (because it's not in HTML tree at that point). You can try to install CJS plugin for chrome and write jQuery that:
creates temporary textarea
clicks through all necessary sections, their try now button and then their execute button
copies .curl contents to the temporary textarea
After that you can simpy copy the contents of the textarea to a textfile or something.

Related

Submit multiple files on form as part of axios post

i have created a form to make a submission to an api using axios.
There are 3 other parameters and then the files to submit.
I got it working with one file but what I need to do is be able to have multiple files uploaded and then submit, i tried using the multiple flag but this seems to only allow you to select multiple files in the same folder at once rather than choosing and selecting the files individually.
I don’t want the files sent to the api until the submit button is clicked though.
I thought maybe about using local storage to put the files and then pull to submit at once when the button is clicked?
You can use Base64 encode in client side and add the encoded string to your post request and decode from server side.

How to access comment section of a page source using selenium?

How can we access the content after class="hidden_elem" using selenium, as it does not get loaded into the page source while accessing it. The content in the comments is actually what we need to extract as they are a part of the script that gets run.

Can JQuery File upload be used without AJAX?

I want to use something along the lines of JQuery file upload (i'm open minded) in a form with lots of other fields for the UI (ex. image previews, delete, file sizes .etc), but I want to submit the files along with the form as if i used a normal HTML file field.
Is this at all possible?
If you console.log() the form after submission you will get an object in return that has a bunch of information. Among that information you can find for example file information of the file you just upload.
You can check this http://jsfiddle.net/1r0Lprkj/1/ and open your console after you've submitted the form.
Then if you want to go deeper into this, then you can check out the Javascript FileReader which lets you do a bunch of cool stuff with the uploaded file. https://developer.mozilla.org/en-US/docs/Web/API/FileReader
To answer your question; Yes it is possible to achieve without AJAX.

Disable browser cache for displayed in an iFrame PDF by means of TCPDF

I am trying for hours to solve the following caching problem.
My application has the following structure (simplified):
index.php - main page (contains various input fields, submit button and an iframe for dispaying PDF content with the help of TCPDF)
generate.php - generates PDF file based on the supplied POST parameters and stores the file to the filesystem
viewer.php - Displays the PDF document (TCPDF libraries). The iframe loads this script to show the pdf file
The workflow is pretty simple - the user chooses some options and clicks the submit button on the main page. The selected parameters are sent per AJAX by POST to the generate.php script. The script generates the PDF file and stores it to the filesystem. At the end it returns the newly created/edited filename. The filename is fetched in the AJAX callback function, which then refreshes the iframe with the new/edited filename:
viewer.php?filename=NEW_OR_EDITED_FILENAME
Everything is working, but when the file is being replaced, sometimes (NOT ALWAYS), the browser shows the old pdf file, although the new version is on the hard drive. I tried the following solutions:
Add Meta tags to disable cache to the generated HTML by index.php and viewer.php
Disabling cache for jQuery AJAX calls by: jQuery.ajaxSetup({cache: false});
Adding some random string to the the filename parameter:
viewer.php?filename=FILENAME_RANDOMSTRING
The RANDOMSTRING is then removed from the script and the filename is extracted.
None of these solutions worked for me. Tested browsers are: Chrome 25.0.1364.152 and Firefox 19.0. Can someone help me with this?
Thanks in advance
Just had the same problem but after adding a random string it works perfect:
<iframe src="file.pdf?=<?=time();?>"></iframe>
After many hours of trying, the solution I found is to really generate a new file each time (Solution 3 from the question without removing the random string at the end of the file). As a result it was necessary to update the database and to delete the old files on every change. My initial intention was to avoid these actions, but unfortunately no other solution was found

Automatic Webpage Data Entry based on The Page Content

Is it possible to make a program that open a page (as if a bookmark file were opened by IE), and based on its content generate a feedback, that should be fedback in a textbox on said page by pressing a button on said page?
I need this program to execute on a set time schedule to feed some data to a web server based on time dependent web page data.
Yes, that is possible. It is generally called screen scraping. You basically retrieve the web page in question via a HTTP request, parse/analyze the page you got, then send back the data that should go into the textbox (again a HTTP request).
There are libraries to do that. Here is an article describing an example in Perl:
http://www.perl.com/pub/a/2003/01/22/mechanize.html