I am tying to use openapi-generator-cli to make the model (pojo) classes from a json api definition. It works, but it makes more than I want.
I am using -g java --global-property models
as options, and this kind of works. It is only making the model classes now, and not all the API classes. However, it' still putting import in for things that are not found or used, for example;
Some imports are included which are not used, such as;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Which is ok because I am using that elsewhere.
However, some of the code in the models are importing code I do not have, which it not generated, nor do I want;
import org.openapitools.client.JSON;
public static AmendRequestPiecesInner fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, AmendRequestPiecesInner.class);
}
I literally JUST want the simple POJO classes, with no extra things.
Is this possible?
There is no simple option in OpenAPI Generator to achieve what you want.1
You can however use e.g. OpenAPI's "file post-processing" or "templating" features to adapt the generated code for your needs:
sed
/python/... command to remove the source code parts that you don't need.1 As you can check here, e.g. the code
return JSON.getGson().fromJson(
mentioned in OP's question will always be part of the output, as there are absolutely no conditionals around it.