Swagger integration into Dropwizard - api

I am fairly new to drop wizard (dropwizard.io) & just completed their tutorial. I would like to integrate Swagger (swagger.io) into this sample app.
I found:
github.com/federecio/dropwizard-swagger-sample-app
github.com/federecio/dropwizard-swagger
The generated JSON seems to be quite similar, however I cannot expand the REST resources to see their respective operations.
The only difference I noted was that the example code of the swagger integration uses SERVER whereas the official drop wizard example is using APPLICATION
Here an Image (i.stack.imgur.com/QzhPa.png)
Please could you tell me what is wrong in my approach.
Thank you very much. Here is the code to my approach: https://github.com/geoHeil/dropwizardSwaggerIntegrationNotWorking
Edit:
for api - docs {
"apiVersion": "0.0",
"swaggerVersion": "1.2",
"apis": [{
"path": "/sample"
}, {
"path": "/hello-world",
"description": "Operations about greetings"
}]
}
for sample {
"apiVersion": "0.0",
"swaggerVersion": "1.2",
"basePath": "http://geoHeil.local:8080",
"resourcePath": "/sample",
"apis": [{
"path": "/sample",
"operations": [{
"method": "GET",
"summary": "Sample endpoint",
"notes": "",
"type": "void",
"nickname": "get",
"authorizations": {},
"parameters": []
}]
}, {
"path": "/sample/hello-with-path-param/{name}",
"operations": [{
"method": "GET",
"summary": "Sample endpoint with path param",
"notes": "",
"type": "void",
"nickname": "getWithPathParam",
"authorizations": {},
"parameters": [{
"name": "name",
"required": true,
"type": "string",
"paramType": "path"
}]
}]
}, {
"path": "/sample/hello-with-query-param",
"operations": [{
"method": "GET",
"summary": "Sample endpoint with query param",
"notes": "",
"type": "void",
"nickname": "getWithQueryParam",
"authorizations": {},
"parameters": [{
"name": "name",
"required": false,
"type": "string",
"paramType": "query"
}]
}]
}]
}
for hello - world {
"apiVersion": "0.0",
"swaggerVersion": "1.2",
"basePath": "http://geoHeil.local:8080",
"resourcePath": "/hello-world",
"apis": [{
"path": "/hello-world",
"operations": [{
"method": "GET",
"summary": "Greetings endpoint",
"notes": "",
"type": "void",
"nickname": "sayHello",
"authorizations": {},
"parameters": [{
"name": "name",
"required": false,
"items": {
"type": "string"
},
"paramType": "query"
}]
}]
}]
}

There is now a Swagger spec 2.0 example available:
https://github.com/swagger-api/swagger-samples/tree/master/java/java-dropwizard
This uses the latest swagger core libraries with minimal dependencies. Note, the version of Jackson needed to be updated from dropwizard's 2.3.2 to swagger's 2.4.2.

I don't see anything obvious in the generated JSON that would cause the operations to not expand.
However, the swagger-ui bundled with the dropwizard-swagger package is a bit old. I would try using the newer version of swagger-ui.
I'm not sure if it would conflict with the bundled swagger-ui or not, but basically you need to clone https://github.com/swagger-api/swagger-ui and copy the /dist directory to your static content.
Another option is to run the swagger-ui locally (just for testing purposes) but opening the /dist/index.html and pointing it at your /api-docs directory. However, in order for that to work properly, you'd need to enable CORS - https://github.com/swagger-api/swagger-ui#cors-support.
EDIT:
I didn't notice you edited the question with the JSON, and it made it easier to read.
There's a problem with the GET /hello-world operation. It looks like it's supposed to accept an array of strings as a query parameter, but the parameter is missing a "type": "array" in its definition. I can't say what may be causing it without seeing the method's declaration and its annotations, but that's what you should be looking at.

Related

How can I use a map in UI5 GeoMap?

