Skip to content

Commit

Permalink
add general required params to local params
Browse files Browse the repository at this point in the history
  • Loading branch information
shulkaolka committed Apr 1, 2024
1 parent eb9d2f5 commit e123e5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/utils/schemaAndComponentJsonBuilder.js
Expand Up @@ -13,6 +13,10 @@ async function schemaBuilder(api, componentJson, existingNames, outputDir) {
return;
} // skip x-* fields
let pathParams = operations.parameters || {};
let requiredGeneralParams;
if (operations.parameters) {
requiredGeneralParams = operations.parameters.filter((param) => param.required);
}

_.forOwn(operations, async (operation, method) => {
if (method === "parameters") {
Expand Down Expand Up @@ -64,6 +68,18 @@ async function schemaBuilder(api, componentJson, existingNames, outputDir) {
action.$$$params.push(param);
});

if (requiredGeneralParams) {
requiredGeneralParams.forEach((param) => {
schema.properties[param.name] = Object.assign(
{
required: param.required,
},
param.schema
);
action.$$$params.push(param);
});
}

if (operation.requestBody) {
let contentTypes = [];

Expand Down
2 changes: 2 additions & 0 deletions templates/lib/triggers/trigger.js
Expand Up @@ -61,7 +61,9 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
);

const specPath = spec.paths[pathName];
const specPathGeneralParams = specPath.parameters? specPath.parameters.map(({ name }) => name) : [];
const specPathParameters = specPath[method].parameters ? specPath[method].parameters.map(({ name }) => name) : [];
specPathParameters.push(...specPathGeneralParams);

let triggerParams = cfg.triggerParams;
if (!triggerParams) {
Expand Down

0 comments on commit e123e5b

Please sign in to comment.