You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that the default generated contract tests include a statusSuccess test which passes if the result is 2XX. I was actually surprised recently when I realized that one of my APIs was returning a 200, instead of a 204, as it was intended, that it wasn't caught by the autogenerated portman tests.
Is it possible to configure Postman to automatically have a test to see if the returned status matches what was specified in the OpenAPIResponse directive? Here's an example that manually does this:
I'd like it if I could "auto-magically" set this test so that instead of setting the value to 204, it used whatever value has been specified in the OpenAPIResponse directive. This way I can validate that all my positive and negative tests are returning the expected error code.
Perhaps in addition to the contractTests statusSuccess and statusCode, there could be one statusOpenAPIResponse?
Even if this test wasn't automatically generated, if OpenAPIResponse could be a TemplateExpression, that would make it straightforward to add the test described above globally.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I know that the default generated contract tests include a
statusSuccess
test which passes if the result is 2XX. I was actually surprised recently when I realized that one of my APIs was returning a 200, instead of a 204, as it was intended, that it wasn't caught by the autogenerated portman tests.Is it possible to configure Postman to automatically have a test to see if the returned status matches what was specified in the
OpenAPIResponse
directive? Here's an example that manually does this:I'd like it if I could "auto-magically" set this test so that instead of setting the value to 204, it used whatever value has been specified in the OpenAPIResponse directive. This way I can validate that all my positive and negative tests are returning the expected error code.
Perhaps in addition to the contractTests
statusSuccess
andstatusCode
, there could be onestatusOpenAPIResponse
?Even if this test wasn't automatically generated, if OpenAPIResponse could be a TemplateExpression, that would make it straightforward to add the test described above globally.
Beta Was this translation helpful? Give feedback.
All reactions