-
Notifications
You must be signed in to change notification settings - Fork 5
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 inline json request and response representations in specification #9
Comments
This is already supported, but unwieldy. Instead of representation-ref use representation field. |
Sorry, what we meant to say was, support inline json type... ie, instead of: representation: "{ \"field\": \"value\" }", we would support: representation: { "field": "value" }, Would you agree this is easier to write/maintain? |
How will you distinguish between a representation which is a string On Thu, May 15, 2014 at 9:10 AM, davidsiefert [email protected]:
|
Not yet seeing this as a problem--when would you need to distinguish the two? They are both inserted into the request body. If it is a string, it is put in verbatim. If it is a JSON object, it is marshalled into a string. May I please have you provide a more detailed example of where this would break down? |
I can think of two other potential solutions here:
On Thu, May 15, 2014 at 9:14 AM, jking-roar [email protected]:
|
@ratamacue--take a look at the rest spec mockrunner project--you should not have to do JSONAssert in your test to match against things in your rest spec. Your test can be simpler using the mockrunner, and you'd be TDD'ng with your spec as the guidepost. Feedback is welcome. |
The rest spec mockrunner project uses a string comparison to match two JSON On Thu, May 15, 2014 at 9:28 AM, davidsiefert [email protected]:
|
@ratamacue--JSON comparison was already added to the mockrunner (see https://github.com/cjdev/rest-specs/blob/master/mockrunner/src/main/java/com/cj/restspecs/mockrunner/RestSpecServletValidator.java#L184). I was not aware at the time this was put in that people would be picky about being able to assert a json object as a string. Perhaps this option could be given to the user by changing the design of the mockrunner slightly to allow a different request/response comparison implementation to be injected (ie, follow the Open-Close Principle). |
Ooh.. I didn't notice that change. The project I was referencing must have On Thu, May 15, 2014 at 10:18 AM, davidsiefert [email protected]:
|
Oops, i hit the closed button by mistake! Undo! Undo! Arghhhh!!! |
I wouldn't want the tool to eliminate the ability to specify a response
|
@jking-roar: Would it be better if we just turned json detection off (remove code that was implemented mentioned in my response to @ratamacue), and have it only do json comparison if request/response representation is a json object in the spec (not a json object in a string)? To elaborate completely, these are the possible scenarios... "representation": "not a json object here" will do String.equals comparison, and "representation": "{ ... }" will do String.equals, and lastly "representation": {
...
} will do json equivalence (so field order in objects does not matter, and neither does spacing). |
I would prefer the decision of how to parse be based on an explicit
|
Agreed. Such as perhaps passing in a Hamcrest Matcher and bundling a few
|
whoops! |
To avoid having to create a separate file
The text was updated successfully, but these errors were encountered: