Bug Report Checklist
Description
API client libraries generated with OpenAPI Generator should ignore response fields that were not existing at the time the code was generated, instead of raising the following error:
java.lang.IllegalArgumentException: The field `updated` in the JSON string is not defined in the `Dog` properties. JSON: {"name":"Luna","created":"2021-04-23T17:32:28Z","updated":"2021-04-23T17:32:28Z"}
openapi-generator version
| Version |
Status |
| OpenAPI Generator 5.4.0 |
✔️ |
| OpenAPI Generator 6.0.0 |
❌ |
| OpenAPI Generator 6.0.1-SNAPSHOT |
❌ |
OpenAPI declaration file content or url
sample-v1.yaml
sample-v2.yaml
Download ⤓
Generation Details
java -jar openapi-generator-cli-5.4.0.jar generate -g java -i sample-v1.yaml -c config.json -o api_client_5.4
java -jar openapi-generator-cli-6.0.0.jar generate -g java -i sample-v1.yaml -c config.json -o api_client_6.0
{
"groupId" : "com.acme.app",
"artifactId" : "sample-api-client",
"artifactVersion" : "1.0.0",
"invokerPackage" : "com.acme.app",
"apiPackage" : "com.acme.app.api",
"modelPackage" : "com.acme.app.model"
}
Steps to reproduce
- Generate a client from
sample-v1.yaml:
java -jar openapi-generator-cli-6.0.0.jar generate -g java -i sample-v1.yaml -c config.json -o api_client_6.0
- Update
DogsApiTest:
public class DogsApiTest {
@Test
public void addDogTest() throws ApiException {
// GIVEN
ApiClient client = new ApiClient();
client.setDebugging(true);
client.setBasePath("http://localhost:4010");
NewDog newDog = new NewDog()
.name("Bella");
// WHEN
Dog dog = new DogsApi(client).addDog(newDog);
// THEN
assertNotNull(dog);
}
}
- Run
prism.exe mock sample-v1.yaml
- Run
addDogTest => ✔️
- Run
prism.exe mock sample-v2.yaml
- Run
addDogTest => ❌
java.lang.IllegalArgumentException: The field `updated` in the JSON string is not defined in the `Dog` properties. JSON: {"name":"Luna","created":"2021-04-23T17:32:28Z","updated":"2021-04-23T17:32:28Z"}
at com.acme.app.model.Dog.validateJsonObject(Dog.java:217)
at com.acme.app.model.Dog$CustomTypeAdapterFactory$1.read(Dog.java:253)
at com.acme.app.model.Dog$CustomTypeAdapterFactory$1.read(Dog.java:243)
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
at com.google.gson.Gson.fromJson(Gson.java:991)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.acme.app.JSON.deserialize(JSON.java:151)
at com.acme.app.ApiClient.deserialize(ApiClient.java:845)
at com.acme.app.ApiClient.handleResponse(ApiClient.java:1053)
...
Bug Report Checklist
Description
API client libraries generated with OpenAPI Generator should ignore response fields that were not existing at the time the code was generated, instead of raising the following error:
openapi-generator version
OpenAPI declaration file content or url
sample-v1.yamlsample-v2.yamlDownload ⤓
Generation Details
java -jar openapi-generator-cli-5.4.0.jar generate -g java -i sample-v1.yaml -c config.json -o api_client_5.4java -jar openapi-generator-cli-6.0.0.jar generate -g java -i sample-v1.yaml -c config.json -o api_client_6.0{ "groupId" : "com.acme.app", "artifactId" : "sample-api-client", "artifactVersion" : "1.0.0", "invokerPackage" : "com.acme.app", "apiPackage" : "com.acme.app.api", "modelPackage" : "com.acme.app.model" }Steps to reproduce
sample-v1.yaml:DogsApiTest:prism.exe mock sample-v1.yamladdDogTest=> ✔️prism.exe mock sample-v2.yamladdDogTest=> ❌