I should use the basemap.at free online map to my SAPUI5 application. I can't achieve, to use it.
var oMapConfig = {
"MapProvider": [{
"name": "GMAP",
"Source": [{
"id": "s1",
"url": 'https://maps3.wien.gv.at/basemap/bmaphidpi/normal/google3857/9/178/278.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3'
}]
}],
I don't where could I find the good URL, or what should I set in.
Tried to find the API and other hints, but didn't find any solution and I don't know how could I do it. I think it's easy (basemap.at, wien.gv.at, data.gv.at) but I don't know what to do.
I tried it with Google Maps, with this URL: https://mt.google.com/vt/lyrs=s&x={X}&y={Y}&z={LOD} and it works well.
Following #BoghyonHoffmann suggestion, I believe you should use the following url:
https://maps3.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3
Also you could make use of all of available sources:
var oMapConfig = {
"MapProvider": [{
"name": "GMAP",
"Source": [{
"id": "s0",
"url": "https://maps.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3"
},{
"id": "s1",
"url": "https://maps1.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3"
},{
"id": "s2",
"url": "https://maps2.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3"
},{
"id": "s3",
"url": "https://maps3.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3"
},{
"id": "s4",
"url": "https://maps4.wien.gv.at/basemap/bmaphidpi/normal/google3857/{LOD}/{X}/{Y}.jpeg?api_key=a73befc7-575f-48cb-8eb9-b05172a8c9e3"
}]
}],

API testing : Dynamic payload and dynamic assertions [duplicate]

I want to construct a complex POJO during run time based on the scenario .
In the below sample request structure consider addresses.line1 as mandatory field
And I dont have to pass the other fields everytime but need to do on test cases basis.
{
"site": [{
"code": "string",
"mrn": "string"
}
],
"email": ["string"],
"addresses": [{
"line1": "string",
"line2": "string",
"city": "string",
"state": "string",
"postalCode": "string"
}
],
"names": [{
"first": "string",
"middle": "string",
"last": "string",
"suffix": "string"
}
]
}
Ex:
For TestCase#1 I need only below JSON:
{
"addresses": [{
"line1": "string"
}
]
}
Where as for TestCase#2 I need below JSON
{
"email": ["string"],
"addresses": [{
"line1": "string",
"line2": "string"
}
],
"names": [{
"first": "string",
"last": "string"
}
]
}
I referred https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/outline/examples.feature
but the example was pretty straight forward with replaceable values.
I was looking for something like #JsonInclude(JsonInclude.Include.NON_DEFAULT)
Karate is designed to completely avoid POJO-s and give you complete control over creating and modifying complex JSON. So I suggest you temporarily forget about POJO-s and Java, else you won't get the best out of Karate.
There are a few ways to do this, but here is one. First store the complex JSON in a file, called main.json
Then creating the different variants is simple:
Background:
* def main = read('main.json')
Scenario: one
* def payload = karate.filterKeys(main, 'addresses')
Scenario: two
* def payload = main
* remove payload.site
I suggest you read the docs on reading files for more ideas, look out for embedded expressions.
Also see: https://stackoverflow.com/a/51896522/143475

REST dataset for Copy Activity Source give me error Invalid PaginationRule

My Copy Activity is setup to use a REST Get API call as my source. I keep getting Error Code 2200 Invalid PaginationRule RuleKey=supportRFC5988.
I can call the GET Rest URL using the Web Activity, but this isn't optimal as I then have to pass the output to a stored procedure to load the data to the table. I would much rather use the Copy Activity.
Any ideas why I would get an Invalid PaginationRule error on a call?
I'm using a REST Linked Service with the following properties:
Name: Workday
Connect via integration runtime: link-unknown-self-hosted-ir
Base URL: https://wd2-impl-services1.workday.com/ccx/service
Authentication type: Basic
User name: Not telling
Azure Key Vault for password
Server Certificate Validation is enabled
Parameters: Name:format Type:String Default value:json
Datasource:
"name": "Workday_Test_REST_Report",
"properties": {
"linkedServiceName": {
"referenceName": "Workday",
"type": "LinkedServiceReference",
"parameters": {
"format": "json"
}
},
"folder": {
"name": "Workday"
},
"annotations": [],
"type": "RestResource",
"typeProperties": {
"relativeUrl": "/customreport2/company1/person%40company.com/HIDDEN_BI_RaaS_Test_Outbound"
},
"schema": []
}
}
Copy Activity
{
"name": "Copy Test Workday REST API output to a table",
"properties": {
"activities": [
{
"name": "Copy data1",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "RestSource",
"httpRequestTimeout": "00:01:40",
"requestInterval": "00.00:00:00.010",
"requestMethod": "GET",
"paginationRules": {
"supportRFC5988": "true"
}
},
"sink": {
"type": "SqlMISink",
"tableOption": "autoCreate"
},
"enableStaging": false
},
"inputs": [
{
"referenceName": "Workday_Test_REST_Report",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "Destination_db",
"type": "DatasetReference",
"parameters": {
"schema": "ELT",
"tableName": "WorkdayTestReportData"
}
}
]
}
],
"folder": {
"name": "Workday"
},
"annotations": []
}
}
Well after posting this, I noticed that in the copy activity code there is a nugget about "supportRFC5988": "true" I switched the true to false, and everything just worked for me. I don't see a way to change this in the Copy Activity GUI
Editing source code and setting this option to false helped!

