Ignore property for type conversion of declarative client URI argument

ⅰ亾dé卋堺 提交于 2019-12-11 04:31:38

问题


I am implementing a declarative client in Micronaut that looks like this:

@Get("/dostuff{?requestObject*}")
fun getStuff(requestObject: MyRequestObject): String

My MyRequestObject is validated with Javax.Validation and looks like this:

data class MyRequestObject(val anything: String) {

    @AssertTrue
    fun isValid() = true
}

When I now send a request via the client the value from requestObject generates the following query /?anything=helloworld&valid=true. I need to exclude the value from the isValid function from the query.

Now I have two questions

  1. What is the mechanism that is used by Micronaut to "deserialize" the object?
  2. How can I achieve that the valid field is not included in the query?

回答1:


The expansion of the URL takes place here: https://github.com/micronaut-projects/micronaut-core/blob/7cd78cf8b03cc78ac31bc2c262e86eae6edd58f0/http/src/main/java/io/micronaut/http/uri/UriTemplate.java#L202

Either through the introspection api or reflection the class is inspected and converted to a map. Currently there is no way to exclude properties in this manner. Please file an issue to suggest improvement of this feature.



来源:https://stackoverflow.com/questions/55967185/ignore-property-for-type-conversion-of-declarative-client-uri-argument

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!