Skip to content

Commit bb32b6f

Browse files
author
Chris Wiechmann
committed
Handle the different file extentions (JSON, YAML, XML) when
exporting an API.
1 parent a15263b commit bb32b6f

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

modules/api-export/src/main/java/com/axway/apim/api/export/impl/JsonAPIExporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ private void saveAPILocally(ExportAPI exportAPI) throws AppException {
9292
APISpecification apiDef = exportAPI.getAPIDefinition();
9393
String targetFile = null;
9494
try {
95-
targetFile = localFolder.getCanonicalPath() + "/" + exportAPI.getName()+".json";
95+
targetFile = localFolder.getCanonicalPath() + "/" + exportAPI.getName()+apiDef.getAPIDefinitionType().getFileExtension();
9696
writeBytesToFile(apiDef.getApiSpecificationContent(), targetFile);
97-
exportAPI.getAPIDefinition().setApiSpecificationFile(exportAPI.getName()+".json");
97+
exportAPI.getAPIDefinition().setApiSpecificationFile(exportAPI.getName()+apiDef.getAPIDefinitionType().getFileExtension());
9898
} catch (IOException e) {
9999
throw new AppException("Can't save API-Definition locally to file: " + targetFile,
100100
ErrorCode.UNXPECTED_ERROR, e);

modules/apim-adapter/src/main/java/com/axway/apim/api/definition/APISpecification.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@
2121
public abstract class APISpecification {
2222

2323
public static enum APISpecType {
24-
SWAGGGER_API_12("Swagger 1.2"),
25-
SWAGGGER_API_12_YAML("Swagger 1.2 (YAML)"),
26-
SWAGGGER_API_20("Swagger 2.0"),
27-
SWAGGGER_API_20_YAML("Swagger 2.0 (YAML)"),
28-
OPEN_API_30("Open API 3.0"),
29-
OPEN_API_30_YAML("Open API 3.0 (YAML)"),
30-
WSDL_API ("WSDL");
24+
SWAGGGER_API_12("Swagger 1.2", ".json"),
25+
SWAGGGER_API_12_YAML("Swagger 1.2 (YAML)", ".yaml"),
26+
SWAGGGER_API_20("Swagger 2.0", ".json"),
27+
SWAGGGER_API_20_YAML("Swagger 2.0 (YAML)", ".yaml"),
28+
OPEN_API_30("Open API 3.0", ".json"),
29+
OPEN_API_30_YAML("Open API 3.0 (YAML)", ".yaml"),
30+
WSDL_API ("WSDL", ".xml");
3131

3232
String niceName;
33+
String fileExtension;
3334

3435
public String getNiceName() {
3536
return niceName;
3637
}
3738

38-
APISpecType(String niceName) {
39+
public String getFileExtension() {
40+
return fileExtension;
41+
}
42+
43+
APISpecType(String niceName, String fileExtension) {
3944
this.niceName = niceName;
45+
this.fileExtension = fileExtension;
4046
}
4147
}
4248

0 commit comments

Comments
 (0)