Skip to content

Commit

Permalink
Added logic to provide business information in apiDef (#105)
Browse files Browse the repository at this point in the history
* Added logic to provide business information in apiDef
* added unit test and logic for 2.6.0
* updated unit test
* updated unit test
* added documentation
* updated README.md to reflect the feature

---------

Co-authored-by: Tom Maarschalkerweerd <tom.maarschalkerweerd@nn.nl>
Co-authored-by: ram <ram.grandhi@nn-group.com>
  • Loading branch information
3 people committed Nov 14, 2023
1 parent a6057fb commit f37c25b
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 224 deletions.
82 changes: 44 additions & 38 deletions README.md

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions src/2.6.0/wso2apim.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ function constructAPIDef(user, gatewayEnv, apiDef, apiId) {
additionalProperties: ((apiDef.apiProperties) && (Object.keys(apiDef.apiProperties).length > 0)) ? apiDef.apiProperties : undefined,
subscriptionAvailability: 'current_tenant',
subscriptionAvailableTenants: [],
businessInformation: {
businessInformation: apiDef.businessInformation ? {
businessOwnerEmail: apiDef.businessInformation.businessOwnerEmail,
technicalOwnerEmail: apiDef.businessInformation.technicalOwnerEmail,
technicalOwner: apiDef.businessInformation.technicalOwner,
businessOwner: apiDef.businessInformation.businessOwner
} : {
businessOwnerEmail: ((apiDef.swaggerSpec.info) && (apiDef.swaggerSpec.info.contact) && (apiDef.swaggerSpec.info.contact.email)) ? apiDef.swaggerSpec.info.contact.email : undefined,
technicalOwnerEmail: ((apiDef.swaggerSpec.info) && (apiDef.swaggerSpec.info.contact) && (apiDef.swaggerSpec.info.contact.email)) ? apiDef.swaggerSpec.info.contact.email : undefined,
technicalOwner: ((apiDef.swaggerSpec.info) && (apiDef.swaggerSpec.info.contact) && (apiDef.swaggerSpec.info.contact.name)) ? apiDef.swaggerSpec.info.contact.name : undefined,
Expand All @@ -251,7 +256,7 @@ function constructAPIDef(user, gatewayEnv, apiDef, apiId) {

backendBaseUrl = '';
backendType = '';

return wso2ApiDefinition;
}
catch (err) {
Expand Down Expand Up @@ -581,11 +586,11 @@ async function listCertInfo(wso2APIM, accessToken, certAlias) {
/**
* Upsert the swagger spec of the wso2 api
* see https://docs.wso2.com/display/AM260/apidocs/publisher/#!/operations#APIIndividual#apisApiIdSwaggerPut
* @param {*} wso2APIM
* @param {*} accessToken
* @param {*} apiId
* @param {*} swaggerSpec
* @returns
* @param {*} wso2APIM
* @param {*} accessToken
* @param {*} apiId
* @param {*} swaggerSpec
* @returns
*/
async function upsertSwaggerSpec(wso2APIM, accessToken, apiId, swaggerSpec) {
try {
Expand All @@ -599,7 +604,7 @@ async function upsertSwaggerSpec(wso2APIM, accessToken, apiId, swaggerSpec) {
rejectUnauthorized: false
})
};

const data = new FormData();
data.append('apiDefinition', JSON.stringify(swaggerSpec));

Expand Down
Loading

0 comments on commit f37c25b

Please sign in to comment.