OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.76k stars 6.56k forks source link

[BUG] Failed at unknown property #19482

Open Yingsheng-eroad opened 2 months ago

Yingsheng-eroad commented 2 months ago

Bug Report Checklist

Description

I am using openapi-generator-maven-plugin to generate the client jar of my application A. The client jar is introduced as a dependency of application B. Application B is calling the API of A at runtime time. At some point, a new property onlineState was added to the DeviceDto, which caused application B to fail when trying to get the device.

Here is the stack.

Caused by: java.lang.IllegalArgumentException: The field `onlineState` in the JSON string is not defined in the `DeviceDto` properties. JSON: {\"serialNumber\":\"002\",\"onlineState\":\"OFFLINE\"}
    at package.name.DeviceDto.validateJsonElement(DeviceDto.java:148)
    at package.name.DeviceDto$CustomTypeAdapterFactory$1.read(DeviceDto.java:178)
    at package.name.DeviceDto$CustomTypeAdapterFactory$1.read(DeviceDto.java:168)
    at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
    at com.google.gson.Gson.fromJson(Gson.java:932)
    at com.google.gson.Gson.fromJson(Gson.java:897)
    at com.google.gson.Gson.fromJson(Gson.java:846)
    at package.name.client.api.JSON.deserialize(JSON.java:156)
    at package.name.client.api.ApiClient.deserialize(ApiClient.java:895)
    at package.name.client.api.ApiClient.handleResponse(ApiClient.java:1105)
    at package.name.client.api.ApiClient.execute(ApiClient.java:1029)
    at package.name.client.api.DeviceApi.getDeviceBySerialNumberWithHttpInfo(DeviceApi.java:693)
    at package.name.client.api.DeviceApi.getDeviceBySerialNumber(DeviceApi.java:673)
openapi-generator version

7.2.0

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Kugaaa commented 2 months ago

I got the same problem. I think it like a question of strict mode, I tried the following parameters, but they didn't work

--strict-spec false \
--skip-validate-spec \