Some help needed i was trying to generate the swagger client code using the command for an Expedia mobile API
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://www.expedia.co.jp/static/mobile/swaggerui/swagger.json -l java -o samples/client/expedia
The code generation fails with the following error
[main] ERROR io.swagger.codegen.languages.JavaClientCodegen - No Type defined for Property null Exception in thread "main" java.lang.RuntimeException: Could not generate model
'detailedRentalFare'
The type attribute within the DetailedRentalFare is where it fails. I am not sure why this fails since the data type is defined. I am newbie to Swagger any help will be greatly appreciated
From #wing328's answer, even if this isn't your service to fix, you can still generate a client from it.
First, just download the JSON locally:
wget https://www.expedia.co.jp/static/mobile/swaggerui/swagger.json > expedia.json
Next, modify the value in the JSON that #wing328 pointed out
Finally, rerun your codegen using the static file as the source:
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i ./expedia.json \
-l java \
-o samples/client/expedia
It's always nice to let the service owner know about the issue, too, since fixing it will help with their adoption of the api.
Answer provided by #wing328
the issue is caused by incorrect type for array, e.g.
"detailedRentalFare": {
"properties": {
"rateTerm": {
"type": "string",
"description": "It can have the following values: HOURLY, DAILY, WEEKLY, WEEKEND, MONTHLY, TOTAL, TRIP"
},
"rate": {
"$ref": "mobilePrice"
},
"priceBreakdownOfTotalDueToday": {
"type": "array",
"items": {
"type": "rentalFareBreakdownItem"
}
},
It should be
"items": {
"$ref": "rentalFareBreakdownItem"
}
or even better
"items": {
"type": "object",
"$ref": "rentalFareBreakdownItem"
}
After correcting this i was able to generate the code.
Related
Once I had set launch.json and I ran gdb and debugged in my code successfully until something happened and all breakpoint became "gray" with the such message:
"Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained."
However, debugger attaches to running program and I even can make steps from main, but still breakpoint are not hit... This is C++ project that is built with cmake with gcc with -DCMAKE_BUILD_TYPE=DEBUG flag.
launch.json is this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "./MyProject/project",
"args": [],
"stopAtEntry": false,
"cwd": "/home/AA/workspace",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerServerAddress": "/*Cannot write here, but it's fine*/",
"sourceFileMap": {/*Cannot write here, but it*/}
},
]
}
How do I fix this problem?
I was looking for an answer in other resources and the most solutions say that you should -g option if you compiler a project with gcc. It wasn't my case because I use cmake but I had one detail that I debugged code that was run in docker.
When you work with files in VS code from your user and docker runs project from another user, you should add the option "sourceFileMap": {} in launch.json:
"sourceFileMap": {
"/home/user/project/file.hpp" : "/home/YourNameBeyondDocker/project/file.hpp",
...
I added wrong path in this option. When I took it out, my debugger finally started hitting breakpoints!
I have an Elasticsearch deployment on Kubernetes (AKS). I'm using the official Elastic's docker images for deployments. Logs are being stored in a persistent Azure Disk. How can I migrate some of these logs to another cluster with a similar setup? Only those logs that matches a filter condition based on datetime of the logs needs to be migrated.
Please use Reindex API for achieving the same
POST _reindex
{
"source": {
"remote": {
"host": "http://oldhost:9200",
"username": "user",
"password": "pass"
},
"index": "source",
"query": {
"match": {
"test": "data"
}
}
},
"dest": {
"index": "dest"
}
}
Note:
Run the aforementioned command on your target instance.
Make sure that the source instance is whitelisted in elasticsearch.yml
reindex.remote.whitelist: oldhost:9200
Run the process asynchronously using below query param
POST _reindex?wait_for_completion=false
I have used a method mentioned here to add credential to Jenkins programmatically. It worked successfully for adding secret texts and secrets files. But it gives an exception while adding ssh private keys. Below is the curl command I used.
curl -X POST 'http://localhost:8080/jenkins/credentials/store/system/domain/_/createCredentials' \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "temp",
"username": "temp",
"privateKeySource": {
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource",
"privateKeyFile": "/home/udhan/private-key.pem",
},
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
}
}'
Here is the exception I get.
A problem occurred while processing the request.
Please check our bug tracker to see if a similar problem has already been reported.
If it is already reported, please vote and put a comment on it to let us gauge the impact of the problem.
If you think this is a new issue, please file a new issue.
When you file an issue, make sure to add the entire stack trace, along with the version of Jenkins and relevant plugins.
The users list might be also useful in understanding what has happened.</p><h2>Stack trace</h2><pre style="margin:2em; clear:both">org.kohsuke.stapler.NoStaplerConstructorException: There's no #DataBoundConstructor on any constructor of class com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource
at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:265)
at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:765)
at org.kohsuke.stapler.RequestImpl.access$200(RequestImpl.java:83)
at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:678)
I've just bumped into this same problem right now. Rather than using a pem file, I ended up putting the SSH pem's value into a variable and passed it that way instead.
CRUMB=$(curl -s 'https://{{jenkins_admin_username}}:{{jenkins_admin_password}}#localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
SSH_KEY="$(cat /your/ssh/pem)"
curl -H $CRUMB -X POST 'https://{{jenkins_admin_username}}:{{jenkins_admin_password}}#localhost:8080/credentials/store/system/domain/_/createCredentials' --data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "'test-jenkins-id'",
"username": "'test-username'",
"password": "",
"privateKeySource": {
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource",
"privateKey": "$SSH_KEY",
},
"description": "test-jenkins-ssh description",
"stapler-class": "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
}
}'
Not that I went with https instead of http here as we're passing things that should be secured.
I hope this helps.
I have an Electron app that I was able to debug in Visual Studio Code. After I upgraded to version 0.10.8 it will no longer run.
I am getting the error message below in my launch.json file:
Relative paths will no longer be automatically converted to absolute ones. Consider using ${workspaceRoot} as a prefix.
Absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
Here is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "My First Electron App",
"type": "node",
"request": "launch",
"program": "$(workspaceRoot}/app/main.js", //ERROR
"stopOnEntry": false,
"args": [],
"cwd": "$(workspaceRoot}",
"runtimeExecutable": "$(workspaceRoot}/node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/Electron", //ERROR
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
]
}
I am getting the green squiggly line mentioned for the two lines with //ERROR at the end.
I saw this article, but honestly was familiar with VS Code enough to understand how this should be implemented: https://code.visualstudio.com/Docs/editor/tasks#_variable-substitution
UPDATE
I replaced the value for "cwd" with "${workspaceRoot}" as recommended by Isidor. The green squiggly line went away.
I updated the error message that I am still seeing on the other two lines.
When I hit F5 I get this error message:
request 'launch': runtime executable '/private/var/git/electron-vs-code/$(workspaceRoot}/node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/Electron' does not exist
There is a typo in your json. Change the parenthesis after the $ in $(workspaceRoot} to a curly brace. This should at least fix the warning.
Even though you are getting the relative path warning VSCode still automatically converts relative to absolute paths in 0.10.8. To get rid of the warnings for "cwd", instead of "." please put "${workspaceRoot}".
What happens when you run try to debug your electron app, do you see some other error, since the relative to absolute can not be the true cause of this. If you command palette / open developper tools -> do you see some error in the console?
I'm trying to install the following using composer:
https://github.com/Lusitanian/PHPoAuthLib
I tried using:
"lusitanian/oauth": "~0.3"
but that didn't work, the version being used now was something I found online that supposedly works.
When I try to run the following composer install commmand I get a message saying that the package couldn't be found. It doesn't appear in the composer.json file (not sure if its meant to). This is the first time I've tried to install this so any tips on getting this working would be much appreciated.
php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package lusitanian/oauth 1.0.0 could not be found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
{
"name": "lusitanian/oauth",
"description": "PHP 5.3+ oAuth 1/2 Library",
"keywords": ["oauth", "authentication", "authorization", "security"],
"license": "MIT",
"authors": [
{
"name": "David Desberg",
"email": "david#daviddesberg.com"
},
{
"name": "Pieter Hordijk",
"email": "info#pieterhordijk.com"
}
],
"require": {
"php": ">=5.3.0",
"lusitanian/oauth": "0.1.*#dev"
},
"require-dev": {
"symfony/http-foundation": "~2.1",
"predis/predis": "0.8.*#dev",
"phpunit/phpunit": "3.7.*"
},
"suggest": {
"symfony/http-foundation": "Allows using the Symfony Session storage backend.",
"predis/predis": "Allows using the Redis storage backend.",
"ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client."
},
"autoload": {
"psr-0": {
"OAuth": "src",
"OAuth\\Unit": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
}
}
Changing this:
"lusitanian/oauth": "0.1.*#dev"
to this:
"lusitanian/oauth": "1.0.*#dev"
Fixed it :)