Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set description to a field using swagger OpenAPI annotations

To improve our api documentation I want to add a description to a field of a response body

as an example see the default petstore spec here: https://editor.swagger.io/

In the POST /pet in the pet response, status has the description "pet status in the store"

How can I do this from an annotation perspective in my code base?

(swagger v3)

like image 665
Viktor Baert Avatar asked Mar 22 '26 01:03

Viktor Baert


1 Answers

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

public class Pet {
    @Schema(description = "Pet status in the store")
    private String status;
}

thanks @viktor-baert

like image 52
Dennis Gloss Avatar answered Mar 24 '26 15:03

Dennis Gloss