Skip to content

Conversation

@imclem
Copy link
Contributor

@imclem imclem commented Feb 2, 2017

This commit fixes the Java problem related by this defect #2064.

If the swagger model contains a class named 'Object' some mustache templates
will generate non compiling Java code.

PR checklist

  • Read the contribution guildelines.
  • 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)
  • 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

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

If the swagger model contains a class named 'Object' some mustache templates
will generate non compiling **Java** code.
@wing328
Copy link
Contributor

wing328 commented Feb 2, 2017

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/swagger-api/swagger-codegen/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@imclem
Copy link
Contributor Author

imclem commented Feb 6, 2017

@wing328 I didn't see that, it is now Thanks !

@wing328
Copy link
Contributor

wing328 commented Feb 7, 2017

cc @nickcmaynard @jfiala as the PR impacts JAX-RS generators.

@jfiala
Copy link
Contributor

jfiala commented Feb 7, 2017

@wing328 looks good after quick inspection (I didn't run it), interesting issue...

@nickcmaynard
Copy link
Contributor

Needs sample updates, but this looks like a pragmatic solution to the problem. Might be worth a comment in the mustache files to explain why java.lang.Object to avoid regression later. Would a test case be possible?

@imclem
Copy link
Contributor Author

imclem commented Feb 8, 2017

@nickcmaynard It fails at compile time, a test case would be possible if you generate the code and try to compile it. You might want to take a look at : https://commons.apache.org/proper/commons-jci/

You can do something like this:

  1. Code generation from a spec with an Object
  2. Compilation using JCI
  3. Assert CompilationResult.getErrors().length == 0

If there's a regression, the test will fail for sure!

@wing328
Copy link
Contributor

wing328 commented Feb 13, 2017

I'll add a test object named "Object" to https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml#L902 so as to catch the issue moving forward.

Will update the sample later.

@wing328 wing328 merged commit 74da89c into swagger-api:master Feb 13, 2017
@wing328
Copy link
Contributor

wing328 commented Feb 13, 2017

@imclem PR merged into master. Thanks for your contribution.

For your upcoming PRs, please create a new branch for the change.

@wing328 wing328 mentioned this pull request Feb 13, 2017
@wing328
Copy link
Contributor

wing328 commented Feb 13, 2017

Created #4782 for tracking

@wing328 wing328 changed the title Fix issue when the swagger model contains an 'Object' class [Java] Fix issue when the swagger model contains an 'Object' class Feb 21, 2017
davidgri pushed a commit to davidgri/swagger-codegen that referenced this pull request May 11, 2017
…api#4695)

If the swagger model contains a class named 'Object' some mustache templates
will generate non compiling **Java** code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants