phiz71 / vertx-swagger

Swagger integration in Eclipse Vert.X world. A dynamic Vert.X router, configured with a swagger file and a swagger-codegen plugin to generate a server stub.
Apache License 2.0
86 stars 35 forks source link

The generated MainVerticle's start mehtod always listens on port 8080 #77

Closed javadch closed 6 years ago

javadch commented 6 years ago

It would be very useful to all passing port number as a parameter along pom, or better to read the port from a config file. The generator can have a switch to read the port from a parameter, a config file, or the default. Also, it can copy the config file to a generated directory so that the start the app can load it not only for the port but also for other configurations items. The Swagger cod-gen command line allows for such a config file, the -c config.json in this command:

java -cp swagger-codegen-cli-2.2.3.jar;vertx-swagger-codegen-1.0.0.jar io.swagger.codegen.SwaggerCodegen generate -l java-vertx -o gen -i swagger.json -c config.json

phiz71 commented 6 years ago

With the current code on master, if you generate a server stubs, a run-with-config.sh script and a config.json are also generated. The script contains the following code :

#!/bin/sh

export TARGET_OUTPUT="target"

if [ ! -d "$TARGET_OUTPUT" ]; then
    echo "Control will enter here if $TARGET_OUTPUT doesn't exist. Therefore build operation going to start."
    mvn clean install
fi

java -jar target/{{artifactId}}-{{artifactVersion}}-fat.jar -conf config.json

and the config.json :

{
    "http.port" : 8080
}

Does it answer your question ?

javadch commented 6 years ago

This is my dependency:

  <dependency>
       <groupId>com.github.phiz71</groupId>
       <artifactId>vertx-swagger-router</artifactId>
       <version>1.4.0</version>
    </dependency>

I can use jitpack to get the latest release from your Github repo, but currently the latest release is still 1.4.0. Would your please create a release namely 1.4.1 and on your repo so that I can get it via maven/jitpack in my project.

javadch commented 6 years ago

I updated my maven to point to the master branch and used Jitpack to always get the latest, like this:

  <repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>  
  </repositories>
          <dependency>
            <groupId>com.github.phiz71</groupId>
            <artifactId>vertx-swagger-codegen</artifactId>
            <version>master-SNAPSHOT</version>
            <scope>compile</scope>
          </dependency>

But I am getting the following error:

Failed to execute goal io.swagger:swagger-codegen-maven-plugin:2.2.2:generate (default) on project server.pfa: Execution default of goal io.swagger:swagger-codegen-maven-plugin:2.2.2:generate failed: Plugin io.swagger:swagger-codegen-maven-plugin:2.2.2 or one of its dependencies could not be resolved: Could not find artifact com.github.phiz71:vertx-swagger-codegen:jar:master-SNAPSHOT in sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots)

Any idea what the problem can be?

javadch commented 6 years ago

tested. works.