release
@@ -393,7 +472,7 @@
site
- scm:git:https://github.com/apiportal/abyss-echoserver.git
+ scm:git:https://github.com/apiportal/abyss-spec-transformer.git
diff --git a/src/main/java/io/abyss/spec/transformer/IAbyssTransformer.java b/src/main/java/com/verapi/abyss/spec/transformer/IAbyssTransformer.java
similarity index 82%
rename from src/main/java/io/abyss/spec/transformer/IAbyssTransformer.java
rename to src/main/java/com/verapi/abyss/spec/transformer/IAbyssTransformer.java
index 2497a50..91846ba 100644
--- a/src/main/java/io/abyss/spec/transformer/IAbyssTransformer.java
+++ b/src/main/java/com/verapi/abyss/spec/transformer/IAbyssTransformer.java
@@ -17,9 +17,10 @@
* under the License.
*/
-package io.abyss.spec.transformer;
+package com.verapi.abyss.spec.transformer;
import com.fasterxml.jackson.core.JsonProcessingException;
+
import javax.wsdl.WSDLException;
/**
@@ -27,14 +28,14 @@
* Created on 2019-04-23
*/
-public interface IAbyssTransformer
-{
+public interface IAbyssTransformer {
/**
* Transforms the WSDL which given with the definition
*
* @param path url or directory
* @return yaml file
- * @throws JsonProcessingException
+ * @throws JsonProcessingException encountered problem while processing JSON content
+ * @throws WSDLException encountered problem while processing WSDL content
*/
String transform(String path) throws JsonProcessingException, WSDLException;
}
diff --git a/src/main/java/io/abyss/spec/transformer/OpenAPITransformer.java b/src/main/java/com/verapi/abyss/spec/transformer/OpenAPITransformer.java
similarity index 80%
rename from src/main/java/io/abyss/spec/transformer/OpenAPITransformer.java
rename to src/main/java/com/verapi/abyss/spec/transformer/OpenAPITransformer.java
index 7cd0238..961499c 100644
--- a/src/main/java/io/abyss/spec/transformer/OpenAPITransformer.java
+++ b/src/main/java/com/verapi/abyss/spec/transformer/OpenAPITransformer.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package io.abyss.spec.transformer;
+package com.verapi.abyss.spec.transformer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -48,11 +48,12 @@
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.tags.Tag;
import io.swagger.v3.oas.models.*;
-import lombok.extern.slf4j.Slf4j;
import org.w3c.dom.*;
+
import javax.wsdl.*;
import javax.wsdl.extensions.ExtensibilityElement;
import java.util.*;
+
import io.swagger.v3.oas.models.info.Info;
import org.yaml.snakeyaml.Yaml;
@@ -61,9 +62,7 @@
* Created on 2019-04-23
*/
-@Slf4j
-public class OpenAPITransformer implements IAbyssTransformer
-{
+public class OpenAPITransformer implements IAbyssTransformer {
private static final String SOAP11_SERVICE_DESCRIPTION = "Soap 1.1 Service";
private static final String SOAP12_SERVICE_DESCRIPTION = "Soap 1.2 Service";
@@ -89,7 +88,6 @@ public class OpenAPITransformer implements IAbyssTransformer
/**
* Constructor.
- *
*/
public OpenAPITransformer() {
@@ -112,13 +110,12 @@ public OpenAPITransformer() {
}
/**
- * @see io.abyss.spec.transformer.IAbyssTransformer#transform(String)
- *
- * Transforms the WSDL which defined with the path param
- *
* @param path url or directory
* @return yaml file
- * @throws JsonProcessingException
+ * @throws JsonProcessingException encountered problem while processing JSON content
+ * @see com.verapi.abyss.spec.transformer.IAbyssTransformer#transform(String)
+ *
+ * Transforms the WSDL which defined with the path param
*/
@Override
public String transform(final String path) throws JsonProcessingException, WSDLException {
@@ -139,13 +136,13 @@ public String transform(final String path) throws JsonProcessingException, WSDLE
/**
* Resolves servers from services collection
*
- * @param services services that are resolved from WSDL
+ * @param services services that are resolved from WSDL
* @param portBindingsMap port bindings map include binding definitions, it forwarded to other methods
- * @param openAPI opeanAPI
+ * @param openAPI opeanAPI
* @return OpenAPITransformer
*/
private OpenAPITransformer resolveServers(final Collection services, final Map> portBindingsMap,
- final OpenAPI openAPI){
+ final OpenAPI openAPI) {
final List serverList = new ArrayList<>();
services.forEach(service -> {
setInformation(service.getQName().getLocalPart(), openAPI);
@@ -165,13 +162,13 @@ private OpenAPITransformer resolveServers(final Collection services, fi
/**
* Iterates ports for resolve binding name and accessing extensibility elements
*
- * @param ports ports that are resolved from WSDL
+ * @param ports ports that are resolved from WSDL
* @param portBindingsMap port bindings map include binding definitions, it forwarded to other methods
* @return locations list that identify servers
*/
- private final Set resolvePortsAndBindings(final Collection ports, final Map> portBindingsMap){
+ private final Set resolvePortsAndBindings(final Collection ports, final Map> portBindingsMap) {
final Set locations = new HashSet<>();
- for(Port port :ports){
+ for (Port port : ports) {
final String bindingName = port.getBinding().getQName().getLocalPart();
resolvePortExtensibilityElement(port, bindingName, port.getExtensibilityElements(), portBindingsMap, locations);
}
@@ -182,29 +179,29 @@ private final Set resolvePortsAndBindings(final Collection ports,
/**
* Iterates extensibility elements for resolve information of soap and http operations
*
- * @param port port it is resolved from WSDL
- * @param bindingName binding name
- * @param extElements extensibility elements of the port
+ * @param port port it is resolved from WSDL
+ * @param bindingName binding name
+ * @param extElements extensibility elements of the port
* @param portBindingsMap port bindings map include binding definitions
- * @param locations locations list that identify servers
+ * @param locations locations list that identify servers
*/
private void resolvePortExtensibilityElement(final Port port, final String bindingName, final List extElements,
- final Map> portBindingsMap, final Set locations){
+ final Map> portBindingsMap, final Set locations) {
extElements.forEach(element -> {
final Map portBinginAttributes = new HashMap<>();
- if(element instanceof SOAPAddressImpl){
+ if (element instanceof SOAPAddressImpl) {
portBinginAttributes.put("url", ((SOAPAddressImpl) element).getLocationURI());
portBinginAttributes.put(DESCRIPTION, SOAP11_SERVICE_DESCRIPTION);
addOperationsName(port.getBinding().getBindingOperations(), portBinginAttributes);
portBindingsMap.put(bindingName, portBinginAttributes);
locations.add(((SOAPAddressImpl) element).getLocationURI());
- } else if(element instanceof SOAP12AddressImpl){
+ } else if (element instanceof SOAP12AddressImpl) {
portBinginAttributes.put("url", ((SOAP12AddressImpl) element).getLocationURI());
portBinginAttributes.put(DESCRIPTION, SOAP12_SERVICE_DESCRIPTION);
addOperationsName(port.getBinding().getBindingOperations(), portBinginAttributes);
portBindingsMap.put(bindingName, portBinginAttributes);
locations.add(((SOAP12AddressImpl) element).getLocationURI());
- } else if(element instanceof HTTPAddressImpl){
+ } else if (element instanceof HTTPAddressImpl) {
portBinginAttributes.put("url", ((HTTPAddressImpl) element).getLocationURI());
portBinginAttributes.put(DESCRIPTION, HTTP_SERVICE_DESCRIPTION);
addOperationsName(port.getBinding().getBindingOperations(), portBinginAttributes);
@@ -217,11 +214,11 @@ private void resolvePortExtensibilityElement(final Port port, final String bindi
/**
* Resolves schemas from types which are declared in the WSDL
*
- * @param types types it is resolved from WSDL
+ * @param types types it is resolved from WSDL
* @param openAPI opeanAPI
* @return OpenAPITransformer
*/
- private OpenAPITransformer getSchemas(final Types types, final OpenAPI openAPI){
+ private OpenAPITransformer getSchemas(final Types types, final OpenAPI openAPI) {
final Components components = new Components();
final Map resolvedSchemas = new HashMap<>();
Optional.ofNullable(types).ifPresent(type -> {
@@ -241,9 +238,9 @@ private OpenAPITransformer getSchemas(final Types types, final OpenAPI openAPI){
* Resolves schemas from types which are included in the WSDL
*
* @param schemaReferences schema references includes schemas included in WSDL
- * @param resolvedSchemas it contains resolved schemas
+ * @param resolvedSchemas it contains resolved schemas
*/
- private void resolveIncludedSchemas(List schemaReferences, final Map resolvedSchemas){
+ private void resolveIncludedSchemas(List schemaReferences, final Map resolvedSchemas) {
schemaReferences.forEach(schema -> resolvedSchemas.putAll(saveSchemas(schema.getReferencedSchema().getElement().getChildNodes())));
}
@@ -251,15 +248,15 @@ private void resolveIncludedSchemas(List schemaReferences,
/**
* Resolves schemas from types which are imported in the WSDL
*
- * @param imports imports includes schemas imported in WSDL
+ * @param imports imports includes schemas imported in WSDL
* @param resolvedSchemas it contains resolved schemas
*/
- private void resolveImportedSchemas(final Map imports, final Map resolvedSchemas){
+ private void resolveImportedSchemas(final Map imports, final Map resolvedSchemas) {
imports.forEach((k, v) ->
- v.forEach(vector -> {
- SchemaImportImpl impl = (SchemaImportImpl) vector;
- Optional.ofNullable(impl.getReferencedSchema()).ifPresent(schema -> resolvedSchemas.putAll(saveSchemas(schema.getElement().getChildNodes())));
- }));
+ v.forEach(vector -> {
+ SchemaImportImpl impl = (SchemaImportImpl) vector;
+ Optional.ofNullable(impl.getReferencedSchema()).ifPresent(schema -> resolvedSchemas.putAll(saveSchemas(schema.getElement().getChildNodes())));
+ }));
}
/**
@@ -268,14 +265,14 @@ private void resolveImportedSchemas(final Map imports, final Map
* @param nodeList node list child nodes from dom
* @return resolved schemas
*/
- private Map saveSchemas(final NodeList nodeList){
+ private Map saveSchemas(final NodeList nodeList) {
final Map schemas = new HashMap<>();
- for(int i=0; i schemas.put(name, childComplexTypeSchema));
- } else if(null != parentNode.getAttributes()) {
+ } else if (null != parentNode.getAttributes()) {
final Schema schema = parseAttributes(parentNode);
Optional.ofNullable(schema.getName()).ifPresent(name -> schemas.put(name, schema));
}
@@ -290,10 +287,10 @@ private Map saveSchemas(final NodeList nodeList){
* @param nodeList node list
* @return schema
*/
- private Schema checkComplexTypeInChildNodes(final NodeList nodeList){
- for(int i=0; i 0){
+ if (sibling.getChildNodes().getLength() > 0) {
resolveSiblingChildNodes(schema, sibling.getChildNodes());
}
}
@@ -349,17 +346,17 @@ private void parseComplexType(final Schema schema, final Node complexType){
/**
* Parsing simple type
*
- * @param schema schema
+ * @param schema schema
* @param nodeList node list
*/
- private void parseSimpleTypeObject(final Schema schema, final NodeList nodeList){
- for(int i=0; i 0){
+ if (sequenceNode.getAttributes() != null && sequenceNode.getAttributes().getLength() > 0) {
resolveSequenceNodeMap(schema, sequenceNode.getAttributes());
}
}
@@ -385,13 +382,13 @@ private void resolveSiblingChildNodes(final Schema schema, final NodeList siblin
/**
* Resolves sequence node map
*
- * @param schema schema
+ * @param schema schema
* @param sequenceNodeMap sequence node map
*/
- private void resolveSequenceNodeMap(final Schema schema, final NamedNodeMap sequenceNodeMap){
- for(int i = 0; i messages, final OpenAPI openAPI){
+ private OpenAPITransformer resolveMessages(final Collection messages, final OpenAPI openAPI) {
final Map extensions = new HashMap<>();
final Map schemaMap = openAPI.getComponents().getSchemas();
@@ -481,7 +478,7 @@ private OpenAPITransformer resolveMessages(final Collection messages, f
attributes.put("$ref", "#/components/schemas/" + messageName);
extensions.put(messageName, attributes);
- if(null == schemaMap.get(messageName)){
+ if (null == schemaMap.get(messageName)) {
final Schema schema = new Schema();
schema.setName(messageName);
schema.setTitle(messageName);
@@ -505,16 +502,16 @@ private OpenAPITransformer resolveMessages(final Collection messages, f
/**
* Generates schemas for message extensions
*
- * @param schema schema
- * @param itemName item name
- * @param type type
+ * @param schema schema
+ * @param itemName item name
+ * @param type type
* @param schemaMap schema map
*/
- private void getSchemaForMessages(final Schema schema, final String itemName, final String type, final Map schemaMap){
+ private void getSchemaForMessages(final Schema schema, final String itemName, final String type, final Map schemaMap) {
schema.addRequiredItem(itemName);
Schema propertyItem = new Schema();
- if(null != schemaMap.get(type)){
+ if (null != schemaMap.get(type)) {
propertyItem.set$ref("#/components/schemas/" + type);
} else {
propertyItem = getPropertyItem(dataTypes.get(type));
@@ -525,13 +522,13 @@ private void getSchemaForMessages(final Schema schema, final String itemName, fi
/**
* Resolves tags and paths from bindings for Open API
*
- * @param bindings bindings that are resolved from WSDL
+ * @param bindings bindings that are resolved from WSDL
* @param portBindingsMap port bindings map include binding definitions
- * @param openAPI openAPI
+ * @param openAPI openAPI
*/
- private OpenAPITransformer resolveTagsAndSetPaths(final Collection bindings, final Map> portBindingsMap, final OpenAPI openAPI){
+ private OpenAPITransformer resolveTagsAndSetPaths(final Collection bindings, final Map> portBindingsMap, final OpenAPI openAPI) {
final List tagList = new ArrayList<>();
- final Map> discoveredPathsMap = new HashMap<>();
+ final Map> discoveredPathsMap = new HashMap<>();
bindings.forEach(binding -> {
final String httpMethod = resolveHttpMethod(binding.getExtensibilityElements());
final Map tagAttributes = portBindingsMap.get(binding.getQName().getLocalPart());
@@ -558,10 +555,10 @@ private OpenAPITransformer resolveTagsAndSetPaths(final Collection bind
* @param exElements exElements list of extensibility element
* @return http method
*/
- private String resolveHttpMethod(final List exElements){
+ private String resolveHttpMethod(final List exElements) {
String httpMethod = "post";
- for(ExtensibilityElement element :exElements){
- if(element instanceof HTTPBindingImpl){
+ for (ExtensibilityElement element : exElements) {
+ if (element instanceof HTTPBindingImpl) {
httpMethod = ((HTTPBindingImpl) element).getVerb().toLowerCase();
}
}
@@ -571,25 +568,25 @@ private String resolveHttpMethod(final List exElements){
/**
* Discovers paths from binding operations for Open API
*
- * @param httpMethod http method
+ * @param httpMethod http method
* @param bindingOperations binding operations that are resolved from the WSDL
- * @param portBindingsMap port bindings map include binding definitions
- * @param discoveredPaths discovered paths include paths
+ * @param portBindingsMap port bindings map include binding definitions
+ * @param discoveredPaths discovered paths include paths
*/
private void discoverPaths(final String httpMethod, final List bindingOperations,
- final Map> portBindingsMap, final Map> discoveredPaths){
- for(BindingOperationImpl impl :bindingOperations){
+ final Map> portBindingsMap, final Map> discoveredPaths) {
+ for (BindingOperationImpl impl : bindingOperations) {
final List exList = impl.getExtensibilityElements();
Map pathAttributes;
- for(ExtensibilityElement element :exList){
- if(element instanceof SOAPOperationImpl || element instanceof SOAP12OperationImpl){
+ for (ExtensibilityElement element : exList) {
+ if (element instanceof SOAPOperationImpl || element instanceof SOAP12OperationImpl) {
pathAttributes = setPathAttributes("SoapService", impl.getName(), httpMethod,
impl.getOperation().getInput().getMessage(), impl.getOperation().getOutput().getMessage(),
impl.getOperation().getFaults());
addPathTags(impl.getName(), "soap", pathAttributes, portBindingsMap);
discoveredPaths.put(impl.getName(), pathAttributes);
- } else if(element instanceof HTTPOperationImpl){
+ } else if (element instanceof HTTPOperationImpl) {
pathAttributes = setPathAttributes("HttpService", impl.getName(), httpMethod,
impl.getOperation().getInput().getMessage(), impl.getOperation().getOutput().getMessage(),
impl.getOperation().getFaults());
@@ -603,22 +600,22 @@ private void discoverPaths(final String httpMethod, final List setPathAttributes(final String description, final String operationName, final String httpMethod,
- final Message inputMessage, final Message outputMessage, final Map faultMap){
+ final Message inputMessage, final Message outputMessage, final Map faultMap) {
final Map pathAttributes = new HashMap<>();
pathAttributes.put(DESCRIPTION, description);
pathAttributes.put("operation", operationName);
pathAttributes.put("method", httpMethod);
- Optional.ofNullable(inputMessage).ifPresent(message -> pathAttributes.put(REQUEST_BODY_KEY, message.getQName().getLocalPart()));
+ Optional.ofNullable(inputMessage).ifPresent(message -> pathAttributes.put(REQUEST_BODY_KEY, message.getQName().getLocalPart()));
Optional.ofNullable(outputMessage).ifPresent(message -> pathAttributes.put(RESPONSE_KEY, message.getQName().getLocalPart()));
pathAttributes.put("faults", !faultMap.isEmpty());
@@ -628,27 +625,27 @@ private final Map setPathAttributes(final String description, fi
/**
* Defines tags for paths
*
- * @param operationName operation name
- * @param requestType request type
- * @param pathAttributes path attributes
+ * @param operationName operation name
+ * @param requestType request type
+ * @param pathAttributes path attributes
* @param portBindingsMap port bindings map include binding definitions
*/
private void addPathTags(final String operationName, final String requestType,
- final Map pathAttributes, final Map> portBindingsMap){
+ final Map pathAttributes, final Map> portBindingsMap) {
portBindingsMap.forEach((key, value) -> {
final Map attributes = value;
attributes.forEach((k, v) -> {
- if(k.equals("operations")){
+ if (k.equals("operations")) {
final List names = (List) v;
final List tags = null != pathAttributes.get("tags")
- ?(List) pathAttributes.get("tags"):new ArrayList<>();
+ ? (List) pathAttributes.get("tags") : new ArrayList<>();
final Set locations = null != pathAttributes.get(LOCATIONS_KEY)
- ?(Set) pathAttributes.get(LOCATIONS_KEY):new HashSet<>();
+ ? (Set) pathAttributes.get(LOCATIONS_KEY) : new HashSet<>();
names.forEach(n -> {
final String desc = value.get(DESCRIPTION).toString().toLowerCase();
- if(n.equals(operationName) && desc.contains(requestType)){
- tags.add(key);
- locations.add((String) value.get("url"));
+ if (n.equals(operationName) && desc.contains(requestType)) {
+ tags.add(key);
+ locations.add((String) value.get("url"));
}
pathAttributes.put("tags", tags);
pathAttributes.put(LOCATIONS_KEY, locations);
@@ -664,9 +661,9 @@ private void addPathTags(final String operationName, final String requestType,
* @param nodeList node list
* @return documentation information
*/
- private String getDocumentation(final NodeList nodeList){
+ private String getDocumentation(final NodeList nodeList) {
String data = "";
- for(int i=0; i bindingOperations, final Map portBindingAttributes){
+ private void addOperationsName(final List bindingOperations, final Map portBindingAttributes) {
final List names = new ArrayList<>();
bindingOperations.forEach(operation -> names.add(operation.getName()));
portBindingAttributes.put("operations", names);
@@ -704,9 +701,9 @@ private void addOperationsName(final List bindingOperations, f
* Sets paths on Open API
*
* @param discoveredPathsMap discovered paths map
- * @param openAPI openAPI
+ * @param openAPI openAPI
*/
- private void setPaths(final Map> discoveredPathsMap, final OpenAPI openAPI){
+ private void setPaths(final Map> discoveredPathsMap, final OpenAPI openAPI) {
final Paths paths = new Paths();
discoveredPathsMap.forEach((k, v) -> {
@@ -731,26 +728,26 @@ private void setPaths(final Map> discoveredPathsMap
* @param bodyName body name
* @return RequestBody
*/
- private RequestBody getRequestBodyForPath(final String bodyName){
+ private RequestBody getRequestBodyForPath(final String bodyName) {
final RequestBody requestBody = new RequestBody();
requestBody.set$ref("#/components/requestBodies/" + bodyName);
return requestBody;
}
/**
- * Returns api responses for Open API
+ * Returns api responses for Open API
*
* @param response response
- * @param faults faults
+ * @param faults faults
* @return ApiResponses
*/
- private ApiResponses getApiResponseForPath(final String response, final boolean faults){
+ private ApiResponses getApiResponseForPath(final String response, final boolean faults) {
final ApiResponses apiResponses = new ApiResponses();
final ApiResponse okResponse = new ApiResponse();
okResponse.set$ref("#/components/responses/200_" + response);
apiResponses.addApiResponse(DEFAULT_SUCCESS_RESPONSE_CODE, okResponse);
- if(faults){
+ if (faults) {
final ApiResponse faultResponse = new ApiResponse();
faultResponse.set$ref(DEFAULT_FAULT_RESPONSE_REF);
apiResponses.addApiResponse(DEFAULT_FAULT_RESPONSE_CODE, faultResponse);
@@ -765,9 +762,9 @@ private ApiResponses getApiResponseForPath(final String response, final boolean
* @param httpMethod http method
* @return PathItem
*/
- private PathItem getPathItem(final String httpMethod, final Operation operation){
+ private PathItem getPathItem(final String httpMethod, final Operation operation) {
final PathItem pathItem = new PathItem();
- switch (httpMethod){
+ switch (httpMethod) {
case "get":
pathItem.setGet(operation);
break;
@@ -791,11 +788,11 @@ private PathItem getPathItem(final String httpMethod, final Operation operation)
/**
* Overrides servers on paths if more than one
*
- * @param servers servers
+ * @param servers servers
* @param pathItem path item
*/
- private void overrideServersIfMoreThanOne(final List servers, final Set location, final PathItem pathItem){
- if(servers.size() > 1){
+ private void overrideServersIfMoreThanOne(final List servers, final Set location, final PathItem pathItem) {
+ if (servers.size() > 1) {
final List serverList = new ArrayList<>();
location.forEach(s -> {
final Server server = new Server();
@@ -811,23 +808,23 @@ private void overrideServersIfMoreThanOne(final List servers, final Set<
* Adds request bodies and responses on Open API
*
* @param portTypes port types
- * @param openAPI openAPI
+ * @param openAPI openAPI
* @return OpenAPITransformer
*/
- private OpenAPITransformer addRequestBodiesAndResponses(final Collection portTypes, final OpenAPI openAPI){
+ private OpenAPITransformer addRequestBodiesAndResponses(final Collection portTypes, final OpenAPI openAPI) {
final Optional