swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.74k stars 6.02k forks source link

Issues with running ./bin/scala-petstore.sh (following README) #65

Closed LiamInJapan closed 9 years ago

LiamInJapan commented 11 years ago

Hi there,

As a continuation of the issue reported at https://github.com/wordnik/swagger-codegen/issues/64 I am still having problems following the readme as is. Now, upon execution of ./bin/scala-petstore.sh I get the following output at the end of the script running:

[info] Assembly up to date: /Users/william.conroy/Development/swagger-codegen/target/scala-2.9.2/swagger-codegen.jar [success] Total time: 10 s, completed Jun 27, 2013 10:16:31 AM /Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:17: error: object wordnik is not a member of package com import com.wordnik.swagger.codegen.BasicScalaGenerator ^ /Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:20: error: not found: value generateClient def main(args: Array[String]) = generateClient(args) ^ two errors found

It looks like some kind of issue with scala identifying the generators location...

RobBlairInq commented 11 years ago

I've hit the same problem, also on the other scripts. The sbt script don't create the swagger-codegen.jar files in the place that scala-petstore.sh (and friends) expect it.

I'm getting the codegen created in target/scala-2.9.2, but *-petstore.sh look in target/swagger-codegen.jar and target/scala-2.10/... substituting my path gets a partial success - gets to "wrote samples/client/petstore/java/pom.xml" and sits there doing nothing (no cpu use)

fehguy commented 11 years ago

Hi, I think the best way to avoid the scala script stuff is to follow a guide like such:

https://github.com/wordnik/swagger-codegen/wiki/Workflow-Integration

And use maven to do the build. This way, it "just works". Can you give that a shot?

RobBlairInq commented 11 years ago

Trying it out - had to add the scalatest dependency to the sample pom:

    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.9.1</artifactId>
      <version>1.8</version>
    </dependency>

which fixed some build problems. but after that, I'm seeing ClassNotFoundException: JavaPetstoreCodegen. I'm assuming it's some classpath / jar issue, so will try a few more things before wailing in sorrow.

RobBlairInq commented 11 years ago

Other suggested changes to pom.xml. the jvmArgs associated with the launchers tag do not appear to be applied to the individual launchers. I had to move them to the launcher itself.

the filemap arg for the sample as copied from swagger-codegen should include full path

<!-- See note #4 -->
 <jvmArg>-DfileMap=src/test/resources/petstore</jvmArg>
 <jvmArg>-Xms256m</jvmArg>
 <jvmArg>-Xmx1024m</jvmArg>

Now things work, except that mvn never exits after writing the pom, sitting using 0% cpu.

...
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//ApiException.java
wrote samples/client/petstore/java/pom.xml

ETA - forgot ellipsis that represented successful codegen.

fehguy commented 11 years ago

Something snuck into codegen that is causing a thread to keep running. If you add this:

System.exit(0)

at the end of your main function, it'll exit (more) gracefully.

Now, it should be writing the petstore APIs, which it clearly is not. Are you sure the target of the fileMap is available?

LiamInJapan commented 11 years ago

Output today of .sbt/assembly:

(final failing part only) [error] Failed: : Total 138, Failed 3, Errors 0, Passed 135, Skipped 0 [error] Failed tests: [error] OperationValidationTest [error] OperationSerializersTest [error] ApiDescriptionSerializersTest error sbt.TestsFailedException: Tests unsuccessful [error] Total time: 10 s, completed Jul 3, 2013 4:41:40 PM

Output of ./bin/scala-petstore.sh:

[error] Failed: : Total 138, Failed 3, Errors 0, Passed 135, Skipped 0 [error] Failed tests: [error] OperationValidationTest [error] OperationSerializersTest [error] ApiDescriptionSerializersTest error sbt.TestsFailedException: Tests unsuccessful [error] Total time: 9 s, completed Jul 3, 2013 4:42:32 PM /Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:17: error: object wordnik is not a member of package com import com.wordnik.swagger.codegen.BasicScalaGenerator ^ /Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:20: error: not found: value generateClient def main(args: Array[String]) = generateClient(args)

I tried the Workflow Integration Guide (including the suggested patch) but I get the following trying to run the sample pom from the root of the project:

[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building client-generator 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> scala-maven-plugin:3.1.0:run (default-cli) @ client-generator >>> [WARNING] The POM for com.wordnik:swagger-codegen_2.9.1:jar:2.0.3-SNAPSHOT is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.364s [INFO] Finished at: Wed Jul 03 16:51:25 JST 2013 [INFO] Final Memory: 3M/81M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project client-generator: Could not resolve dependencies for project com.wordnik:client-generator:jar:1.0.0-SNAPSHOT: Failure to find com.wordnik:swagger-codegen_2.9.1:jar:2.0.3-SNAPSHOT in https://oss.sonatype.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-snapshots has elapsed or updates are forced -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

And the following running it against the one present in /samples/client/petstore

$ mvn scala:run -Dlauncher=objc-codegen

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.963s [INFO] Finished at: Wed Jul 03 16:52:27 JST 2013 [INFO] Final Memory: 3M/81M [INFO] ------------------------------------------------------------------------ [ERROR] No plugin found for prefix 'scala' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/william.conroy/.m2/repository), central (http://repo1.maven.org/maven2)] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
ivanhawkes commented 10 years ago

I've just followed the README as well and end up with much the same result.

[info] Checking every .class/.jar file's SHA-1. [info] Assembly up to date: /home/ivan/swagger/swagger-codegen/target/scala-2.10/swagger-codegen.jar [success] Total time: 9 s, completed 12/10/2013 4:43:18 AM /home/ivan/swagger/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:17: error: object wordnik is not a member of package com import com.wordnik.swagger.codegen.BasicScalaGenerator ^ /home/ivan/swagger/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:20: error: not found: value generateClient def main(args: Array[String]) = generateClient(args) ^ two errors found

This is a fresh install on Ubuntu, with up to date copies of maven and scala just installed today. Any chance of a fix for this?

fehguy commented 10 years ago

Hi, this should be fixed. Can you please pull from master, which is now 2.0.11?