Skip to content

defaultValue attribute at enum object generate arbitrary json file #4908

Open
@bosofelipe

Description

@bosofelipe

I have an enum object mapped in @Schema, that change arbitrary in each build

Sample

@Schema(defaultValue = "DELIVERY", name = "type",
      description = "Type of the shipping", example = "DELIVERY",
      enumAsRef = true)
"ShippingType" : {
        "type" : "string",
        "description" : "Type of the shipping",
        "example" : "DELIVERY",
        "default" : "DELIVERY",
        "enum" : [ "DELIVERY", "REVERSE", "TRANSFERENCE" ]
      },


"ShippingType" : {
        "type" : "string",
        "description" : "Type of the shipping",
        "example" : "DELIVERY",
        "enum" : [ "DELIVERY", "REVERSE", "TRANSFERENCE" ],
        "default" : "DELIVERY"
      },

Property default arbitrary order in object ShippingType in openapi json file

If i remove defaultValue, the json always the same

@Schema(name = "type",
      description = "Type of the shipping", example = "DELIVERY",
      enumAsRef = true)

plugin at pom.xml

<plugin>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-maven-plugin-jakarta</artifactId>
                <version>${swagger-maven-plugin.version}</version>
                <configuration>
                    <outputFileName>openapi</outputFileName>
                    <resourcePackages>
                        <resourcePackage>com.x.test.adapter.input.web</resourcePackage>
                    </resourcePackages>
                    <outputPath>${basedir}/target/resources/com/x/test/adapter/input/web</outputPath>
                    <outputFormat>JSONANDYAML</outputFormat>
                    <prettyPrint>true</prettyPrint>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-doc</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Is that a way to fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions