0

私はspringdoc-openapi-ui swagger で作業しています。の値をハードコーディングしたくありませんswagger documentation。プロパティファイルからそのような値を読み取りたいです。

試してみると、コンパイルエラーが発生していますThe value for annotation attribute Operation.summary must be a constant expression.

定数式を探していることはわかっていますが、これらの値をコードにハードコーディングしたくありません。

ここに画像の説明を入力

ここで私のコントローラーコードを見つけてください

@RestController
@PropertySource("classpath:test.properties")
public class TestController {

    @Autowired
    private TestService testService;

    @Autowired
    private static Environment environment;

    final String SUMMARY = environment.getProperty("operationSummary");

    @Operation(summary = SUMMARY, description = "Returns a list", tags = { "Test" })
    @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successful operation") })
    @GetMapping(path = "/description/{id}")
    public List<Test> getDescriptionById(@PathVariable String id) {

        return testService.getDescriptionById(id);
    }
}

エンドポイントの注釈に異なる言語のメッセージ プロパティを追加する方法はありますか?

4

2 に答える 2