Skip to content

Commit

Permalink
Extract headers for Exceptions (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
joheredi authored Aug 11, 2020
1 parent 17b4080 commit a5e65b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/generators/operationGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ function hasMediaType(
operationDetails: OperationDetails,
mediaType: KnownMediaType
) {
if (!operationDetails.requests) {
if (!operationDetails.requests.some(r => !!r.mediaType)) {
return operationDetails.mediaTypes.has(mediaType);
}

Expand Down
12 changes: 8 additions & 4 deletions src/utils/extractHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ export function extractHeaders(
let responseHeaders: ObjectSchema[] = [];

operationGroups.forEach(operationGroup =>
operationGroup.operations.forEach(operation =>
operation.responses?.forEach(response => {
operationGroup.operations.forEach(operation => {
const responsesAndExceptions = [
...(operation.responses || []),
...(operation.exceptions || [])
];
responsesAndExceptions.forEach(response => {
const operationName = getOperationFullName(
operationGroup,
operation,
Expand All @@ -21,8 +25,8 @@ export function extractHeaders(
const headerSchema = headersToSchema(headers, operationName);
headerSchema && responseHeaders.push(headerSchema);
}
})
)
});
})
);

return responseHeaders;
Expand Down

0 comments on commit a5e65b8

Please sign in to comment.