You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/05/09 09:43:35 UTC
[GitHub] [servicecomb-java-chassis] huanghezhen opened a new issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
huanghezhen opened a new issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741
#### model
```java
@Data
public class OrderDTO
{
@ApiModelProperty(hidden = true)
private String name;
private List<OrderSubDTO> orderDTOList;
}
```
#### ctrl
```java
@RpcReference(microserviceName = "provider", schemaId = "ProviderService")
public ProviderService providerService;
@GetMapping("/testApiModelProperty")
public BaseResponse<String> testApiModelProperty() throws Exception {
OrderDTO orderDTO = new OrderDTO();
orderDTO.setName("hhz");
return providerService.testApiModelProperty(orderDTO);
}
```
#### rpc
```java
@Override
public BaseResponse<String> testApiModelProperty(OrderDTO orderDTO) {
System.out.println(orderDTO.getName());
return BaseResponse.newInstance(orderDTO.getName());
}
```
#### 结果
```java
hhz
2020-05-09 17:36:49.783 [vert.x-eventloop-thread-7] INFO org.apache.servicecomb.foundation.vertx.server.TcpServerConnection - 36 - connect from 192.168.2.148:54155, in thread vert.x-eventloop-thread-7
2020-05-09 17:36:50.342 [vert.x-eventloop-thread-7] INFO org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.MessageReadSchema - 133 - java field hhz.springboot.common.entity.OrderDTO:name not exist in proto message provider.ProviderService.OrderDTO, ignore it.
null
hhz
2020-05-09 17:36:52.752 [vert.x-eventloop-thread-0] INFO org.apache.servicecomb.foundation.vertx.server.TcpServerConnection - 36 - connect from 192.168.2.148:54158, in thread vert.x-eventloop-thread-0
null
2020-05-09 17:36:55.566 [Default Service Center Task [1]] INFO org.apache.servicecomb.serviceregistry.task.ServiceCenterTaskMonitor - 39 - sc task interval changed from -1 to 30
```
### 疑问
我的理解是@ApiModelProperty(hidden = true) 应该只是在接口文档是隐藏的,这个注解注释的字段应该是有数据的,在传输的时候不应该为null
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626584725
有可能 provider 同时启用了两个 transport, REST + HIGHWAY. highway 目前序列化的内容就是契约里面描述的内容,没办法像 json 那样,通过 `@JsonIgnore`来排除 。 我理解你的场景, username是否序列化没有关系,“在调用这个接口之后 会设置username这个属性”
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626145070
REST 才会序列化这个字段。 highway 不会。 highway 的处理逻辑是 swagger -> idl , 根据 idl 进行数据序列化的, 不在 idl 里面描述的内容,就不会序列化。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626584725
有可能 provider 同时启用了两个 transport, REST + HIGHWAY. highway 目前序列化的内容就是契约里面描述的内容,没办法像 json 那样,通过 `@JsonIgnore`来排除
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626443021
您好,这边有这样的场景 有一个接口是不需要传递username这个参数的,在调用这个接口之后 会设置username这个属性然后使用highway再去调用别的服务 这个期间是同一个对象 我想在接口文档隐藏username这个属性,该如何实现呢?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626443276
highway 是否序列化 能否不根据hidden = true 这个属性呢? 只是在文档接口展示的时候才去判断hidden这个属性
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626584725
有可能 provider 同时启用了两个 transport, REST + HIGHWAY. highway 目前序列化的内容就是契约里面描述的内容,没办法像 json 那样,通过 `@JsonIgnore`来排除 。
如果你需要开发两个接口:一个需要序列化字段username,一个不需要序列化字段username,建议定义两个不同的model。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626506077
1.3版本之前的 highway通信 传递含有泛型的对象时 反序列化也是一次成功一次失败
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626139019
版本是 2.0.1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626632241
如果不是这个问题 我还以为只会用 HIGHWAY
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626628732
但是为什么 开启了HIGHWAY 为什么还会走 REST 呢?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626628253
嗯嗯 谢谢您 目前就是按照您说这样定义两个model, 确实是开启了两个transport,我说怎么会一次失败一次成功呢
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] huanghezhen commented on issue #1741: @ApiModelProperty(hidden = true) 这个注解注释的字段 highway 模式下不能正常序列化
Posted by GitBox <gi...@apache.org>.
huanghezhen commented on issue #1741:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1741#issuecomment-626505104
还有一个地方不明白,它为什么一次成功一次失败
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org