Swagger showing "Found unknown parameters" error - java

I tried to create stubs for sample swagger specification as mentioned in Swagger CodeGen Documentation, but it does not work as intended to.
Exception in thread "main"
io.airlift.airline.ParseArgumentsUnexpectedException:
Found unexpected parameters: [-i, http://petstore.swagger.io/v2/swagger.json, -l, java] at io.airlift.airline.Cli.validate(Cli.java:148)
at io.airlift.airline.Cli.parse(Cli.java:116)
at io.airlift.airline.Cli.parse(Cli.java:97)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)

The solution of this issue on Swagger Documentation for creating server stub
documentation page.
Below is the command in case the link is obsolete or does not work :
java -jar swagger-codegen-cli-2.2.1.jar generate -i http://petstore.swagger.io/v2/swagger.json -l java

Related

Swagger codegen RX JAVA + Retrofit not working

I tried to export RX JAVA + Retrofit client from swagger hub , by entering Codegen Options and enabling check box of (useRxJava2) in the java client , however when i export the java client it does not work as expected and the code doesn't have neither retrofit nor rx java ! (uses oktthp only)
Also i tried to download the json file from swagger hub (Export -> Download Api) and followed the steps here
RX JAVA + Retrofit sdk generation using Swagger codegen
But when i run the command , i get this in the command line :
[main] INFO io.swagger.parser.Swagger20Parser - reading from openapi.json
[main] INFO io.swagger.parser.Swagger20Parser - reading from openapi.json
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codeg
en-ignore file found.
Exception in thread "main" java.lang.RuntimeException: missing swagger input or
config!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:13
2)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Any clue how can i bypass this ?
I could not manage to export client apis with rxjava and retrofit directly from swagger hub.
However i found out that the tool that used to make code generation by command line (code generator cli) is now called (openapi cli).
And now by looking again to this answer :
https://stackoverflow.com/a/41086671/2469133
Use the same command mentioned in the answer , but :
Download openapi cli from here :
https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli/4.1.3
Use:
openapi cli jar file instead of code generator cli jar file.
and
"-g" instead of "-l"

Marklogic 6 , Calling Resource Extension in java

I need to upload and use a xquery module to marklogic 6 like check-docAvailable.xqy. I tried using the dictionary.xqy sample given by ML6, it works well. But when I try to import my own xquery I'm getting below error.
ERROR :
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: config/resources write failed: Internal Server Error. Server Message: XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:2033)
at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:1918)
at com.marklogic.client.impl.ResourceExtensionsImpl.writeServices(ResourceExtensionsImpl.java:114)
at com.mobius.ln.ml.util.MLUtil$DictionaryManager.installResourceExtensionShortcut(MLUtil.java:279)
at com.mobius.ln.ml.util.MLUtil.main(MLUtil.java:202)
My Xquery Module:
xquery version "1.0-ml";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare variable $uri as xs:string external;
let $uri := $uri
return (
fn:doc-available($uri)
)
Please suggest me how to achieve this. Is there any mistake in Xquery?
I would suggest a read through Extending the REST API. Your XQuery module doesn't look like a REST extension. When I attempt to install your module via curl
curl --anyauth --user admin:admin -i \
-H "Content-type: application/xquery" \
--data-binary #/c/temp/a.xqy \
-X PUT http://localhost:8000/LATEST/config/resources/a
I get the following error:
{"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid a extension: could not parse XQuery extension a; please see the server error log for detail XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/a/assets/resource.xqy; a either is not a valid module or does not provide extension functions (delete, get, put, post) in the http://marklogic.com/rest-api/resource/a namespace"}}
This part of the error message looks significant:
XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy.
That looks like you deployed dictionary.xqy as a service extension, using the REST API, then tried to import that module into another. dictionary.xqy is apparently a main module, but only library modules can be imported. See XQuery Library Modules and Main Modules in the Application Developer's Guide for more info about that.
I think what's happening is that you're deploying a main module as a service extension, but such extensions are required to be library modules. Take a look at Guidelines for Writing XQuery Resource Service Extensions in the REST Application Developer's Guide, taking note of the Resource Extension Interface section.
Solution: rewrite your extension as a library module, using the required interface.

AWS Java NoSuchMethodError using IVONA Text to Speech

