Skip to content

Commit

Permalink
Temporary fix for multiple content-types (apideck-libraries#87)
Browse files Browse the repository at this point in the history
* Temporary fix for handling multiple content-types, where the contract will be based on t he 1st content-type that is defined in the OpenAPI response.
There are a number of ways to solve this, so we are looking into an option that is easy to configure with the test injection.

* release 1.3.3
  • Loading branch information
thim81 authored Jul 14, 2021
1 parent 4830e09 commit 6a0ca76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANEGLOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.3.3 - (2021-07-14)

### Temporary fix

- Temporary fix for handling multiple content-types, where the contract will be based on the 1st content-type that is defined in the OpenAPI response.

## v1.3.2 - (2021-07-09)

### Globals
Expand Down
8 changes: 8 additions & 0 deletions src/application/TestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,17 @@ export class TestSuite {

// Add response content checks
if (responseObject.content) {
// TEMPORARY HANDLING of multiple content-types
let contentTypesCounter = 0

// Process all content-types
for (const [contentType, content] of Object.entries(responseObject.content)) {
// Early skip if no content-types defined
if (!contentType) continue

// TEMPORARY HANDLING of multiple content-types
if (contentTypesCounter > 0) continue

// Add contentType check
if (optContentType && !inOperations(pmOperation, optContentType?.excludeForOperations)) {
pmOperation = testResponseContentType(contentType, pmOperation, oaOperation)
Expand All @@ -254,6 +260,8 @@ export class TestSuite {
) {
pmOperation = testResponseJsonSchema(content?.schema, pmOperation, oaOperation)
}

contentTypesCounter++
}
}

Expand Down

0 comments on commit 6a0ca76

Please sign in to comment.