Skip to content

Commit

Permalink
#736 add type info on wsdl too
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Dec 18, 2013
1 parent 1cd2356 commit 7f187bd
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 26 deletions.
39 changes: 37 additions & 2 deletions hawtio-web/src/main/webapp/app/api/html/wsdl.html
Expand Up @@ -90,7 +90,25 @@ <h4>Inputs</h4>

<tr ng-repeat="kind in method.inputs">
<td>{{kind.name}}</td>
<td>{{kind.type}}</td>
<td>
<div class="model-signature" ng-show="kind.schema">
<div class="signature-container">
<div class="description" style="display: block;">
<span class="strong" title="java class: {{rep.javaClass}}
element name: {{rep.element}}">{{kind.typeName}} {</span>

<div ng-repeat="(key, value) in kind.schema.properties">
<span class="propName propOpt">{{key}}</span>
(<span class="propType">{{value.type}}</span><span class="propOptKey"
ng-show="value.optional">, optional</span>)
<span class="propDesc" ng-show="value.description">: {{value.description}}</span>
</div>
<span class="strong">}</span>
</div>
</div>
</div>

</td>
<td>{{kind.description}}</td>
</tr>
</tbody>
Expand All @@ -115,7 +133,24 @@ <h4>Return Value</h4>

<tr ng-repeat="kind in method.outputs">
<td>{{kind.name}}</td>
<td>{{kind.type}}</td>
<td>
<div class="model-signature" ng-show="kind.schema">
<div class="signature-container">
<div class="description" style="display: block;">
<span class="strong" title="java class: {{rep.javaClass}}
element name: {{rep.element}}">{{kind.typeName}} {</span>

<div ng-repeat="(key, value) in kind.schema.properties">
<span class="propName propOpt">{{key}}</span>
(<span class="propType">{{value.type}}</span><span class="propOptKey"
ng-show="value.optional">, optional</span>)
<span class="propDesc" ng-show="value.description">: {{value.description}}</span>
</div>
<span class="strong">}</span>
</div>
</div>
</div>
</td>
<td>{{kind.description}}</td>
</tr>
</tbody>
Expand Down
23 changes: 22 additions & 1 deletion hawtio-web/src/main/webapp/app/api/js/apiHelpers.ts
Expand Up @@ -268,6 +268,27 @@ module API {
}
});
return obj;
};
}



/**
* Concatenate all the non-null arrays into a single array
* @param arrays an array of arrays
* @return the single flatten arrays with any null/undefined values ignored
*/
export function concatArrays(arrays: any[]) {
var answer: any = [];
angular.forEach(arrays, (array) => {
if (array) {
if (angular.isArray(array)) {
answer = answer.concat(array);
} else {
answer.push(array);
}
}
});
return answer;
}

}
23 changes: 0 additions & 23 deletions hawtio-web/src/main/webapp/app/api/js/wadl.ts
Expand Up @@ -17,31 +17,11 @@ module API {
var apidocs = $scope.apidocs;
var jsonSchema = $scope.jsonSchema;
if (apidocs && jsonSchema) {
log.info("We have apidocs and jsonSchema!");
enrichResources(jsonSchema, apidocs.resources)
}
}


/**
* Concatenate all the non-null arrays into a single array
* @param arrays an array of arrays
* @return the single flatten arrays with any null/undefined values ignored
*/
function concatArrays(arrays: any[]) {
var answer: any = [];
angular.forEach(arrays, (array) => {
if (array) {
if (angular.isArray(array)) {
answer = answer.concat(array);
} else {
answer.push(array);
}
}
});
return answer;
}

function enrichResources(jsonSchema, resources) {
angular.forEach(resources, (resource) => {
var childResources = resource.resource;
Expand Down Expand Up @@ -80,9 +60,6 @@ module API {
representation["javaClass"] = key;
}
});
if (foundDef) {
log.info("Found def " + angular.toJson(foundDef) + " for element " + representation["element"]);
}
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions hawtio-web/src/main/webapp/app/api/js/wsdl.ts
Expand Up @@ -13,6 +13,47 @@ module API {
$scope.url = $location.search()["wsdl"];
loadXml($scope.url, onWsdl);

$scope.$watch("services", enrichApiDocsWithSchema);
$scope.$watch("jsonSchema", enrichApiDocsWithSchema);

function enrichApiDocsWithSchema() {
var services = $scope.services;
var jsonSchema = $scope.jsonSchema;
if (services && jsonSchema) {
log.info("We have services and jsonSchema!");
enrichServices(jsonSchema, services)
}
}


function enrichServices(jsonSchema, services) {
angular.forEach(services, (service) => {
angular.forEach(service.operations, (method) => {
angular.forEach(concatArrays([method.inputs, method.outputs]), (object) => {
enrichRepresentation(jsonSchema, object);
});
});
});
}

function enrichRepresentation(jsonSchema, representation) {
var defs = jsonSchema ? jsonSchema["definitions"] : null;
if (defs && representation) {
var name = representation["name"];
if (name) {
var foundDef = defs[name];
if (foundDef) {
// unwrap arrays
if (angular.isArray(foundDef) && foundDef.length > 0) {
foundDef = foundDef[0];
}
log.info("Found def " + angular.toJson(foundDef) + " for name " + name);
representation["schema"] = foundDef;
}
}
}
}

function onWsdl(response) {
$scope.services = [];
var root = response.documentElement;
Expand Down

0 comments on commit 7f187bd

Please sign in to comment.