Add Account (POST) Endpoint No Longer Working in new Yodlee API

OVERVIEW
I am not sure what happened, as I have not touched my code that interacts with the Add Account endpoint in Yodlee (POST /{cobrandName}/v1/providers/{providerId}), but it has become broken (it was working as of Thursday). I am now getting this reply:
{ errorCode: 'Y400',
errorMessage: 'Null argument specified',
referenceCode: 'RB_134ae91e-4c80-4ad5-aac5-243ca428421d' }
DETAILS
I have the appropriate route params inserted into this POST /{cobrandName}/v1/providers/{providerId} and am passing a stringified JSON object as the request body (per the documentation) that looks like this:
{
"provider": [{
"id": 492,
"name": "Fidelity Investments",
"loginUrl": "https://login.fidelity.com/ftgw/Fas/Fidelity/RtlCust/Login/Init?AuthRedU",
"baseUrl": "http://www.fidelity.com/",
"favicon": "https://moneycenter.ydlstatic.com/fastlink/appscenter/siteImage.fastlink.do?access_type=APPS_CENTER_PRODUCTION&siteId=492&imageType=FAVICON",
"logo": "https://moneycenter.ydlstatic.com/fastlink/appscenter/siteImage.fastlink.do?access_type=APPS_CENTER_PRODUCTION&siteId=492&imageType=LOGO",
"status": "Supported",
"mfaType": "Multiple levels of strong authentication.",
"oAuthSite": false,
"lastModified": "2016-03-31T10:39:36Z",
"forgetPasswordUrl": "http://personal.fidelity.com/accounts/services/content/pinchange.shtml.tvsr",
"containerNames": ["tax", "investment"],
"loginForm": {
"id": 172,
"forgetPasswordURL": "http://personal.fidelity.com/accounts/services/content/pinchange.shtml.tvsr",
"formType": "login",
"row": [{
"id": 4140,
"label": "Username",
"form": "0001",
"fieldRowChoice": "0001",
"field": [{
"id": 358,
"name": "LOGIN",
"maxLength": 15,
"type": "text",
"value": "07ceb28fc8b71dc3e08126e0169022419c114e02cbca7fcfb2e11b939d805c898310d0741bcc0a76943227a38c02e66fd5a5fb132a3c0fb4c663102b9e0947c99953f15fa051ac95fdf9a3ee7d461d33ff11482a3cf973ccd3c2aba6d494deb6ddd1d0dfc89ee0bfa991bf24e19d07bd9f066bbde4fd74ed88f3808ab7420f1430b1ead362a32dd26d5b077f263c83469c37a3c8816b7eaa243f9f89dc4ad4e023642ba1aa651d4b371f613d37619279d90187d11bbd4404896d18605c028bd55461c6e11b47a8aad8ea93d483db7c1211728c9b1222a86811a106077ae5525c75f427520d52478e48f22f6ae11a21bcb42e772befa2e83570c4b4d7c3a54619",
"isOptional": false,
"valueEditable": true
}]
}, {
"id": 4139,
"label": "Password",
"form": "0001",
"fieldRowChoice": "0002",
"field": [{
"id": 357,
"name": "PASSWORD",
"maxLength": 20,
"type": "password",
"value": "285968df9ddf385b2da03d7247533dd0f7dbf6d951c0a6a92bad7701868d4941bcdfe7a41167f3bb0a47cb5ae22557444f83a641318c1985035c6e2c7e7e11a4e71ac52965ad26845ee64a13a2a61c07945870b7c009aba673e01b074fc047e9b08c20cbde0cb36a6068a9d07b4cad7a777f8f6654dd8436527d6017e3a81af68f1dbbfabc52a93a2f8423b342b243316248cebb549bed7433f77a90aae4a3c1c892a725872f77a369407741be98715b39039b547f735e92748ddd5d389c4de3082684c1f5f5b1917ceb34348010866ce6cb649d6e4dac4c45d85c4a729c67fb643c34e704278f3a15626bbe73cddf69cfe5df8bcdd5682415afe952585da800",
"isOptional": false,
"valueEditable": true
}]
}]
}
}]
}
The form values are encrypted via PKI as per the documentation, using the key provided by the appropriate API endpoint, and I have both a cobrand session token and a yodlee user session token in the authentication headers ('Authorization': 'cobSession={appToken}, userSession={token}'). I was previously receiving back the expected 'refresh info' response using the same exact structure and process. I'm trying to understand what the 'null argument' referenced in the error is.

