I am trying to get Swagger to read the API documentation from a properties file swagger.properties
but can't. In @ApiOperation
annotation there is an error saying: Attribute value must be constant
. Any suggestions about how to solve this and be able to read the documentation from a properties file?
Here is the Controller code:
package com.demo.student.demo.controller;
import com.demo.student.demo.entity.Student;
import com.demo.student.demo.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/v1/students")
@Api(description = "Set of endpoints for Creating, Retrieving, Updating and Deleting of Students.")
public class StudentController {
private final String message;
public StudentController(@Value("${test.swagger.message}") String message){
this.message=message;
}
@Autowired
private StudentService studentService;
@GetMapping
@ApiOperation(message)
public List<Student> findAll(){
return studentService.findAl();
}
}
And also, how can I inject a value at the class level in the @API(description)?