Skip to content

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

@kadamar

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions