Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/utils/schemaAndComponentJsonBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ async function schemaBuilder(api, componentJson, existingNames, outputDir) {
}
}

// For response content type we only care about successes, and prefer json
if (operation.responses && operation.responses['200']?.content) {
const responseContentTypes = Object.keys(operation.responses['200'].content);
action.callParams['responseContentType'] = responseContentTypes.some((c) => c === "application/json")
? "application/json"
: `${responseContentTypes[0]}`;
} else if (operation.responses && operation.responses['201']?.content) {
const responseContentTypes = Object.keys(operation.responses['201'].content);
action.callParams['responseContentType'] = responseContentTypes.some((c) => c === "application/json")
? "application/json"
: `${responseContentTypes[0]}`;
}

let schemaOut = {};

schema = getSchemaIn(schema);
Expand Down
8 changes: 5 additions & 3 deletions templates/lib/actions/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa
logger.info("Starting to execute action '%s'", actionFunction);

const action = componentJson.actions[actionFunction];
const { operationId, pathName, method, requestContentType } = action.callParams;
const { operationId, pathName, method, requestContentType, responseContentType } = action.callParams;
logger.info(
"Found spec callParams: 'pathName': %s, 'method': %s, 'requestContentType': %s",
"Found spec callParams: 'pathName': %s, 'method': %s, 'requestContentType': %s, 'responseContentType': %t",
pathName,
method,
requestContentType
requestContentType,
responseContentType
);

const specPath = spec.paths[pathName];
Expand Down Expand Up @@ -100,6 +101,7 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa
method: method,
parameters: parameters,
requestContentType: requestContentType,
responseContentType: responseContentType,
requestBody: body,
securities: { authorized: securities },
server: spec.servers[cfg.server] || cfg.otherServer,
Expand Down
8 changes: 5 additions & 3 deletions templates/lib/triggers/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
);

const trigger = componentJson.triggers[triggerFunction];
const { operationId, pathName, method, requestContentType } = trigger.callParams;
const { operationId, pathName, method, requestContentType, responseContentType } = trigger.callParams;
logger.info(
"Found spec callParams: \"pathName\": %s, \"method\": %s, \"requestContentType\": %s",
"Found spec callParams: \"pathName\": %s, \"method\": %s, \"requestContentType\": %s, \"responseContentType\": %t",
pathName,
method,
requestContentType
requestContentType,
responseContentType,
);

const specPath = spec.paths[pathName];
Expand Down Expand Up @@ -150,6 +151,7 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
method: method,
parameters: parameters,
requestContentType: requestContentType,
responseContentType: responseContentType,
securities: { authorized: securities },
server: spec.servers[cfg.server] || cfg.otherServer
};
Expand Down