OpenAPITools / OpenAPITools/openapi-generator

[BUG] Failed at unknown property

Open
#19,482 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated DeviceDto.java stack location, especially validateJsonElement, and reproduce against openapi-generator 7.2.0 using the missing OpenAPI declaration and generation steps, which the issue does not provide. Done means identifying and documenting the generator behavior for the added onlineState property with a minimal reproducible specification and regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.