0

我正在拼命地让 swagger-codegen 在我的 Macbook Pro 上使用 OS X Mountain Lion 工作。

将 Java 升级到 1.7。

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

安装自制。

根据“brew doctor”卸载 Mono 和 Xamarin。

每个“brew doctor”安装了 Xcode 命令行工具。

执行“酿造更新”

安装了scala“brew install scala”。

安装 sbt “brew install sbt”

执行“sbt”

[info] Loading project definition from /Users/jecz/Apache/swagger-codegen-master/project
[info] Set current project to swagger-codegen (in build file:/Users/jecz/Apache/swagger-codegen-master/)

执行“./sbt 程序集”

Detected sbt version 0.13.0
[info] Loading project definition from /Users/jecz/Apache/swagger-codegen-master/project
[info] Set current project to swagger-codegen (in build file:/Users/jecz/Apache/swagger-codegen-master/)
[warn] Credentials file /Users/jecz/.ivy2/.credentials does not exist
[info] ResourceExtractorTest:
[info] ResourceExtractor
[info] - should get 3 apis from a resource listing
[info] ApiExtractorTest:
[info] ApiExtractor
[info] - should verify the deserialization of the store api
[info] ResourceListingValidationTest:
[info] - should not have base path
[info] - should fail resource listing without apiVersion
[info] - should fail with missing paths in a ResourceListing
[info] ApiListingReferenceValidationTest:
[info] - should deserialize an ApiListingReference
[info] - should serialize an ApiListingReference
[info] ApiDescriptionValidationTest:
[info] - should fail to deserialize an ApiDescription with path, method, return type
[info] OperationValidationTest:
[info] - should fail to deserialize an Operation with missing param type
[info] - should serialize an operation
[info] ResponseMessageValidationTest:
[info] - should deserialize an ResponseMessage
[info] - should serialize an operation
[info] ParameterValidationTest:
[info] - should deserialize another param
[info] - should deserialize a parameter
[info] - should serialize a parameter
[info] ModelValidationTest:
[info] - should deserialize a model
[info] - should serialize a model
[info] ModelRefValidationTest:
[info] - should deserialize a model ref
[info] - should serialize a model ref
[info] ModelPropertyValidationTest:
[info] - should deserialize a model property with allowable values and ref
[info] - should serialize a model property with allowable values and ref
[info] - should deserialize a model property with allowable values
[info] - should serialize a model property with allowable values
[info] - should deserialize a model property
[info] - should serialize a model property
[info] AllowableValuesValidationTest:
[info] - should deserialize allowable value list
[info] - should serialize allowable values list
[info] - should deserialize allowable values range
[info] - should serialize allowable values range
[info] ResourceListingSerializersTest:
[info] - should deserialize an ResourceListing with no apis
[info] - should serialize an ApiListingReference with no apis
[info] - should deserialize an ResourceListing
[info] - should serialize an ApiListingReference
[info] ApiListingReferenceSerializersTest:
[info] - should deserialize an ApiListingReference
[info] - should serialize an ApiListingReference
[info] ApiDescriptionSerializersTest:
[info] - should deserialize an ApiDescription with no ops
[info] - should serialize an ApiDescription with no operations
[info] - should deserialize an ApiDescription
[info] - should serialize an ApiDescription
[info] OperationSerializersTest:
[info] - should deserialize an Operation
[info] - should serialize an operation
[info] ErrorResponseSerializersTest:
[info] - should deserialize an ResponseResponse
[info] - should serialize an operation
[info] ParameterSerializersTest:
[info] - should deserialize another param
[info] - should deserialize a parameter
[info] - should serialize a parameter
[info] ModelSerializationTest:
[info] - should deserialize a model
[info] - should serialize a model
[info] ModelRefSerializationTest:
[info] - should deserialize a model ref
[info] - should serialize a model ref
[info] ModelPropertySerializationTest:
[info] - should deserialize a model property with allowable values and ref
[info] - should serialize a model property with allowable values and ref
[info] - should deserialize a model property with allowable values
[info] - should serialize a model property with allowable values
[info] - should deserialize a model property
[info] - should serialize a model property
[info] AllowableValuesSerializersTest:
[info] - should deserialize allowable value list
[info] - should serialize allowable values list
[info] - should deserialize allowable values range
[info] - should serialize allowable values range
[info] ResourceListingValidationTest:
[info] - should fail resource listing without base path
[info] - should fail resource listing without apiVersion
[info] - should fail with missing paths in a ResourceListing
[info] ApiListingReferenceValidationTest:
[info] - should deserialize an ApiListingReference
[info] - should serialize an ApiListingReference
[info] ApiDescriptionValidationTest:
[info] - should fail to deserialize an ApiDescription with path, method, return type
[info] OperationValidationTest:
[info] - should fail to deserialize an Operation with missing param type
[info] - should serialize an operation
[info] ResponseMessageValidationTest:
[info] - should deserialize an ResponseMessage
[info] - should serialize an operation
[info] ParameterValidationTest:
[info] - should deserialize another param
[info] - should deserialize a parameter
[info] - should serialize a parameter
[info] ModelValidationTest:
[info] - should deserialize a model
[info] - should serialize a model
[info] ModelRefValidationTest:
[info] - should deserialize a model ref
[info] - should serialize a model ref
[info] ModelPropertyValidationTest:
[info] - should deserialize a model property with allowable values and ref
[info] - should serialize a model property with allowable values and ref
[info] - should deserialize a model property with allowable values
[info] - should serialize a model property with allowable values
[info] - should deserialize a model property
[info] - should serialize a model property
[info] AllowableValuesValidationTest:
[info] - should deserialize allowable value list
[info] - should serialize allowable values list
[info] - should deserialize allowable values range
[info] - should serialize allowable values range
[info] SwaggerModelTest:
[info] Swagger Model
[info] - should deserialize ResourceListing
[info] - should deserialize ApiListing
[info] - should deserialize ApiListing with AllowableValues
[info] - should maintain model property order when deserializing
[info] - should deserialize models
[info] ResourceExtractorTest:
[info] ResourceExtractor
[info] - should get 3 apis from a resource listing
[info] ApiExtractorTest:
[info] ApiExtractor
[info] - should verify the deserialization of the store api
09:49:13,840 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:49:13,840 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:49:13,840 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/jecz/Apache/swagger-codegen-master/target/scala-2.9.1/classes/logback.xml]
09:49:13,991 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:49:14,000 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:49:14,012 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:49:14,114 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
09:49:14,114 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
09:49:14,114 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
09:49:14,116 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.wordnik] to DEBUG
09:49:14,116 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
09:49:14,116 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
09:49:14,117 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:49:14,119 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@7b1b9e3a - Registering current configuration as safe fallback point

