我用的swagger是springdoc依赖不需要配置其他的类
直接导入依赖
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-api</artifactId> <version>2.0.2</version> </dependency>
jdk17+springboot3
参考这位大哥的
与csdn其他文章有所不同我这遇到的问题比较离谱!
Please correct the following validation errors and try again.
- Value must be a string
在swagger中显示的界面可以上传文件
如图所示后续呢就是选择文件上传后出现如图所示
比较郁闷的是我试了其他友友的建议改了 参数加上@requestpart("file")
反而没有上传文件的表示标识符了。
先当个问题吧!
2024/3/8问题在一次又一次百度中得到解决
在参数前加一个这个注解就可以解决
@io.swagger.v3.oas.annotations.parameters.RequestBody( description = "附件", content = @Content( mediaType = "multipart/form-data", schema = @Schema(type = "object"), schemaProperties = { @SchemaProperty( name = "file", schema = @Schema(type = "string", format = "binary") ) } ) )
我真的哭死这里市swagger接口的问题
2024/3/12又发现一个更为便捷的方法
在方法中添加@postmapging(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)中添加 且在参数前添加@RequestPart("file")