Support multiple types on a field descriptor and assert that actual type matches one of them
The following code produce a nice output in the type column, but It does not perform the assertion:
fieldWithPath("uid").type(Arrays.asList(JsonFieldType.STRING, JsonFieldType.NULL));
Is there a better way to do it? Would you accept a pull request about this?
That sounds like a nice improvement. A PR would be welcome. Looks like the assertion could be performed whenever a collection or array of JsonFieldType is passed in.
OK, I will do a pull request these week.
What do you think about adding .type(JsonFieldType... types), .type(JsonFieldType type) and deprecate .type(Object obj).
is there any reason to use an object instead of JsonFiledType?
OK, I will do a pull request these week.
Thanks
What do you think about adding .type(JsonFieldType... types), .type(JsonFieldType type) and deprecate .type(Object obj)
Overloading with (JsonFieldType... types) and (JsonFieldType type) is worth considering, although I'm not sure that I want JSON-specific classes on FieldDescriptor.
Is there any reason to use an Object instead of JsonFieldType?
Yes, the payload may not be JSON. For example, REST Docs also supports XML payloads.
@victorherraiz @wilkinsona Is there any progress or any plan to add this feature?
I have this already implemented in my local repo, but I have not had time to updated and push it, I have to help other projects in my company and I abandoned the POC I was doing. I will do it this week. Sorry for the late reply.
@victorherraiz good news. thanks!
https://github.com/wilkinsona/spring-restdocs/tree/gh-352