How to use swagger code-generator - swagger

I am working on creating the rest client and I will be calling an API which gives this big json output .I want to know how to create the Pojo classes automatically by inputting this json to swagger code gen and let it create my pojo classes for me which will save manual time . Here is what I have tried
To generate a PHP client for http://petstore.swagger.io/v2/swagger.json, please run the following
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l php \
-o /var/tmp/php_api_client
(if you're on Windows, replace the last command with java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client)
I could not get pass the mvn clean package and it is giving the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project swagger-codegen: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: io/swagger/models/properties/Property
Anyone have successfully used this swagger ? or even if you can suggest any other framework which can do this functionality would be of great help . Thanks in advance ..,
I seen the following link
Update code generated by Swagger code-gen
and able to run the application .. Can anyone explain if I can use this to get the pojo object created for the json input?

Your problem is not swagger itself. Your problem comes from maven and it says that it can't find a certain class. I downloaded the repo and it compiles on my machine with mvn validate package. Make sure you have .m2\repository\io\swagger\swagger-models... in your standard maven cache directory. Thats the dependency, which has the Property class.
Actually maven should download it right before compiling. Check the maven output for connection errors or unreachable downloads etc.

Related

How do I locate or generate the .NET source files for AWS CDK

I'm trying to get the .NET source code, not the TypeScript source code. I've googled for quite a while and tried to dig through the main source code repository for documentation on this. Not finding answers.
It doesn't exist. CDK is written in TypeScript and then converted to other languages at release using their jsii tool.
You can generate the .NET code using jsii yourself if that's what you're after. The CDK github documentation explains how to do this:
Packing involves generating CDK code in the various target languages and packaging them up to be published to their respective package managers. Once in a while, these will need to be generated either to test the experience of a new feature, or reproduce a packaging failure.
To package a specific module, say the #aws-cdk/aws-ec2 module:
$ cd <root-of-cdk-repo>
$ docker run --rm --net=host -it -v $PWD:$PWD -w $PWD jsii/superchain
docker$ cd packages/#aws-cdk/aws-ec2
docker$ ../../../scripts/foreach.sh --up yarn run package
docker$ exit

Jenkins integration with JMeter - build is failed giving **Error: Unable to access jarfile ApacheJMeter.jar errorlevel=1**

Jenkins Cosole output :updated 2
When executing the Jmeter .JMX file using JMeter non GUI mode, it is working fine and I am able to get the .JTL file, but when I am trying to trigger the build using Jenkins it is getting failed giving Error: Unable to access jarfile ApacheJMeter.jar
errorlevel=1 as message from console output .
Please note that I have added Perfomance Plugin in Jenkins and made jmeter.save.saveservice.output_format=xml enabled in JMeter user properties. Please help if I am missing anything to setup the configuration.
Build cmd command
C:\jmeter\bin\jmeter -J jmeter.save.saveservice.output_format=xml -n -t C:\jmeter\bin\edueka.jmx -l C:\jmeter\bin\report3.jtl
code from CMD - JMeter non GUI
JMeter Jar file access from CMD
There is nothing wrong with your command, it should work normally.
Double check that the main JMeter executable .jar exists and the user which executes Jenkins process has correct permissions to access this file:
c:\jmeter\bin\ApacheJMeter.jar
The most common mistake is that users download source bundle of JMeter instead of the binary
Also the correct syntax for passing JMeter Properties via -J command line argument is:
J needs to be capital
remove the space between J and the property name
C:\jmeter\bin\jmeter -Jjmeter.save.saveservice.output_format=xml -n -t C:\jmeter\bin\edueka.jmx -l C:\jmeter\bin\report3.jtl
Also currently there is no need to switch JMeter results format to XML, Jenkins Performance Plugin is capable of processing JMeter results files in .CSV format as well

Svcutil --update error output not making sense

I am trying to update a soap service reference using svcutil.
I have tried:
dotnet svcutil -u --projectFile "C:\projects\MySolution\MyProject\MyProject.csproj"
Which gives the nonsensical error:
Warning: The specified --projectFile option is not expected in the current operational context of the tool!
Error: The --update option requires a project to be specified, please use the --projectFile option to specify the project to use.
And:
dotnet svcutil -u --projectFile "C:\projects\MySolution\MyProject\MyServiceFolder"
Same Error
And I have tried:
dotnet svcutil -u --projectFile "C:\projects\MySolution\MyProject\MyServiceFolder\dotnet-svcutil.params.json"
Same error.
I have even tried:
dotnet svcutil -u "C:\projects\MySolution\MyProject\Nexus.Services.csproj"
and
dotnet svcutil -u "C:\projects\MySolution\MyProject\MyServiceFolder"
But that gives the error:
Error: The --update option requires a project to be specified, please use the --projectFile option to specify the project to use.
I cannot find a single example anywhere of how this command should be run.
Has anyone gotten this to work?
To update a service reference using dotnet svcutil --update ..., it needs to find both the project file and the service reference configuration.
From the help dotnet-svcutil --help:
--projectFile <project file> The project file to add the client to (if any). (Short Form: -pf).
--update <web service reference> Updates an existing web service reference. If the project contains more than one web service reference, the name of the web service reference to be updated is required. (Short Form: -u).
When you run the svcutil in a different directory than the one containing your project file, you will need to tell it explicitly where your project is using --projectFile.
So, the easiest solution is to run the update command from the directory containing your project and specify where the service reference is:
dotnet svcutil -u .\path\to\ServiceReference
You can specify the path of the directory containig the dotnet-svcutil.params.json file, or an explicit path to a config file.
From the examples printed when running dotnet svcutil -h:
dotnet-svcutil -u ServiceReference
Update existing web service reference named ServiceReference. The command need to be executed under directory which contains the project file.

Jenkins cannot find g++

I am learning all of these new technologies. I have a home server for private development with latest version of centos 7.6 (minimal installation). I am trying to keep the server as light as possible.
I have installed jenkins (v2.164.2) and it is up and running correctly. I have created a new Freestyle project to compile a g++ project hosted on another own gogs server. I have defined gogs url and credentials and then added the following in the execute shell command:
which g++; make clean; make;
When I press the "Build Now" button, it fails with the following message:
which: no g++ in (/sbin:/usr/sbin:/bin:/usr/bin)
Cloning the repository, etc seems to be working fine.
I have NOT installed the default g++ version but instead I have installed the one that comes with devtools-7 (g++ v7.3.1). I have created a new file under /etc/profile.d/devtools.sh with the following text:
!#/bin/bash
source scl_source enable devtoolset-7
If I login into a bash shell in the server and then run which g++, I get the expected output.
Finally, the question: why jenkins is not picking this up? As far as I know, adding that file under /etc/profile.d ensures that everyone will be able to access g++.
Thanks very much in advance for any help.
I have managed to fix it at the end. I leave the question just in case someone else runs into the same problem. I only had to add the following line as first line in the "execute shell" command field:
#!/bin/bash -l
make clean; make;
That #!/bin/bash -l did the trick. (Please mind the -l).
Found it here: What shell does Jenkins use?

How can I stage additional files using Google Cloud Dataflow?

I am reading a bunch configuration files in my Google Dataflow program and wonder what is the best way to stage them. Currently I do it this way and the system cannot find them.
FileReader filereader1 = new FileReader("config_1.csv");
FileReader filereader2 = new FileReader("config_2.csv");
config_1.csv and config_2.csv are stored in ./target/classes/org/model/examples/
My running script looks like this:
mvn compile exec:java -Dexec.mainClass=org.model.examples.MyPipeline \
-Dexec.args="--runner=DataflowRunner \
--project=mortgage-data-warehouse
--gcpTempLocation=gs://my-project-bucket/tmp \
--inputFile=gs://my-project-bucket/Data/input.txt \
--filesToStage=./target/classes/org/datamodel/examples/config_1.csv, ./target/classes/org/datamodel/examples/config_2.csv" \
-Pdataflow-runner
I have got the error
java.io.FileNotFoundException: config_1.csv (The system cannot find the file specified)
I wonder if this is the proper way to set --filesToStage.
For small configuration files, it is better to read files from resource folder such as what has been written by this link and avoid the complication of using --filesToStage

Resources