swagger-api / swagger-api/swagger-codegen
[Java] Client - Missing import in JSON.java when using `Object` as schema name
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When defining an Object as schema the io.swagger.client.JSON file doesn't compile anymore due to an ambigous usage of Object
Compile error message:
Error:(1397, 29) java: reference to Object is ambiguous
both class io.swagger.client.model.Object in io.swagger.client.model and class java.lang.Object in java.lang match
// Line 1397
public String serialize(Object obj) {
return gson.toJson(obj);
}
Swagger-codegen version
3.0.19
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli-3.0.19.jar generate -i openapi.json -l java -o clients/java
Steps to reproduce
- Create a client of a schema which contains
Objectas schema name - Try to compile the client
Suggest a fix/enhancement
The import to java.lang.Object should be added to JSON.java in this case
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Generate the Java client with swagger-codegen-cli 3.0.19 using the supplied OpenAPI declaration, then inspect clients/java JSON.java around line 1397. Reproduce the compilation error with a schema named Object; done means the generated client compiles without the ambiguous Object reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100