2 * Copyright 2013 Laurent Bovet <laurent.bovet@windmaster.ch>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 function createDoc(definitions, type) {
22 var docson = "/docson/index.html";
25 function receiveMessage(event) {
26 if (event.data.id && event.data.id == "docson") {
27 var frame = $("#docson-"+event.data.url.split("$")[2]);
28 if (event.data.action == "resized") {
29 frame.get(0).width = event.data.width + 18;
30 frame.get(0).height = event.data.height + 36;
31 frame.parents("td").width(event.data.width + 24)
33 if (event.data.action == "ready") {
34 frame.get(0).contentWindow.postMessage({ id: "docson", action: "load", definitions: allDefinitions, type: event.data.url.split("$")[1]}, "*");
38 window.addEventListener("message", receiveMessage, false);
40 $.extend(allDefinitions, definitions);
41 return "<iframe class='docson-frame' id='docson-" + counter + "' style='padding: 0; border: 0; width:100%; background: transparent' src='" + docson + "#$" + type + "$"+counter+"'></iframe>"
44 SwaggerOperation.prototype.getSignature = function(type, models) {
45 var collectionType, isPrimitive;
46 if(this.isCollectionType) {
47 collectionType = this.isCollectionType(type);
49 collectionType = this.isListType(type);
51 isPrimitive = ((collectionType != null) && models[collectionType]) || (models[type] != null) ? false : true;
55 if (collectionType != null) {
56 return "<p class='stronger'>" + type + "</p>" + createDoc(this.resource.rawModels, collectionType);
58 return createDoc(this.resource.rawModels, type);
63 $(document).on("click", ".toggleOperation", function() {
64 $(this).parents(".operations").find(".docson-frame").each(function(k, frame) {
65 frame.contentWindow.postMessage({id: "docson", action: "resize"}, "*");