Swagger Integration with spring boot - swagger

For one of the rest call /rest/task/addAttachmentToNote which is POST request, I'am getting OPTIONSand PATCH being displayed in the Swagger UI. Why?

Related

Postman: Generating POST request body from GET response

I generate an API and Collection for my app by applying the steps on the following article: The hidden gem: Postman API and Documentation feature.
You may try by using a test endpoint e.g. https://petstore.swagger.io (user:test, pass:abc123).
Here is an example json body that I am trying to generate:
{
"name": "{{$randomLoremSentence}}",
"description": "{{$randomAdjective}}",
"productUuid": "{{productUuid}}",
"address": "{{$randomLoremSentence}}"
}
However, I am looking for a practical way for generating json body for Postman requests. Is there a proper way for this? Or do ı have to build each request manually? I think there must a a smarter way. Any idea?
The JSON response body is not created within POSTMAN, it is generated by the response from a web API HTTP request.
The API method that is executed determines the response.
Once you have determined the response and it's structure, you can then create the request and test script within a POSTMAN Collection.
It is easier to manually test each HTTP request with sample inputs then copy that into an existing Collection, then write the test scripts for each test case, template any input parameters into URL query strings or the
JSON request body with global or collection scoped variables.
After you have determined how to parameterize and template each request (and both the Test Script and Pre-request Script), you will then be able to
implement the test script to create assertions on the JSON response content using BDD expressions.
I recommend looking at the POSTMAN documentation at
https://learning.postman.com/docs/writing-scripts/test-scripts/
https://learning.postman.com/docs/writing-scripts/script-references/test-examples/
as it shows some really good examples on how to create a basic test, then automate it using JavaScript, Chai BDD language and the POSTMAN Collection Runner.
This is based on my experience with POSTMAN. I am not aware of any simple way
to automate request and test script creation from API Swagger definitions as every API method response could have any number of potential responses based on different inputs, so this (I believe) has to be constructed manually by the tester.

Can we use only HTTP POST and and get rid of HTTP GET?

I am new to ASP.NET MVC. I am using http POST for custom validation. Recently I learned that both http POST and http GET are used to send data to the server. HTTP POST is more secure while http GET is less secure as it sends the data in the query string.
I want to know then, is it possible to get completely rid of HTTP GET in my project as its function is similar to http POST? I tried that but it immediately gave error as soon as I started debugging the project. It said "The resource cannot be found.". I am confused. Please help.
I would recommend to review Http Methods - MDN
Since you just started the right course of action would be to use GET to obtain the data (e.g. load the form) and POST to update the data (submit the form to the server).
If the application you are working on is written in plain ASP.NET MVC it will be impossible to completely avoid GET (as it is used by the browser to load application pages/views).
Once you are ready to move to REST APIs you might want to deeper explore PUT, DELETE and other methods

CXF post api fails via jmeter

Trying to automate my test cases using jmeter. I have used cxf for rest apis on my web server. I have an api which actually takes a java object as parameter. On jmeter I have selected the POST method under HTTP-request and sending json data in Body data. The api gets called fine. However the parameter comes null and hence by api fails. I did try changing the parameter to String object, however I get this string as null.
Is this the right way to call apis via jmeter. Or is this failing because I have used cxf on my server.
Any help is appreciated.
Thanks
Most likely you need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json
See Testing SOAP/REST Web Services Using JMeter for detailed explanation on JMeter configuration for REST API testing.
Other thing you could try out is using SoapUI tool to send the request to your CXF endpoint and if it succeeds - inspect the request and configure JMeter accordingly. By the way, SoapUI has some limited load testing capabilities, may be it will be enough for your scenario

Get Jenkins Systemtime using Rest (JSON)

Is there a way to get the system time (say as long-timestamp) of a Jenkins deploy using the Rest API. In my case I was looking at JSON.
If nothing else, every HTTP response should have a Date header which will be the server-side time. You wouldn't need any authentication for this, a simple HEAD request for the homepage would do the job.

How to get response headers and time using capybara-webkit

How to get response of seperate ajax requests in a web page using capybara-webkit?
Is there any particular method available to capture response time of each request?
Note:
Am using capybara with rspec.
For eg: i have 3 Ajax requests in a web page. I need to get separate response time of each request and the response time of entire web page.
Thanks,
Priya
Generally it's not possible since webserver is running in the different process but you could create a custom rack middle-ware and dump all responses to the separate log file. For the beginning you could implement technique described here: https://gist.github.com/2975611 and for dumping headers you could use some code snippets from http://rack.rubyforge.org/doc/Rack/ContentLength.html

Resources