I have started using IVONA TTS and AWS is a dependancy of it, so I have also imported that to the project. My problem is that when running even the sample Java application I get the following error:
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.auth.AWS4Signer.presignRequest(Lcom/amazonaws/Request;Lcom/amazonaws/auth/AWSCredentials;Ljava/util/Date;)V
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequest(IvonaSpeechCloudClient.java:292)
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequestForGetUrl(IvonaSpeechCloudClient.java:270)
at com.ivona.services.tts.IvonaSpeechCloudClient.getCreateSpeechUrl(IvonaSpeechCloudClient.java:159)
at filetest.TextToSpeech.main(TextToSpeech.java:49)
TextToSpeech.java:49 being:
System.out.println("Requested URL: " + speechCloud.getCreateSpeechUrl(createSpeechRequest));
I'm using AWS version 1.10.12 (latest), but I've also tried several other previous versions only to get the same error. I've checked the class file "AWS4Signer", and the method "presignRequest" does exist, so I'm confused as to why I'm getting this error. If needed, here is the sample I used.
I'll be happy to add any more information if required. Any help would be greatly appreciated.
Your error is NoSuchMethod - I suspect that there is a version mismatch. Check from Ivona which version of AWS you need to use. According to Ivona's pom.xml it is 1.9.19.

The Grinder - unknown token 'timedTests'

I'm trying to run some simple tests with Grinder. I'm using the JMSReceiver script from the Script Gallery and trying to add some statistics, but my Agent throws an exception when it starts up.
A trivial example is:
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 timedTests)")
Running this throws an exception:
...Parse exception: Unknown token 'timedTests', at character 23 of '(/ userLong0 timedTests)'
I'm using grinder-3.11, jython-2.5.3, and I'm running the above Grinder script with:
CLASSPATH=lib/jython-standalone-2.5.3.jar:lib/grinder.jar
java -classpath $CLASSPATH net.grinder.Grinder etc/grinder.properties
where grinder.properties specifies the script to run.
Java version is "1.7.0_03-icedtea", which I think is JDK 7u60 on Centos 6.3.
About 5 minutes after posting the question, I found this wiki page. I don't know if it's the version of Grinder that I'm using, but in order to get this to work I have to change
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 timedTests)")
to
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 (count timedTests))")
The important difference being the addition of the "count" token. This solves my problem.

Java Stored Procedure using MQ

I need to create a Java stored procedure in Oracle. I have used IBM's sample class for creating an MQ message from a simple class outside of Java EE environment. I have tested the class by itself and it is working.
My Oracle vesrion is 11i.
When I am trying to add the jars used in the simple application to load to Oralce along with my simple class, I am getting errors about class not found, even if same jars work with the test case. I am stuck with this for over a week and am desperately hoping that someone would be able to help me with it.
Kinds of errors I am getting are like this from -v flag with loadjava utility on the client
on line 326 / 327, you see this:
creating : class com/ibm/mq/jms/admin/AP loading : class
com/ibm/mq/jms/admin/AP
and then at the end starting from line 6224 to end, it indicates that the above class can’t be resolved:
com/ibm/mq/jms/admin/APRCXI: ORA-29534: referenced object
xxxx.com/ibm/mq/jms/admin/AP could not be resolved
com/ibm/mq/jms/admin/APSDX: ORA-29534: referenced object xxxx.com/ibm/mq/jms/admin/AP could not be resolved exiting : errors
resolving class com/ibm/mq/jms/admin/AP
the command I used is:
c:\Oracle\product\11.2.0\client_1\bin\loadjava.bat -f -jarsasdbobjects
-prependjarnames -stoponerror -u xxxx/yyyy#SID -v -resolve lib\jms.jar lib\com.ibm.mqjms.jar lib\com.ibm.mq.jmqi.jar lib\dhbcore.jar
lib\fscontext.jar src\com\test\javasp\mq\JmsProducer.java
I also tried with -genmissing option with some additional jars ( list I found here ), but still get similar error for a different class.
Other issue with this that I am facing is that if I get an error and try to use the dropjava command from Oracle, it doesn't work either.
I also saw from this link, that this person was successful, but unfortunately, he/she didn't indicate how they used loadjava to load the jars.
If i can provide any other information, please let me know.
If anyoneone has any idea on how to get the Java Stored Procedure to use IBM MQ working with Oracle 11i, I would really appreciate the help.
Found a detailed answer in this blog entry. I tried it and it worked for me.
In Oracle there is no concept of CLASSPATH, so the standard MQ Client install is useless. You can only load the jars reference by your app within the database schema. Classes are resolved when loaded with the -r option. You can further on specify your own resolved using -r -Resolver (schemas). (check Oracle docs for exact format). So in effect the database schemas becomes the classpath.
Using Websphere MQ classes for Java poses a number of problems, you have to ensure that the Oracle JDK version is at an appropriate support level to connect to the chosen MQ server version. Check the system requirements for websphere MQ Vx.x. You should find IBM's web references. check the support for MQ classed for java.
I have such an issue at the moment trying to connect to Mq using Oracle 10 and JDK 1.4.2. I had to recompile my Java code using JDK 1.4.x. This does not work and I assume it is because I connect to MQ 7.0.1.7 which requires JRE 1.7 as minimum.

Categories