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

Validation spec don't throws any error, but on generation, validation fails #237

Closed GerardSoleCa closed 9 years ago

GerardSoleCa commented 9 years ago

Hi,

Finally I've moved to my preproduction environment to run this in a better way.

If I use the validator against my API (spec 1.1) it doesn't throw any error, but when trying to generate a client it crashes:

preproduction@ubuntu:~/swagger-codegen/swagger-codegen$ ./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://192.168.1.92:8080/aaaida/ws/api-docs.json

base path is http://192.168.1.92:8080/aaaida/ws

********* Failed to read swagger json!
ValidationError(/aaaida:/aaaida.{format}/request/accept:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/measure:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/bond:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/request:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/bondInList:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/api_token:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/user:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/comment:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/value:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/login:[parameter],name is required,ERROR)
ValidationError(/aaaida:/aaaida.{format}/bondList:[parameter],name is required,ERROR)
ListBuffer(ValidationError(/aaaida:/aaaida.{format}/request/accept:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/measure:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/bond:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/request:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/bondInList:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/api_token:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/user:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/comment:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/value:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/login:[parameter],name is required,ERROR), ValidationError(/aaaida:/aaaida.{format}/bondList:[parameter],name is required,ERROR))
com.wordnik.swagger.util.ValidationException: Failed validation
    at com.wordnik.swagger.codegen.BasicGenerator.generate(BasicGenerator.scala:106)
    at com.wordnik.swagger.codegen.BasicGenerator.generateClientWithoutExit(BasicGenerator.scala:74)
    at com.wordnik.swagger.codegen.BasicGenerator.generateClient(BasicGenerator.scala:56)
    at com.wordnik.swagger.codegen.BasicScalaGenerator$.main(BasicScalaGenerator.scala:22)
    at com.wordnik.swagger.codegen.BasicScalaGenerator.main(BasicScalaGenerator.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

Could be related to the required params?

Thanks!

fehguy commented 9 years ago

How are you integrating with swagger? It would be immensely better if you can update to use the 1.2 specification, which is about 2 years old now. Most all tooling is expecting that format.

GerardSoleCa commented 9 years ago

I'm using the jersey swagger version: com.wordnik:swagger-jersey-jaxrs_2.10.0:1.2.5 which I think that is the latest version of this library as I see on http://mvnrepository.com/search.html?query=com.wordnik

fehguy commented 9 years ago

oh dear! No, we are at 1.3.7, and I expect to release 1.3.8 any day.

https://oss.sonatype.org/content/repositories/releases/com/wordnik/swagger-jersey-jaxrs_2.10/

GerardSoleCa commented 9 years ago

I'm trying now http://mvnrepository.com/artifact/com.wordnik/swagger-jersey2-jaxrs_2.10/1.3.7 but I think that annotations will be different...

GerardSoleCa commented 9 years ago

Oh! Thanks, I'll try that repo!

GerardSoleCa commented 9 years ago

Hi,

The following annotations have been removed, isn't it?

import com.wordnik.swagger.annotations.ApiError;
import com.wordnik.swagger.annotations.ApiErrors;
fehguy commented 9 years ago

There are some naming changes between 1.2 and 1.3 but functionally the changes are minimal. Take a look at the samples in master

GerardSoleCa commented 9 years ago

Ok, I think that, at least and for now, I've updated the spec to 1.2. And now java files are created.

Thanks, I close this issue.

By now, jar files are generated without the classes, I'll search the reason why this happen.