Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@ApiModelProperty to @Schema

I'm trying to migrate springfox to springdoc using this code:

import io.swagger.annotations.ApiModelProperty;

@ApiModelProperty(position = 30, required = true, value = "Group value")

to

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(position = 20, required = false)

But I get not found for position and value. Do you know what is the proper way to replace them in springdoc?

like image 733
Peter Penzov Avatar asked Oct 13 '25 03:10

Peter Penzov


1 Answers

Ensure that your fields are declared in the same order you want them to show up in swagger,

position isn't available in Springdoc cause by default it preserves the order in which the fields are declared.

value was to describe the model property and is called description in the new world.

So the old code

import io.swagger.annotations.ApiModelProperty;

@ApiModelProperty(position = 30, required = true, value = "Group value")

becomes

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description="Group Value", required = true)
like image 63
Debargha Roy Avatar answered Oct 16 '25 10:10

Debargha Roy