This repository was archived by the owner on Nov 28, 2022. It is now read-only.
Start testing server responses against OpenAPI doc via Chai plugin #203
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Richard Waller [email protected]
This uses the Chai OpenAPI response validator plugin (that @JonnySpruce and I made) to automatically test that PFE responds as our OpenAPI doc claims it does. This makes it easier to keep the two in sync, helping PFE's developers and users.
Notes:
required
, then this plugin assumes that we are following OpenAPI conventions to specify that the properties are optionaltype
(e.g.string
,integer
) a property should have, then this plugin assumes that we are following OpenAPI conventions to specify a multi-typed property (see Istype
a required field for Schema Objects? OAI/OpenAPI-Specification#1657).chai-http
automatically inserts a body of{}
. So if our doc specifies that the response should contain No Content, this plugin will (accurately) flag the fact that{}
is notnull
.res.should.have.status(X)
will suffice.