swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Jaxrs-spec] Java-based generator + unittest for jaxrs-spec

Open jfiala opened this issue 8 years ago • 2 comments

PR checklist

  • [x] Read the contribution guildelines.
  • [x] Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • [x] Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

For details see #4087

This is the first draft:

  1. Instead of using the shellscripts, define a Java class to generate the ouput with all the desired options. first example: JaxrsSpec_Generator_Petstore.java

  2. add a check for equality of all files (missing: compare directory structures) example: Jaxrs_Spec_Generator_Petstore_Test.java

  3. Setup a unittest to verify if the samples are equal with the generated output automatically This means no more outdated samples, otherwise the build will fail!

The basic idea has been taken from the swagger2markup project.

Releated issues

#4087

jfiala avatar Mar 09 '17 20:03 jfiala

@wing328: I implemented the first draft for jaxrs-spec to generate & compare the outcome automatically.

Currently the shippable build fails:

[main] INFO io.swagger.codegen.generators.util.ComparePathUtil - checking file /tmp/junit5278387355632741777/src/gen/java/io/swagger/model/Capitalization.java
[main] INFO io.swagger.codegen.generators.util.ComparePathUtil - files not equal: compare: ../../samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Capitalization.java, file: Capitalization.java!

Is there an easy way to access a file from the shippable build (here: /tmp/junit5278387355632741777/src/gen/java/io/swagger/model/Capitalization.java)? It would be necessary to compare the expected with the actual outcome during the build. On my local pc everything runs fine, there is no difference in Capitalization.java, so I'm wondering what is different during the CI build...

jfiala avatar Mar 11 '17 20:03 jfiala

@jfiala can you create an account at Shippable CI and access the following page?

https://app.shippable.com/github/swagger-api/swagger-codegen

wing328 avatar Mar 20 '17 14:03 wing328