Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple types on a field descriptor and assert that actual type matches one of them #352

Open
victorherraiz opened this issue Feb 20, 2017 · 7 comments

Comments

@victorherraiz
Copy link

victorherraiz commented Feb 20, 2017

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?

@wilkinsona
Copy link
Member

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.

@victorherraiz
Copy link
Author

victorherraiz commented Feb 20, 2017

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?

@wilkinsona
Copy link
Member

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.

@BK-Choi
Copy link

BK-Choi commented Apr 18, 2017

@victorherraiz @wilkinsona
Is there any progress or any plan to add this feature?

@victorherraiz
Copy link
Author

victorherraiz commented Apr 18, 2017

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.

@BK-Choi
Copy link

BK-Choi commented Apr 21, 2017

@victorherraiz
good news. thanks!

@wilkinsona wilkinsona added this to the 2.1.0.RC1 milestone Mar 28, 2018
@wilkinsona wilkinsona changed the title Support multiple type assertion Support multiple types on a field descriptor and assert that actual type matches one of them Mar 28, 2018
@wilkinsona
Copy link
Member

@wilkinsona wilkinsona removed this from the 2.1.0-RC1 milestone Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants