嵌入式摇摇欲坠会产生X-WWW形式的肉体编码的身体缺少什么?
我正在尝试找出为什么OpenAPI Generator生成的春季服务器在带有X-WWW-Form-urlenCoded Body的Postman Post请求中适当接受“ user = foo”,“ password = bar”的请求(如预期)使用Springfox-Swagger2嵌入服务器中的Swagger页面生成了一个
curl -X 'POST' \
'http://localhost:8080/v1.0/login?username=foo&password=bar' \
-H 'accept: */*' \
-d ''
请求,该请求返回415个未支撑的媒体类型。对于记录,来自OpenAPI规范的生成的Java客户端显示相同的行为。生成的Java方法看起来像:(
@Operation(
operationId = "loginPost",
responses = {
@ApiResponse(responseCode = "200", description = "User successfully logged in."),
@ApiResponse(responseCode = "400", description = "User login failed."),
@ApiResponse(responseCode = "415", description = "Unsupported Media Type")
}
)
@RequestMapping(
method = RequestMethod.POST,
value = "/login",
consumes = { "application/x-www-form-urlencoded" }
)
default ResponseEntity<Void> loginPost(
@Parameter(name = "username", description = "", required = true) @Valid @RequestParam(value = "username", required = true) String username,
@Parameter(name = "password", description = "", required = true) @Valid @RequestParam(value = "password", required = true) String password
) {
return getDelegate().loginPost(username, password);
}
自动生成,我的代码在getDelegate()委托)中。
我的猜测是,生成的Java代码上的属性略有关闭,因此我想找出需要修复的内容,以便我可以向OpenAPI Generator Project报告一个错误,希望使用补丁。
我看到的原因是什么?
I am trying to find out why my Spring server generated by OpenAPI generator properly accepts requests with "user=foo", "password=bar" in a Postman POST request with x-www-form-urlencoded body (as expected), but the Swagger page embedded in the server using springfox-swagger2 generates a
curl -X 'POST' \
'http://localhost:8080/v1.0/login?username=foo&password=bar' \
-H 'accept: */*' \
-d ''
request, which returns a 415 Unsupported Media Type. For the record, the generated Java client from the OpenAPI specification shows the same behavior. The generated Java method looks like:
@Operation(
operationId = "loginPost",
responses = {
@ApiResponse(responseCode = "200", description = "User successfully logged in."),
@ApiResponse(responseCode = "400", description = "User login failed."),
@ApiResponse(responseCode = "415", description = "Unsupported Media Type")
}
)
@RequestMapping(
method = RequestMethod.POST,
value = "/login",
consumes = { "application/x-www-form-urlencoded" }
)
default ResponseEntity<Void> loginPost(
@Parameter(name = "username", description = "", required = true) @Valid @RequestParam(value = "username", required = true) String username,
@Parameter(name = "password", description = "", required = true) @Valid @RequestParam(value = "password", required = true) String password
) {
return getDelegate().loginPost(username, password);
}
(automatically generated, my code is in the getDelegate() delegate).
My guess is that the attributes on the generated Java code is slightly off, so I would like to find out what needs to be fixed so I can report a bug to the OpenAPI generator project, hopefully with a patch.
What is the reason for what I see?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论