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

How to validate complex object responses #58

Open
humbienri opened this issue Mar 4, 2020 · 3 comments
Open

How to validate complex object responses #58

humbienri opened this issue Mar 4, 2020 · 3 comments
Labels
question Further information is requested

Comments

@humbienri
Copy link

humbienri commented Mar 4, 2020

Hello,

Perhaps I am just not getting it, even after having read the example-spec.yaml example. How can I validate a more complicated response body/payload. For example, something like:

{
    "status": "ok",
    "info": {
        "stats": {
            "status": "up",
            "serviceName": "service.name",
            "version": "1.0.11"
        },
        "aConnector": {
            "status": "up"
        }
    },
    "details": {
        "stats": {
            "status": "up",
            "serviceName": "service.atyours",
            "version": "1.0.1"
        },
        "theConnector": {
            "status": "up"
        }
    }
}

I guess I am referring to nesting of json objects so as to confirm that the response body conforms to something more specific. Notice how some of those status keys are duplicated so it's not just a matter of validating that the "status up" exists somewhere in the response, but specifically.

Thanks!

@aviaviavi
Copy link
Owner

Hi @humbienri, you are correct that this more complex sort of matching is not cleanly supported by curl-runnings right now. You could check that details or info are the exact thing you're expecting, but not much more than that if you have such a similar payload in both spots.

This is something I have been meaning to add, but haven't had the need yet and you're the first to ask for it. 😄 I'll think on ways to implement this, I think there are some relatively lightweight solutions like allowing you to supply a traversal path to run the matcher at.

To make sure I am accounting for what you have in mind, can you give me an example or two of something you're trying to assert about this payload you shared?

@humbienri
Copy link
Author

Hello,

I was envisioning doing something like jsonschema validation to a response payload. For example, https://davidwalsh.name/json-validation

be able to specify keys and structure pretty tightly yet not specify hard coded or fixed values but types of values, like strings or numbers, etc.

@aviaviavi
Copy link
Owner

I really the idea of type checking against a json schema. Probably won't be too hard to add. Making a separate issue for that to track it.

@aviaviavi aviaviavi added the question Further information is requested label Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants