英文:
migrate dataType and paramType got Springdoc
问题
我已经迁移到SpringDoc,使用以下方式:
@Parameter(in = ParameterIn.HEADER, name = "token", description = "token", required = true, schema = @Schema(type = "string"))
我不知道如何替换 dataType
和 paramType
。你知道应该如何正确迁移吗?
英文:
I have this SpringFox api description param:
@ApiImplicitParam(value = "token", required = true, dataType = "string",
paramType = "header")
I migrated it to SpringDoc using:
@Parameter(value = "token", required = true, dataType = "string",
paramType = "header")
I can't find how to replace dataType
and paramType
. Do you know what should be the proper way to migrate it?
答案1
得分: 2
paramType
使用 in
。
dataType
使用 schema
。
示例
@GetMapping
public String index(@Parameter(name = "token", required = true, in = ParameterIn.HEADER, schema = @Schema(implementation = String.class)) @RequestHeader("token") String header) {
return header;
}
如果附加了 RequestHeader
注解,可以进一步简化。
@GetMapping
public String index(@Parameter(name = "token", required = true) @RequestHeader("token") String header) {
return header;
}
英文:
paramType
uses in
.
dataType
uses schema
.
example
@GetMapping
public String index(@Parameter(name = "token", required = true, in = ParameterIn.HEADER, schema = @Schema(implementation = String.class)) @RequestHeader("token") String header) {
return header;
}
If RequestHeader annotation is attached, it can be simplified a little more.
@GetMapping
public String index(@Parameter(name = "token", required = true) @RequestHeader("token") String header) {
return header;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论