Swagger UI - "Try it Out!" button call failing - swagger-ui

I have installed Swagger UI on my local machine. When I am pulling up some Swagger definitions, the definitions are working fine, however, when I click on the "Try it out!" button, the call fails stating "No response from server".
However, when I take the Request URL from Swagger UI and run it directly in the browser, the server responds (BAU).
Am I missing something? Do I need to setup/configure Swagger UI to make this call happen?
Note: I have just downloaded the latest version of Swagger and running it locally on Windows desktop with Tomcat server.
Please help.

The specs for Swagger-ui is usually in JSON format which contains host(including port), basePath, paths (path array of each API service). Swagger-client will construct the request URL from all these properties and send the request to the URL with an "Accept" header. Now you can not get response from service you need to check whether the backend services are running. You can open browser development tools to capture the HTTP request and see if it is correct.
You can go to http://petstore.swagger.io/ to see how it works.

Related

Post request always returning error in JMeter

I'm creating a load test with JMeter. I'm trying to make a Post request to create a new resource but it always responds with 500 error, even though I'm sending the same headers and parameters as the browser and I also tried with postman and it works fine, it's just with JMeter that's not working.
The script was recorded with the BlazeMeter Chrome extension and adjusted as needed.
The next configurations are for the Test Plan in general:
HTTP Header Manager with the header "User-Agent".
User Defined Variables with only one variable "BASE_URL_1".
HTTP Request Defaults with the "Retrieve All Embedded Resources" and "Parallel downloads" selected and "Number" set to 6.
DNS Cache Manager with "Clear cache each iteration" selected and "Use system DNS resolver".
HTTP Authorization Manager with nothing selected.
HTTP Cookie Manager with "Clear cookies each iteration?" selected.
HTTP Cache Manager with "Clear cache each iteration?" selected and "Max Number of elements in cache" set to 5000.
I set the "CookieManager.save.cookies" option to "true" in "jmeter.properties".
Here's an image of what the "HTTP Request" looks like:
Inside the "HTTP Request" there's a "HTTP Header Manager" with the next headers:
Inside the "HTTP Request" there's also a "Uniform Random Timer" with "Random Delay Maximum" set to 26344.0 and "Constant Delay Offset" set to 13172.
The cookies seemed to be sent fine with the session data. I do log in a user and get the session data before attempting to do the post request and other get requests work fine under the same session. I teste this same headers with Postman and it worked. I have no idea why this is not working in JMeter. I tried doing several changes to the configuration without success. This is a .NET service.
The API is not built the best way, but what makes me think that this 500 error might be from JMeter and not the API is that I was able to successfully make the request from postman.
Anyone has an idea of what could be wrong on the test config?
EDIT
Here are some images from the View Results Tree:
Sampler Result
Request Body
Request Headers
Response Headers
The Response Body is HTML saying that there's an error.
Given your request works in Postman you should be able to record it using JMeter's HTTP(S) Test Script Recorder.
Prepare JMeter for recording, the fastest and the easiest way is using JMeter Templates feature
From JMeter's main menu choose File -> Template -> Recording and click "Create"
Open HTTP(S) Test Script Recorder and click "Start"
Prepare Postman for recording.
From Postman main menu choose File -> Settings -> Proxy
Use 127.0.0.1 as the proxy host and 8888 as the proxy port
Run your request in Postman
JMeter will capture the request under the Recording Controller
Parameterize and correlate the request
It should be working fine. If not - compare the requests which are being sent by Postman and JMeter using a 3rd-party sniffer tool like Wireshark of Fiddler, detect and eliminate any inconsistencies.

How to configure Neo4j Browser to use a custom REST endpoint?

