Skip to content

Setting type in @Schema has no effect #3052

@sam-hieken

Description

@sam-hieken

Describe the bug

The type property of @Schema has no effect for objects in the "Schemas" section of the Swagger page.

To Reproduce
Can be reproduced by cloning this repository, running mvn spring-boot:run, and navigating to http://localhost:8081/swagger-ui.html.

The UserModel class is explicitly defined as type = "integer":

public class UserModel {
	...

	/** User's age */
	@Schema(type = "integer", format = "int8")
	private byte age;
}

yet the default type (string for bytes in Java) is not overriden:

Image

I've tested this with type = "integer" on both Java Strings and bytes, both with the same result.

Expected behavior

The integer type being applied to the field in Swagger.

Screenshots
See above

Additional context
Using SpringDocs 2.8.9 and Spring Boot 3.5.4 (see POM of linked repo reproducing issue for other version info).

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