Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[swagger-codegen 3.0.0] Server Stub support #7776

Closed
GovardhanYakula opened this issue Mar 7, 2018 · 11 comments
Closed

[swagger-codegen 3.0.0] Server Stub support #7776

GovardhanYakula opened this issue Mar 7, 2018 · 11 comments

Comments

@GovardhanYakula
Copy link

Description

I have tried to generate server stub for OpenAPI 3.0 spec based .yaml using swagger-codegen 3.0.0 and used java/inflector languages (as it supports only java & inflector). In case of java, this generated files for client API library not for the server stub. In case of inflector, this causes exception. I would like to know whether server stub support is there or not in this release.

Swagger-codegen version

3.0.0-SNAPSHOT

Swagger declaration file content or url

https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i petstore.yaml -l java

Steps to reproduce

NA

Related issues/PRs

NA

Suggest a fix/enhancement

NA

@jmini
Copy link
Contributor

jmini commented Mar 7, 2018

inflector should work with 3.0.0-SNAPSHOT.

There was a small continuous integration build problem yesterday, see swagger-api/swagger-codegen-generators#31 (see stacktrace there). Can you verify the precise 3.0.0-SNAPSHOT version you are using?

The continuous build is now OK: https://travis-ci.org/swagger-api/swagger-codegen

If you are interested by JaxRS backends in the 3.0.0 version, follow swagger-api/swagger-codegen-generators#29

@GovardhanYakula
Copy link
Author

Thank you, I will take the new version for building and check for the inflector. Is there support for server stub generation in this release ?

@jmini
Copy link
Contributor

jmini commented Mar 7, 2018

I am not using inflector as backend, I prefer generating server stubs and then suse JaxRS.

The inflector banckend for the petstore demo spec looks like this: java-inflector (generated with Swagger Codegen v2)

With the 3.0.0-SNAPSHOT version generated code should look the same, using the swagger v3 runtime instead of swagger v2.

@GovardhanYakula
Copy link
Author

@jmini I am facing the below problem, can you please look into it.

  1. I have taken the latest version and tried to build from it. But it is causing the following error.

[INFO] Reactor Summary:
[INFO]
[INFO] swagger-codegen-project ............................ SUCCESS [ 2.643 s]
[INFO] swagger-codegen (core library) ..................... SUCCESS [ 23.386 s]
[INFO] swagger-codegen (executable) ....................... SUCCESS [ 7.243 s]
[INFO] swagger-codegen (maven-plugin) ..................... FAILURE [ 3.579 s]
[INFO] swagger-generator .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 38.423 s
[INFO] Finished at: 2018-03-07T15:25:28+05:30
[INFO] Final Memory: 39M/337M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.4:descriptor (default-descriptor) on project swagger-codegen-maven-plugin:
The API of the mojo scanner is not compatible with this plugin version.
Please check the plugin dependencies configured in the POM and ensure the versions match.
/opt/jdk/jdk1.8.0_152/jre/lib/i386/libawt_xawt.so: libXext.so.6: cannot open shared object file: No such file or directory -> [Help 1]

  1. After that, i successfully generated server stub for inflector language using following command :
    java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i petstore.yaml -l inflector -o samples/server/petstore/java-inflector/

  2. Finally, i tried to run using this command : mvn package jetty:run
    But it is causing the below error:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/chandan/Govardhan/OpenAPI/Swagger-Codegen-3.0/swagger-codegen-3.0.0/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[3,39]
package io.swagger.oas.inflector.models does not exist
[ERROR] /home/chandan/Govardhan/OpenAPI/Swagger-Codegen-3.0/swagger-codegen-3.0.0/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[4,39]
package io.swagger.oas.inflector.models does not exist
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.396 s
[INFO] Finished at: 2018-03-07T15:50:24+05:30
[INFO] Final Memory: 19M/171M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project swagger-inflector-server: Compilation failure: Compilation failure:
[ERROR] /home/chandan/Govardhan/OpenAPI/Swagger-Codegen-3.0/swagger-codegen-3.0.0/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[3,39] package io.swagger.oas.inflector.models does not exist
[ERROR] /home/chandan/Govardhan/OpenAPI/Swagger-Codegen-3.0/swagger-codegen-3.0.0/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[4,39] package io.swagger.oas.inflector.models does not exist

@jmini
Copy link
Contributor

jmini commented Mar 7, 2018

I can not follow.

With a checkout of branch 3.0.0, I can run mvn clean verify:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] swagger-codegen-project ............................ SUCCESS [  1.795 s]
[INFO] swagger-codegen (core library) ..................... SUCCESS [ 20.425 s]
[INFO] swagger-codegen (executable) ....................... SUCCESS [  6.318 s]
[INFO] swagger-codegen (maven-plugin) ..................... SUCCESS [  6.983 s]
[INFO] swagger-generator .................................. SUCCESS [  9.244 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.199 s
[INFO] Finished at: 2018-03-07T12:30:44+01:00
[INFO] Final Memory: 172M/1224M
[INFO] ------------------------------------------------------------------------

The different CI Builds are also OK for this branch.


If you just want to use the latest version, you do not need to build it locally... Are you using a maven plugin or the cli?

Just fetch the latest version from maven central (https://oss.sonatype.org/content/repositories/snapshots/) and it should work.

@HugoMario
Copy link
Contributor

hey @GovardhanYakula, can you try again? the build failure was already fixed

@GovardhanYakula
Copy link
Author

GovardhanYakula commented Mar 7, 2018

Thanks @jmini and @HugoMario . I am able to build swagger-codegen 3.0.0 and generate server stub for inflector successfully.

But I am facing following compilation error while running the server.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/chandan/Govardhan/OpenAPI/New_Swagger_Codegen_3/swagger-codegen/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[3,39] package io.swagger.oas.inflector.models does not exist
[ERROR] /home/chandan/Govardhan/OpenAPI/New_Swagger_Codegen_3/swagger-codegen/samples/server/petstore/java-inflector/src/main/java/io/swagger/controllers/PetsController.java:[4,39] package io.swagger.oas.inflector.models does not exist

Do you have any clue on this ?

@HugoMario
Copy link
Contributor

@GovardhanYakula
it's probably related to system properties removing changes, can you please file a new ticket and close this one?

@GovardhanYakula
Copy link
Author

@HugoMario
As I am new to this I have no idea about "system properties removing changes" you mentioned.Can you please elaborate?
About raising a new issue can u clarify what new information I have to add as the issue is still the same i.e Server stubs generation faces compilation error.

@jmini
Copy link
Contributor

jmini commented Mar 8, 2018

system properties removing changes

@HugoMario has started to work on swagger-api/swagger-codegen-generators#27

I agree that we can keep this issue to discuss it.

@HugoMario
Copy link
Contributor

@GovardhanYakula
i used tihs cmd to generate inflector:

java -jar target/swagger-codegen-cli.jar generate -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml -l java -o [some place in my disk]

then on generated project i run:

mvn clean package jetty:run

everything worked pretty well:

...
[INFO] Started o.e.j.m.p.JettyWebAppContext@46731692{/,file:/Users/hugomercado/Documents/tempo/v4/src/main/webapp/,AVAILABLE}{file:/Users/hugomercado/Documents/tempo/v4/src/main/webapp/}
[WARNING] !RequestLog
[INFO] Started ServerConnector@696fad31{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started @4721ms
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 1 seconds.

So, when you have a chance, can you please try again and see if it works for you? for now i'm going to close this issue and it can be opened if something wrong is found.

I used the latest 3.0.0-SNAPHOT btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants