Skip to content

[BUG] [webclient] Missing default null value for Object #23908

Closed

Description

@kadamar
Description

Missing default null value for Object in generated model for webclient

openapi-generator version

Bug reproduced since 7.13.0 and in latest version 7.22.0.
Generation was correct in 7.12.0 version.

OpenAPI declaration file content or url

Using openapi example

          properties:
            records:
              type: 'null'
Generation Details

I got generated correct DTO in 7.12.0 version.

    @Nullable
    private Object records = null;

But since 7.13.0 and in latest version 7.22.0 where is no null value in generated pojo.
If not modify openapi schema generated dto will not compiled couse of missing ModelNull

  @jakarta.annotation.Nullable
  private **ModelNull** records = null;

If I change openapi

          properties:
            records:
              default: null
              type: object

I got generated, but without default null value

  @jakarta.annotation.Nullable
  private Object records;
Steps to reproduce

Using openapi-generator-maven-plugin

<execution>
                            <id>webclient-generation</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <skip>${skip.webclient}</skip>
                                <inputSpec>${inputSpec}</inputSpec>
                                <generatorName>java</generatorName>
                                <templateDirectory>${webclient.templateDirectory}</templateDirectory>
                                <generateModelTests>false</generateModelTests>
                                <generateApiTests>false</generateApiTests>
                                <generateSupportingFiles>true</generateSupportingFiles>
                                <modelPackage>${webclient.base-package}.dto</modelPackage>
                                <apiPackage>${webclient.base-package}.api</apiPackage>
                                <invokerPackage>${webclient.base-package}.invoker</invokerPackage>
                                <configOptions>
                                    <library>webclient</library>
                                    <sourceFolder>webclient</sourceFolder>
                                    <implFolder>webclient</implFolder>
                                    <useSwaggerAnnotations>false</useSwaggerAnnotations>
                                    <jackson>true</jackson>
                                    <withXml>false</withXml>
                                    <supportAsync>true</supportAsync>
                                    <useSpringBoot3>true</useSpringBoot3>
                                    <useJakartaEe>true</useJakartaEe>
                                    <openApiNullable>false</openApiNullable>
                                </configOptions>
                                <openapiNormalizer>
                                    REF_AS_PARENT_IN_ALLOF=true
                                </openapiNormalizer>
                            </configuration>
                        </execution>
Suggest a fix

In generated webclient model in DTO should be default null value for Object type

    @Nullable
    private Object records = null;

Activity

  1. anupamchaubey commented on Jun 6, 2026

    @anupamchaubey
    Contributor

    I'm looking into this regression regarding the ModelNull generation bug for the Java webclient.

  2. wing328 commented on Aug 15, 2026

    @wing328
    Member

    I added a test via #24701 to cover null type only in properties.

    please give it a try with the latest master to see if you still experience the same issue

    happy to reopen the issue if needed.

  3. renechoi commented on Sep 9, 2026

    @renechoi
    Contributor

    Still reproduces on master (7.26.0-20260909.075159). One property, java webclient, only the quoting differs:

    type: 'null' gives private ModelNull records = null; and no ModelNull.java is generated.
    type: null gives private JsonNullable<Object> records.

    The fixture in #24701 uses the unquoted form, which YAML reads as a null scalar, so that schema carries no type at all. That is why the sample shows Object and the round-tripped api/openapi.yaml has no type line for it.

    okhttp-gson matches. typescript-axios emits Null.

    Bisect to 7.17.0 and the normalizer path: #24520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions