swagger-api / swagger-api/swagger-codegen
[Retrofit2] Be less opinionated about JSON Serialization Implementation
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am attempting to use the retrofit generation in a Storm cluster (running on Azure HDInsight) which is having issues with the version of Gson that is attempted to be used.
The exception that is generated was:
tried to access method com.google.gson.Gson.newJsonWriter(Ljava/io/Writer;)Lcom/google/gson/stream/JsonWriter; from class retrofit2.converter.gson.GsonRequestBodyConverter
To work around this issue I had to write my own Converter.Factory that used the version of Gson I had available to me, and then serialize/deserialize as appropriate.
Thinking that I had my issue resolved I removed the converter-gson dependeny from my POM only to find that my generated-sources now no longer compile.
This got me to thinking - Retrofit allows a pluggable infrastructure for the serialization of content, so it would make sense to have a template that generates a Retrofit binding that does not make any assumptions about Gson or the converter-gson dependency being available.
Swagger-codegen version
swagger-codegen-maven-plugin:2.2.1
Related issues
How do I use the Gson converter in RetroFit?
GsonConverter is not resolved
Suggest a Fix
I am happy to fork the repo and create a new plugin, however it does look like that there would be minimal changes to the moustache files to make this happen, so am wondering what the best way to implement this would be?
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
No source file or test is named; start by tracing the Maven plugin's generated Retrofit templates and their Gson converter dependency. Define the template/plugin approach that lets generated bindings use caller-provided serialization without requiring converter-gson, then verify the generated sources compile and serialize/deserialize correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100