[info] BasicScalaGeneratorTest:
[info] BasicScalaGenerator
[info] - should process a response declaration
[info] - should process a string response
[info] - should process a string array
[info] - should process an unmapped response type
[info] - should get the invoker package
[info] - should get the api package
[info] - should get the model package
[info] - should convert to a declared type
[info] - should convert a string a declaration
[info] - should honor the import mapping
[info] - should quote a reserved var name
[info] - should create a declaration with a List of strings
[info] - should create a declaration with a List of ints
[info] - should create a declaration with a List of floats
[info] - should create a declaration with a List of doubles
[info] - should create a declaration with a List of complex objects
[info] - should verify an api map with query params
[info] - should verify an api map with query params with default values
[info] - should create an api file
[info] BasicGeneratorTest:
[info] BasicGenerator
[info] - should get operations
[info] - should verify ops are grouped by path correctly
[info] - should create a model map
[info] - should create a model file
[info] BasicJavaGeneratorTest:
[info] BasicJavaGenerator
[info] - should process a response declaration
[info] - should process a string response
[info] - should process a string array
[info] - should process an upper-case string array
[info] - should process an unmapped response type
[info] - should get the invoker package
[info] - should get the api package
[info] - should get the model package
[info] - should convert to a declared type
[info] - should convert a string a declaration
[info] - should honor the import mapping
[info] - should quote a reserved var name
[info] - should create a declaration with a List of strings
[info] - should create a declaration with a List of ints
[info] - should create a declaration with a List of floats
[info] - should create a declaration with a List of doubles
[info] - should create a declaration with a List of complex objects
[info] CodegenConfigTest:
[info] PathUtil
[info] - should convert an api name
[info] - should convert a path
[info] CodegenConfig
[info] - should process a response declaration
[info] - should process an unchanged response
[info] - should process an mapped response type
[info] - should get the invoker package
[info] - should get the api package
[info] - should get the model package
[info] - should convert to a declared type
[info] - should honor the import mapping
[info] - should quote a reserved var name
[info] CoreUtilsTest:
[info] CoreUtils
[info] - should verify models are extracted
[info] - should verify operation names
[info] - should find required models
[info] - should find required models from a nested list
[info] PathUtilTest:
[info] PathUtil
[info] - should convert an api name
[info] - should convert a path
[info] - should get determine the basePath implicitly
[info] ResourceListingSerializersTest:
[info] - should deserialize an ResourceListing with no apis
[info] - should serialize an ApiListingReference with no apis
[info] - should deserialize an ResourceListing
[info] - should serialize an ApiListingReference
[info] ApiListingReferenceSerializersTest:
[info] - should deserialize an ApiListingReference
[info] - should serialize an ApiListingReference
[info] ApiDescriptionSerializersTest:
[info] - should deserialize an ApiDescription with no ops
[info] - should serialize an ApiDescription with no operations
[info] - should deserialize an ApiDescription
[info] - should serialize an ApiDescription
[info] OperationSerializersTest:
[info] - should deserialize an Operation
[info] - should deserialize an Operation with an array property
[info] - should serialize an operation
[info] - should deserialize an Operation with array
[info] ErrorResponseSerializersTest:
[info] - should deserialize an Response
[info] - should serialize an operation
[info] ParameterSerializersTest:
[info] - should deserialize another param
[info] - should deserialize a parameter
[info] - should serialize a parameter
[info] ModelSerializationTest:
[info] - should deserialize a model
[info] - should deserialize a model with a set
[info] - should serialize a model
[info] ModelRefSerializationTest:
[info] - should deserialize a model ref
[info] - should serialize a model ref
[info] ModelPropertySerializationTest:
[info] - should deserialize a model property with allowable values and ref
[info] - should serialize a model property with allowable values and ref
[info] - should deserialize a model property with allowable values
[info] - should serialize a model property with allowable values
[info] - should deserialize a model property
[info] - should serialize a model property
[info] - should extract model properties
[info] - should extract model properties with arrays
[info] AllowableValuesSerializersTest:
[info] - should deserialize allowable value list
[info] - should serialize allowable values list
[info] - should deserialize allowable values range
[info] - should serialize allowable values range
[info] CoreUtilsTest:
[info] CoreUtils
[info] - should verify models are extracted
[info] - should verify operation names
[info] - should find required models
[info] - should find required models from a nested list
[info] BasicCSharpGeneratorTest:
[info] BasicCSharpGenerator
[info] - should perserve the name date
[info] - should process a string array
[info] Passed: Total 194, Failed 0, Errors 0, Passed 194
[info] Including from cache: json4s-ast_2.9.1-3.2.5.jar
[info] Including from cache: jackson-annotations-2.2.2.jar
[info] Including from cache: jackson-core-2.2.2.jar
[info] Including from cache: json4s-core_2.9.1-3.2.5.jar
[info] Including from cache: jackson-databind-2.2.2.jar
[info] Including from cache: paranamer-2.5.6.jar
[info] Including from cache: commons-io-2.3.jar
[info] Including from cache: scala-inflector_2.9.1-1.3.5.jar
[info] Including from cache: json4s-jackson_2.9.1-3.2.5.jar
[info] Including from cache: mockito-all-1.9.0.jar
[info] Including from cache: scallop_2.9.1-0.9.4.jar
[info] Including from cache: scalate-core_2.9-1.6.1.jar
[info] Including from cache: scalate-util_2.9-1.6.1.jar
[info] Including from cache: scala-compiler-2.9.1.jar
[info] Including from cache: scala-library-2.9.1.jar
[info] Including from cache: scalap-2.9.1.jar
[info] Including from cache: slf4j-api-1.6.1.jar
[warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to a file
[info] Checking every *.class/*.jar file's SHA-1.
[info] Assembly up to date: /Users/jecz/Apache/swagger-codegen-master/target/scala-2.9.1/swagger-codegen.jar
[success] Total time: 26 s, completed Nov 1, 2013 9:49:34 AM

执行“./bin/scala-petstore.sh”

 Please set scalaVersion := "2.10.3" in build.sbt and run ./sbt assembly
4

4 回答 4

4

我遇到过同样的问题。问题是:

我安装了 scala 2.10.2,sbt 在名为 scala-2.10 的文件夹中构建它,这由 php-petstore.sh 文件中的这一行处理:

if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then

使用 bin/Version.scale 它将带有补丁的版本号映射到只有主要和次要版本的版本号。由于 2.10.3 未映射到 2.10,因此会发生错误。

val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown").toString match {
  case "2.10.0" => "2.10"
  case e: String => e
}
println(version)

解决方案:将 2.10.0 更改为 2.10.3(或您正在运行的任何版本)

于 2013-11-12T14:02:21.683 回答
0

如果你做 brew install scala 事情应该开始工作

于 2013-11-01T00:56:07.490 回答
0

也许您在更改 build.sbt 中的版本后忘记了“./sbt 程序集”。

我也得到:

object BeanProperty is not a member of package reflect
[error] import scala.reflect.BeanProperty

并试图降级到版本 2.10.4

在那之后它起作用了。

于 2014-08-20T17:44:02.327 回答
0

最新版本的 Swagger-Codegen 不再依赖于 Scala。您可以在此处找到安装说明

于 2015-07-12T05:44:09.883 回答