Swagger with Springboot add personalized information whith java anotations

dante :

How do I personalize the information displayed on the page in swagger-UI whith java anotations?

in swagger petstore

dante :

if you want to customize the api information you can include java style annotations:



    @OpenAPIDefinition(
        info = @Info(
                 title = "API personas", 
                 description = "Este es un ejemplo de servidor Personas-Server."
            + "Usted puyede encontrar mas acerca de Swagger " ++"[http://swagger.io](http://swagger.io) o en "
            + "[irc.freenode.net, #swagger](http://swagger.io/irc/).",
            termsOfService = "http://swagger.io/terms/", 
              license = @License(
                          name = "Apache 2.0", 
                          url = "http://springdoc.org"), 
       version = "otra"
    ))
    @Tag(name = "persona", description = "API para personas")
    @RestController
    @RequestMapping("persona")
    public class PersonaRest extends GeneralRest {}

can also be generated for special methods:



     @Operation(
         summary = "traer todas las personas", 
         description = "api para traer todas las personas, aqui no se tienen en cuenta paginaciones, ni filtros, trae todos los registros", 
         tags = { "persona" }
         )
     @ApiResponses(
         value = {
         @ApiResponse(
             responseCode = "200", 
             description = "Operación exitosa", 
             content = @Content(
                 mediaType = "application/json", 
                 array = @ArraySchema(
                     schema = @Schema(
                         implementation = PersonaTO.class
                         )))),
         @ApiResponse(
             responseCode = "401", 
             description = "Sin autorización", 
             content = @Content(
                 mediaType = "application/json", 
                 schema = @Schema(
                     implementation = Object.class
                     ))),
     })
     @GetMapping
     public List personas() {
            return personaServicio.obtenerTodo();
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related