这豆'州':
public class State {
private boolean isSet;
@JsonProperty("isSet")
public boolean isSet() {
return isSet;
}
@JsonProperty("isSet")
public void setSet(boolean isSet) {
this.isSet = isSet;
}
}
Run Code Online (Sandbox Code Playgroud)
使用ajax'success'回调通过线路发送:
success : function(response) {
if(response.State.isSet){
alert('success called successfully)
}
Run Code Online (Sandbox Code Playgroud)
这里需要注释@JsonProperty吗?使用它有什么好处?我想我可以删除这个注释而不会产生任何副作用.
在https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations上阅读这个注释我不知道什么时候需要使用它?
我正在(gradle)spring boot 项目中使用 openAPI 实现 petstore API。我使用 openapi 生成器插件生成一个服务器并实现一个简单的请求:
@Service
@RestController
public class PetApiController implements PetApi {
@Override
public ResponseEntity<Pet> getPetById(Long petId) {
Pet p = new Pet();
p.setId(0L);
p.setName("fido");
p.setPhotoUrls(new ArrayList<String>());
p.setStatus(StatusEnum.AVAILABLE);
p.setTags(new ArrayList<Tag>());
Category c = new Category();
c.setId(3L);
c.setName("dummy category");
p.setCategory(c);
ResponseEntity<Pet> r = new ResponseEntity<Pet>(p, HttpStatus.OK);
return r;
}
}
Run Code Online (Sandbox Code Playgroud)
我生成的 swagger-ui 为请求提供了 xml 和 json 查询,但 xml 似乎不起作用:
$ curl -X GET "http://localhost:8080/pet/1" -H "accept: application/xml"; echo ""
$ curl -X GET "http://localhost:8080/pet/1" -H "accept: …Run Code Online (Sandbox Code Playgroud)