Skip to content

Commit

Permalink
- Fix issue #413
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Aug 24, 2023
1 parent 87c5318 commit 29e4268
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 45 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

# [1.14.2] In progress
### Fixed
- Regression in host (See issue [#413](https://github.com/Axway-API-Management-Plus/apim-cli/issues/413))
- gson library 2.4 has vulnerability CVE-2022-25647 (See issue [#425](https://github.com/Axway-API-Management-Plus/apim-cli/issues/425))

# [1.14.1] 2023-07-31
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ public void configureBasePath(String backendBasePath, API api) throws AppExcepti
((ObjectNode) swagger).put("basePath", "/"); // to adhere the spec - if basePath is empty, serve the traffic on / - Ref -> https://swagger.io/specification/v2/
}
if (CoreParameters.getInstance().isOverrideSpecBasePath()) {
LOG.info("Overriding host scheme and basePath with value : {}", backendBasePath);
String basePath = url.getPath();
if (StringUtils.isNotEmpty(basePath)) {
LOG.debug("Overriding Swagger basePath with value : {}", basePath);
((ObjectNode) swagger).put("basePath", basePath);
}else {
LOG.debug("Not updating basePath as BackendBasepath : {} has empty basePath", backendBasePath);
LOG.debug("Not updating basePath value in swagger 2 as BackendBasePath : {} has empty basePath", backendBasePath);
}
((ObjectNode) swagger).put("host", url.getHost() + port);
ArrayNode newSchemes = this.mapper.createArrayNode();
newSchemes.add(url.getProtocol());
((ObjectNode) swagger).set("schemes", newSchemes);
}
this.apiSpecificationContent = this.mapper.writeValueAsBytes(swagger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void overrideBackendBasePath() throws IOException {
JsonNode swagger = mapper.readTree(apiDefinition.getApiSpecificationContent());
Assert.assertEquals(swagger.get("host").asText(), "petstore.swagger.io");
Assert.assertEquals(swagger.get("basePath").asText(), "/test");
Assert.assertEquals(swagger.get("schemes").get(0).asText(), "https");
Assert.assertEquals(swagger.get("schemes").get(0).asText(), "http");
Assert.assertEquals(swagger.get("schemes").size(), 1);
}

Expand Down Expand Up @@ -290,6 +290,4 @@ public void testSwaggerWithoutHost() throws IOException{
Assert.assertEquals(swagger.get("schemes").get(0).asText(), "https");
Assert.assertEquals(swagger.get("schemes").size(), 1);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,24 @@ protected void writeBytesToFile(byte[] bFile, String fileDest) throws AppExcepti
}
}

protected APIFilter createFilter(){
Builder builder = getBaseAPIFilterBuilder();
switch (params.getWide()) {
case standard:
case wide:
builder.includeQuotas(false);
builder.includeClientApplications(false);
builder.includeClientOrganizations(false);
builder.includeClientAppQuota(false);
builder.includeQuotas(false);
break;
case ultra:
builder.includeQuotas(true);
builder.includeClientAppQuota(false);
builder.includeClientApplications(true);
builder.includeClientOrganizations(true);
break;
}
return builder.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.axway.apim.api.export.impl;

import com.axway.apim.adapter.apis.APIFilter;
import com.axway.apim.adapter.apis.APIFilter.Builder;
import com.axway.apim.adapter.apis.APIManagerPoliciesAdapter.PolicyType;
import com.axway.apim.api.API;
import com.axway.apim.api.export.lib.APIComparator;
Expand Down Expand Up @@ -240,24 +239,6 @@ private String getFormattedDate(API api) {

@Override
public APIFilter getFilter() {
Builder builder = getBaseAPIFilterBuilder();

switch (params.getWide()) {
case standard:
case wide:
builder.includeQuotas(false);
builder.includeClientApplications(false);
builder.includeClientOrganizations(false);
builder.includeClientAppQuota(false);
builder.includeQuotas(false);
break;
case ultra:
builder.includeQuotas(true);
builder.includeClientAppQuota(false);
builder.includeClientApplications(true);
builder.includeClientOrganizations(true);
break;
}
return builder.build();
return createFilter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.axway.apim.adapter.APIManagerAdapter;
import com.axway.apim.adapter.apis.APIFilter;
import com.axway.apim.adapter.apis.APIFilter.Builder;
import com.axway.apim.adapter.apis.APIManagerPoliciesAdapter.PolicyType;
import com.axway.apim.api.API;
import com.axway.apim.api.export.lib.params.APIExportParams;
Expand Down Expand Up @@ -161,7 +160,7 @@ private String getCreatedBy(API api) {


private boolean hasTags(API api) {
return (api.getTags() != null && api.getTags().size() != 0);
return (api.getTags() != null && !api.getTags().isEmpty());
}

private String getOrgCount(API api) {
Expand All @@ -185,23 +184,6 @@ private String getSubscribedApplications(API api) {

@Override
public APIFilter getFilter() {
Builder builder = getBaseAPIFilterBuilder();
switch (params.getWide()) {
case standard:
case wide:
builder.includeQuotas(false);
builder.includeClientApplications(false);
builder.includeClientOrganizations(false);
builder.includeClientAppQuota(false);
builder.includeQuotas(false);
break;
case ultra:
builder.includeQuotas(true);
builder.includeClientAppQuota(false);
builder.includeClientApplications(true);
builder.includeClientOrganizations(true);
break;
}
return builder.build();
return createFilter();
}
}

0 comments on commit 29e4268

Please sign in to comment.