How to get number of googleplus page followers?

is there actually a possibility to get the number of followers of my googleplus-page. the following script - which I found here in an earlier post - doesn't work (no output):
$google_api_key = 'XYZXYZXYZXYZXYZXYZ';
$page_id = 'MYNUMERICPAGEID';
$data = #file_get_contents("https://www.googleapis.com/plus/v1/people/$page_id?key=$google_api_key");
$data = json_decode($data, true);
echo $data['plusOneCount'];
thank you!
There could be a few things wrong:
Don't have an updated project on the Developer Console.
Didn't enable the API for that project.
Are past thresholds/quotas.
Try the following:
Login to your Google Developers Console
You'll need a project.
If you don't have a project, create one.
Enable "Google Plus API" on that project.
Confirm usage/quotes are within tolerance and you haven't gone past.
From there, your call should work as normal:
GET https://www.googleapis.com/plus/v1/people/{USER_ID}?key={YOUR_API_KEY}
In my case, I'm querying Google's's page, so {USER_ID} = 116899029375914044550. I can then see the plusOneCount:
{
"kind": "plus#person",
"etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/bTf-sq_Sg3fLAFijixPfjtKM5f8\"",
"urls": [
{
"value": "http://www.google.com",
"type": "website",
"label": "www.google.com"
},
{
"value": "http://www.google.com/support/",
"type": "other",
"label": "Google Help"
},
{
"value": "http://googleblog.blogspot.com/",
"type": "other",
"label": "Official Blog"
},
{
"value": "http://twitter.com/#!/google",
"type": "other",
"label": "#google"
},
{
"value": "http://www.google.com/about/corporate/company/",
"type": "other",
"label": "Company Info"
},
{
"value": "http://www.google.com/press/",
"type": "other",
"label": "News"
},
{
"value": "http://www.google.com/press/google-directory.html",
"type": "other",
"label": "More Google pages"
}
],
"objectType": "page",
"id": "116899029375914044550",
"displayName": "Google",
"tagline": "News and updates on Google's products, technology and more",
"aboutMe": "<p>Welcome to Google's official page. Here, you'll find product news and announcements, company updates, glimpses into what it's like to work at Google, discussions on technology and the web, and much more. </p><p><span>Given the volume of feedback we receive here, we may not be able to respond individually to every comment and we're not able to provide product support (if you're having product issues, please visit our Help Center). Rest assured we're paying attention, and we're always eager to hear from you.</span></p>",
"url": "https://plus.google.com/+google",
"image": {
"url": "https://lh4.googleusercontent.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAAC9wQ/JD8tdz3bFTM/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"plusOneCount": 10757884,
"circledByCount": 7692912,
"verified": true,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh4.googleusercontent.com/-PLPoXvnN0XI/UTdr4xTtuHI/AAAAAAAA_1U/p1n_Za3BZUg/s630-fcrop64=1,00000000fe06fe97/g_plus_background.png",
"height": 528,
"width": 940
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
}
}