Skip to content

@Schema(example="1234", type="string") interpreted as integer #4820

Open
@EAlf91

Description

Background
After upgrading swagger to 3.1 we face the issue that our schema annotations which have numbers in their examples gets interpreted as integers even though the type is a string.

Example

 record TestDto (@Schema(example = "notANumber") String name, int age) {} //works perfectly fine
 record TestDtoClone (@Schema(example = "1234", type = "string") String name, int age) {} //interpreted as integer even with type="string"

I created a small demo project with a basic test:
https://github.com/EAlf91/swagger-issue/blob/main/src/test/java/org/example/MainTest.java

Expected Behaviour
String examples are correctly interpreted as string when typing is provided

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