The server is running a custom REST endpoint configured using the following line
org.neo4j.server.webadmin.data.uri=/db/abc
in neo4j-server.properties. REST is then working fine using /db/abc, but then the browser client (http://$SERVERHOST:7474/browser) stops working and displays the Disconnected from Neo4j message. Packet sniffing indicates it is still trying to connect to db/data. Clearing local web caches doesn't help. Is there a way to point the browser client to use a custom endpoint?
Sources indicate that /db/data is possibly hardcoded into the browser as part of client "Settings" (see line 23). There is supposedly a way to reconfigure these settings using the :config command in the client, but the command bar is only available when the client is already connected to the server.
Is there a way to get this to work, or is it possibly a bug in the browser client?
Current option is to download source code of the browser and change what you need.
https://github.com/neo4j/neo4j/tree/2.3/community/browser

Swagger UI shows error (validation) when deployed

I have the swagger ui embedded in my application. And when I run my node application locally the UI works great.
However when I deploy the UI to my 'real' server I get an error image in the bottom right of my swagger ui:
I am sure this is something I am doing that is screwing it up but I have no idea. Again works locally when I access swagger ui via http.
However when I deploy I run through apache and serve out over https, I see an error. Even worse none of my 'Try it' calls work when deployed. Seems like the request is not being made.
Looks like the UI makes a call to a validator with my swagger.json, however that call works locally.
What am I doing wrong?
When I click the error icon, I get:
To turn off swagger validator add validatorUrl : null, in dist/index.html in
window.swaggerUi = new SwaggerUi({
url: url,
validatorUrl : null,
dom_id: "swagger-ui-container",
When this happens (and it sometimes does) I go here:
http://json-schema-validator.herokuapp.com/index.jsp
Paste the swagger schema from here https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json in the schema field and then your spec in the data field
Swagger-UI is able to handle some malformed specs, which is probably why it is works locally.
By default, the validation process does not run when the spec is read from localhost. You should be able to run it still, if you wish, using the validatorUrl (https://github.com/swagger-api/swagger-ui#parameters).
To see the validation errors, just click on the ERROR icon, and it will give you a list of problems with your spec.

Not able to retrieve WSDL content from WSP

I have service (Web Service Proxy) running on DataPower. I am able to test the service from SOAPUI.
Client application / service is trying pull WSDL from URL like http://host:port/uri?WSDL
It is mandatory to pull the WSDL from URL to develop their code.
I have upload the WSDL and share the
http://host:port/system/dpViewer/ServiceName.wsdl?filename=local:/Path/ServiceName.wsdl
Still They were not able to access the URL from their system.
We performed the connectivity to both system. Everything is working fine.
Any help?
You can't access using
http://host:port/system/dpViewer/ServiceName.wsdl?filename=local:/Path/ServiceName.wsd
As it is internal for your reference and It will open your file in Management / Admin IP. (Most of the place there will be different IP for transactions)
http://host:port/uri?WSDL is possible in DataPower
Please follow the below step in your Web Service Proxy (WSP)
Edit front side handler (HTTP SOURCE HANDLER)
Enable 'GET method'
Apply changes and Save Config.
By Default , 'Get method' will not be enabled in WSProxy. As it is disabled, All WSDL get requests are rejected by DataPower.
I hope after this , We can access the WSDL using URL.

URL pattern to include in JMeter for testing ASP.NET MVC website

I am trying to perform a load test with JMeter on my ASP.NET MVC website that I have published on IIS..
My problem is..I'm confused about what URL pattern should I include or exclude..Currently, URL is immaterial for me, so I tried with '.* ' in URL to include and nothing in URL to exclude.. But JMeter is recording only a jpg url...If I specify '.*\.jpg ' in exclude, it records nothing. I also tried '.*\.aspx ' in include and nothing in exclude, but that doesn't seem to be working either :(
Is this something MVC specific? I am not very sure how it handles urls..(I am doing all this for the first time..). I otherwise didn't have any issues recording steps on other servers like google,apache.jmeter.test etc. where there were normal html pages with my current JMeter settings:
A Thread Group called 'Users' having a
Recording Controller
HTTP request defaults pointing to localhost:9080
A Workbench with
HTTP Proxy Server pointing to localhost:9080
My connection setting is also on localhost:9080.
I'm running JMeter from behind my company's proxy server successfully.
Thanks for any help :)
Realized later that it was not about URLs as such. My browser setting was probably faulty. I was using IE8..When I switched to Firefox, got more fine-grained control on the settings..These settings before recording worked for me:
Set manual proxy configuration to localhost,8081.
Check 'Use this proxy for all protocols'
Leave 'No proxy for' field blank
No 'Automatic proxy configuration'
Click OK.
After this if you try to access your site on IIS while JMeter proxy server hasn't started yet, it wouldn't, saying the connection was refused.
After this, go to JMeter and click the Start button to record. Try acessing the site again. It should come up :) Some more details:
There was no need to specify port number in HTTP request defaults. Just specified it in HTTP proxy server (8081 in my case).
For the session information to be saved properly, you must use a cookie manager (preferably, keep it at the top)..When you record, you get a HTTP header manager under each HTTP request if you had ticked the chekcbox against "Capture HTTP headers" in HTTP Proxy Server before recording..Copy this and add it as a child under your thread group.
Hope this helps someone struggling like me :)

Resources