-
Notifications
You must be signed in to change notification settings - Fork 59
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
Handling multiple request body Content-Type
on one endpoint
#466
Comments
hi @tillig Portman typically looks for the 1st JSON content type it comes across and uses that to generate the schema validation. |
Yeah, because each JSON type has a different schema associated - merge patch looks similar to the document getting patched, while JSON patch has a specific schema that specifies operations using JSONPath. Both are JSON, both have a JSON schema, but different schema per content type. |
hi @tillig Not sure if this is still relevant (if not feel free to close this issue). But we made some improvement in the latest version of Portman with regards the request body & the schema validation. You can specify as option, via the postman config --postmanConfigFile, with "preferredRequestBodyType", which request body content-type to take from OpenAPI. (typically: raw OR first-listed) Example
|
Is there a way to generate tests for all of the content types? That's really what I'm looking for with this issue - not just defaulting to one type, but actually generating tests based on all the types [assuming they're JSON compatible]. In this case, JSON patch vs. JSON merge patch - both are JSON, both are accepted, both have a schema associated, so it seems like both could get tests generated. |
Using Variations and some new config that could be an option, that we could explore. With variations (and fuzzing) we already are using the original requests and making variations from them. How would you expect to configure this? How would that variation config look like? |
I mean, I guess I wouldn't really expect to configure it a lot, but I haven't really thought it through deeply. I guess I'd just figure it's a |
We have had the request to generate multiple variations for different responses but you are looking for the case to generate variations per request content-type? something like this:
which would lead to requests:
|
@nicklloyd What would be your input on this idea? |
We have a specification that has a single endpoint for
PATCH
but allows either standard JSON patch (application/json-patch+json
) or JSON merge patch (application/merge-patch+json
) as input in the request body.I find that only the first one ends up generating contract tests.
I did see this issue about different content types (one being non-JSON) having some challenges getting handled, and this issue about handling JSON patch. They seem to slightly overlap with what I'm talking about, so I don't know if it's all connected or what.
Here's an example schema to show what I'm talking about:
schema.json (click to expand)
As the schema is now, it will generate tests for
application/json-patch+json
because that's the first one listed in therequestBody.content
listing. If you reorder them soapplication/merge-patch+json
is first, those are the tests you'll get.How do I get both?
The text was updated successfully, but these errors were encountered: