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"
Related
I have a Java application running with an OTel agent to collect telemetries and send them to the New Relic platform.
Configuration of OTel Java agent:
-javaagent:./agents/opentelemetry-javaagent-all.jar
-Dotel.traces.exporter=otlp
-Dotel.resource.attributes=service.name=my-application
-Dotel.exporter.otlp.endpoint=https://otlp.nr-data.net:4317
-Dotel.exporter.otlp.headers=api-key=${NEW_RELIC_LICENSE_KEY}
When this app is starting an error occurs:
Caused by: java.lang.IllegalArgumentException: cannot find a NameResolver for https://otlp.nr-data.net:4317
How to resolve this problem?
I would try:
-Dotel.exporter.otlp.endpoint=otlp.nr-data.net:4317
OTLP endpoint should be officially URL (so scheme part should be included), but some implementations need it without scheme part. I guess this is your case.
The problem has been solved for me when adjusting Dockerfile forcing the download of OTel java agent on the image build process.
From:
COPY ./agents/opentelemetry-javaagent-all.jar .
To:
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.12.1/opentelemetry-javaagent.jar .
I've got a Spring Boot application that'd I'd like to automatically generate traces for using the OpenTelemetry Java agent, and subsequently upload those traces to Google Cloud Trace.
I've added the following code to the entry point of my application for sending traces:
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.addSpanProcessor(
SimpleSpanProcessor.create(TraceExporter.createWithDefaultConfiguration())
)
.build()
)
.buildAndRegisterGlobal();
...and I'm running my application with the following system properties:
-javaagent:path/to/opentelemetry-javaagent-all.jar \
-jar myapp.jar
...but I don't know how to connect the two.
Is there some agent configuration I can apply? Something like:
-Dotel.traces.exporter=google_cloud_trace
I ended up resolving this as follows:
Clone the GoogleCloudPlatform /
opentelemetry-operations-java repo
git clone
git#github.com:GoogleCloudPlatform/opentelemetry-operations-java.git
Build the exporter-auto project
./gradlew clean :exporter-auto:shadowJar
Copy the jar produced in exporter-auto/build/libs to my target project
Run the application with the following arguments:
-javaagent:path/to/opentelemetry-javaagent-all.jar
-Dotel.javaagent.experimental.extensions=[artifact-from-step-3].jar
-Dotel.traces.exporter=google_cloud_trace
-Dotel.metrics.exporter=none
-jar myapp.jar
Note: This setup does not require any explicit code changes in the target code base.
Micronaut CLI is very useful while creating the application, however the command to create a controller is not present in the CLI.
Micronaut Version: 2.0.3
From the micronaut documentation we have a command for profile https://docs.micronaut.io/2.0.0.M3/guide/index.html#cli
$ mn profile-info service
Profile: service
------------------
The service profile
Provided Commands:
--------------------
create-bean Creates a singleton bean
create-client Creates a client interface
create-controller Creates a controller and associated test
create-job Creates a job with scheduled method
create-test Creates a simple test for the project's testing framework
create-websocket-client Creates a Websocket client
create-websocket-server Creates a Websocket server
help Prints help information for a specific command
Provided Features:
------------------
...
When I run the command mn profile-info service I get an error as
I have only below options
I am trying to create a controller from the cli
Profiles were only in Micronaut version 1.x. So profile related commands like mn profile-info service are not available in Micronaut version 2.x.
When you create the project end enter the project directory you can use these additional mn commands:
feature-diff - Produces the diff of an original project with an original project with additional features.
create-job - Creates a job with scheduled method
create-client - Creates a client interface
create-controller - Creates a controller and associated test
create-test - Creates a simple test for the project's testing framework
create-bean - Creates a singleton bean
create-websocket-client - Creates a Websocket client
create-websocket-server - Creates a Websocket server
And you can also see more description of the command when you call it with -h option. For example:
$ mn create-controller -h
Usage: mn create-controller [-fhvVx] CONTROLLER-NAME
Creates a controller and associated test
CONTROLLER-NAME The name of the controller to create
-f, --force Whether to overwrite existing files
-h, --help Show this help message and exit.
-v, --verbose Create verbose output.
-V, --version Print version information and exit.
-x, --stacktrace Show full stack trace when exceptions occur.
I'm having a node-js app on Heroku using the pdfMerge.js library.
following the documentation I'm using the stream event mechanism as a callback to identify the end of the process
then an exception is thrown :
events.js:167 Error: spawn java ENOENT.
I'm almost sure it's happening because I'm messing required java installation as described here:
pdfmerger combines multiple PDF-files into a single PDF-file. It is a node module that utilizes the Apache PDFBox Library, which the required functionality are distributed along with this module. The only requirement for this module to run, is having Java 6 or higher in the path.
I'm Not familiar enough with Heroku installation/configuration process in order to make it work.
thanks in advance
You can add Java to your app by adding the heroku/jvm buildpack like this:
$ heroku buildpacks:add -i 1 heroku/jvm
Then redeploy with git commit --allow-empty and git push heroku master.
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