swagger-ui-svelte
Version:
Light version of swagger UI using Svelte framework
1,651 lines (1,529 loc) • 81.5 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SwaggerUISvelte = {}));
}(this, (function (exports) { 'use strict';
function noop() { }
function run(fn) {
return fn();
}
function blank_object() {
return Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === 'function';
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function append(target, node) {
target.appendChild(node);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(' ');
}
function empty() {
return text('');
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function children(element) {
return Array.from(element.childNodes);
}
function set_data(text, data) {
data = '' + data;
if (text.wholeText !== data)
text.data = data;
}
function set_input_value(input, value) {
input.value = value == null ? '' : value;
}
function set_style(node, key, value, important) {
node.style.setProperty(key, value, important ? 'important' : '');
}
function toggle_class(element, name, toggle) {
element.classList[toggle ? 'add' : 'remove'](name);
}
let current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error(`Function called outside component initialization`);
return current_component;
}
function onMount(fn) {
get_current_component().$$.on_mount.push(fn);
}
const dirty_components = [];
const binding_callbacks = [];
const render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
let flushing = false;
const seen_callbacks = new Set();
function flush() {
if (flushing)
return;
flushing = true;
do {
// first, call beforeUpdate functions
// and update components
for (let i = 0; i < dirty_components.length; i += 1) {
const component = dirty_components[i];
set_current_component(component);
update(component.$$);
}
set_current_component(null);
dirty_components.length = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
// then, once components are updated, call
// afterUpdate functions. This may cause
// subsequent updates...
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
// ...so guard against infinite loops
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
flushing = false;
seen_callbacks.clear();
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
const outroing = new Set();
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function mount_component(component, target, anchor) {
const { fragment, on_mount, on_destroy, after_update } = component.$$;
fragment && fragment.m(target, anchor);
// onMount happens before the initial afterUpdate
add_render_callback(() => {
const new_on_destroy = on_mount.map(run).filter(is_function);
if (on_destroy) {
on_destroy.push(...new_on_destroy);
}
else {
// Edge case - component was destroyed immediately,
// most likely as a result of a binding initialising
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
// TODO null out other refs, including component.$$ (but need to
// preserve final state?)
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
}
function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const prop_values = options.props || {};
const $$ = component.$$ = {
fragment: null,
ctx: null,
// state
props,
update: noop,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
before_update: [],
after_update: [],
context: new Map(parent_component ? parent_component.$$.context : []),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false
};
let ready = false;
$$.ctx = instance
? instance(component, prop_values, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
})
: [];
$$.update();
ready = true;
run_all($$.before_update);
// `false` as a special case of no DOM component
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
const nodes = children(options.target);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
}
else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor);
flush();
}
set_current_component(parent_component);
}
class SvelteComponent {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
}
/**
* Tokenize input string.
*/
function lexer(str) {
var tokens = [];
var i = 0;
while (i < str.length) {
var char = str[i];
if (char === "*" || char === "+" || char === "?") {
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
continue;
}
if (char === "\\") {
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
continue;
}
if (char === "{") {
tokens.push({ type: "OPEN", index: i, value: str[i++] });
continue;
}
if (char === "}") {
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
continue;
}
if (char === ":") {
var name = "";
var j = i + 1;
while (j < str.length) {
var code = str.charCodeAt(j);
if (
// `0-9`
(code >= 48 && code <= 57) ||
// `A-Z`
(code >= 65 && code <= 90) ||
// `a-z`
(code >= 97 && code <= 122) ||
// `_`
code === 95) {
name += str[j++];
continue;
}
break;
}
if (!name)
throw new TypeError("Missing parameter name at " + i);
tokens.push({ type: "NAME", index: i, value: name });
i = j;
continue;
}
if (char === "(") {
var count = 1;
var pattern = "";
var j = i + 1;
if (str[j] === "?") {
throw new TypeError("Pattern cannot start with \"?\" at " + j);
}
while (j < str.length) {
if (str[j] === "\\") {
pattern += str[j++] + str[j++];
continue;
}
if (str[j] === ")") {
count--;
if (count === 0) {
j++;
break;
}
}
else if (str[j] === "(") {
count++;
if (str[j + 1] !== "?") {
throw new TypeError("Capturing groups are not allowed at " + j);
}
}
pattern += str[j++];
}
if (count)
throw new TypeError("Unbalanced pattern at " + i);
if (!pattern)
throw new TypeError("Missing pattern at " + i);
tokens.push({ type: "PATTERN", index: i, value: pattern });
i = j;
continue;
}
tokens.push({ type: "CHAR", index: i, value: str[i++] });
}
tokens.push({ type: "END", index: i, value: "" });
return tokens;
}
/**
* Parse a string for the raw tokens.
*/
function parse(str, options) {
if (options === void 0) { options = {}; }
var tokens = lexer(str);
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
var result = [];
var key = 0;
var i = 0;
var path = "";
var tryConsume = function (type) {
if (i < tokens.length && tokens[i].type === type)
return tokens[i++].value;
};
var mustConsume = function (type) {
var value = tryConsume(type);
if (value !== undefined)
return value;
var _a = tokens[i], nextType = _a.type, index = _a.index;
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
};
var consumeText = function () {
var result = "";
var value;
// tslint:disable-next-line
while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
result += value;
}
return result;
};
while (i < tokens.length) {
var char = tryConsume("CHAR");
var name = tryConsume("NAME");
var pattern = tryConsume("PATTERN");
if (name || pattern) {
var prefix = char || "";
if (prefixes.indexOf(prefix) === -1) {
path += prefix;
prefix = "";
}
if (path) {
result.push(path);
path = "";
}
result.push({
name: name || key++,
prefix: prefix,
suffix: "",
pattern: pattern || defaultPattern,
modifier: tryConsume("MODIFIER") || ""
});
continue;
}
var value = char || tryConsume("ESCAPED_CHAR");
if (value) {
path += value;
continue;
}
if (path) {
result.push(path);
path = "";
}
var open = tryConsume("OPEN");
if (open) {
var prefix = consumeText();
var name_1 = tryConsume("NAME") || "";
var pattern_1 = tryConsume("PATTERN") || "";
var suffix = consumeText();
mustConsume("CLOSE");
result.push({
name: name_1 || (pattern_1 ? key++ : ""),
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
prefix: prefix,
suffix: suffix,
modifier: tryConsume("MODIFIER") || ""
});
continue;
}
mustConsume("END");
}
return result;
}
/**
* Compile a string to a template function for the path.
*/
function compile(str, options) {
return tokensToFunction(parse(str, options), options);
}
/**
* Expose a method for transforming tokens into the path function.
*/
function tokensToFunction(tokens, options) {
if (options === void 0) { options = {}; }
var reFlags = flags(options);
var _a = options.encode, encode = _a === void 0 ? function (x) { return x; } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
// Compile all the tokens into regexps.
var matches = tokens.map(function (token) {
if (typeof token === "object") {
return new RegExp("^(?:" + token.pattern + ")$", reFlags);
}
});
return function (data) {
var path = "";
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (typeof token === "string") {
path += token;
continue;
}
var value = data ? data[token.name] : undefined;
var optional = token.modifier === "?" || token.modifier === "*";
var repeat = token.modifier === "*" || token.modifier === "+";
if (Array.isArray(value)) {
if (!repeat) {
throw new TypeError("Expected \"" + token.name + "\" to not repeat, but got an array");
}
if (value.length === 0) {
if (optional)
continue;
throw new TypeError("Expected \"" + token.name + "\" to not be empty");
}
for (var j = 0; j < value.length; j++) {
var segment = encode(value[j], token);
if (validate && !matches[i].test(segment)) {
throw new TypeError("Expected all \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
}
path += token.prefix + segment + token.suffix;
}
continue;
}
if (typeof value === "string" || typeof value === "number") {
var segment = encode(String(value), token);
if (validate && !matches[i].test(segment)) {
throw new TypeError("Expected \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
}
path += token.prefix + segment + token.suffix;
continue;
}
if (optional)
continue;
var typeOfMessage = repeat ? "an array" : "a string";
throw new TypeError("Expected \"" + token.name + "\" to be " + typeOfMessage);
}
return path;
};
}
/**
* Escape a regular expression string.
*/
function escapeString(str) {
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
}
/**
* Get the flags for a regexp from the options.
*/
function flags(options) {
return options && options.sensitive ? "" : "i";
}
/* src/SwaggerUISvelte.svelte generated by Svelte v3.25.1 */
function get_each_context_3(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[26] = list[i];
return child_ctx;
}
function get_each_context_2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[23] = list[i];
return child_ctx;
}
function get_each_context_5(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[32] = list[i];
child_ctx[33] = list;
child_ctx[34] = i;
return child_ctx;
}
function get_each_context_8(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[29] = list[i];
return child_ctx;
}
function get_each_context_7(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[29] = list[i];
return child_ctx;
}
function get_each_context_6(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[35] = list[i];
return child_ctx;
}
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[20] = list[i];
child_ctx[21] = list;
child_ctx[22] = i;
return child_ctx;
}
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[17] = list[i];
child_ctx[19] = i;
return child_ctx;
}
// (108:2) {:else}
function create_else_block_5(ctx) {
return {
c() {
document.title = "Swagger UI using Svelte";
},
m: noop,
d: noop
};
}
// (106:2) {#if swagger}
function create_if_block_16(ctx) {
let title_value;
document.title = title_value = /*swagger*/ ctx[0].info.title;
return { c: noop, m: noop, d: noop };
}
// (116:6) {#if swagger}
function create_if_block(ctx) {
let h1;
let t0_value = /*swagger*/ ctx[0].info.title + "";
let t0;
let t1;
let h2;
let t2_value = /*swagger*/ ctx[0].info.description + "";
let t2;
let t3;
let t4_value = /*swagger*/ ctx[0].info.version + "";
let t4;
let t5;
let div2;
let t6;
let div0;
let t7;
let div1;
let label;
let t9;
let input;
let t10;
let each_1_anchor;
let mounted;
let dispose;
let if_block = /*swagger*/ ctx[0].info.contact && create_if_block_15(ctx);
let each_value = Object.entries(/*paths*/ ctx[6]);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
return {
c() {
h1 = element("h1");
t0 = text(t0_value);
t1 = space();
h2 = element("h2");
t2 = text(t2_value);
t3 = text(" - ");
t4 = text(t4_value);
t5 = space();
div2 = element("div");
if (if_block) if_block.c();
t6 = space();
div0 = element("div");
t7 = space();
div1 = element("div");
label = element("label");
label.textContent = "Server:";
t9 = space();
input = element("input");
t10 = space();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
attr(h1, "class", "title");
attr(h2, "class", "subtitle");
attr(div0, "class", "rf-col-offset-4");
attr(label, "class", "rf-label");
attr(label, "for", "text-input-text");
attr(input, "class", "rf-input");
attr(input, "type", "text");
attr(input, "placeholder", "Server URL");
attr(input, "id", "text-input-text");
attr(input, "name", "text-input-text");
attr(div1, "class", "rf-col-xs-12 rf-col-lg-4");
attr(div2, "class", "rf-grid-row");
},
m(target, anchor) {
insert(target, h1, anchor);
append(h1, t0);
insert(target, t1, anchor);
insert(target, h2, anchor);
append(h2, t2);
append(h2, t3);
append(h2, t4);
insert(target, t5, anchor);
insert(target, div2, anchor);
if (if_block) if_block.m(div2, null);
append(div2, t6);
append(div2, div0);
append(div2, t7);
append(div2, div1);
append(div1, label);
append(div1, t9);
append(div1, input);
set_input_value(input, /*baseurl*/ ctx[1]);
insert(target, t10, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
if (!mounted) {
dispose = listen(input, "input", /*input_input_handler*/ ctx[10]);
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*swagger*/ 1 && t0_value !== (t0_value = /*swagger*/ ctx[0].info.title + "")) set_data(t0, t0_value);
if (dirty[0] & /*swagger*/ 1 && t2_value !== (t2_value = /*swagger*/ ctx[0].info.description + "")) set_data(t2, t2_value);
if (dirty[0] & /*swagger*/ 1 && t4_value !== (t4_value = /*swagger*/ ctx[0].info.version + "")) set_data(t4, t4_value);
if (/*swagger*/ ctx[0].info.contact) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_15(ctx);
if_block.c();
if_block.m(div2, t6);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty[0] & /*baseurl*/ 2 && input.value !== /*baseurl*/ ctx[1]) {
set_input_value(input, /*baseurl*/ ctx[1]);
}
if (dirty[0] & /*paths, active, getSchema, responses, handleRequest, requestParams, requestBodyExample*/ 508) {
each_value = Object.entries(/*paths*/ ctx[6]);
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
},
d(detaching) {
if (detaching) detach(h1);
if (detaching) detach(t1);
if (detaching) detach(h2);
if (detaching) detach(t5);
if (detaching) detach(div2);
if (if_block) if_block.d();
if (detaching) detach(t10);
destroy_each(each_blocks, detaching);
if (detaching) detach(each_1_anchor);
mounted = false;
dispose();
}
};
}
// (120:6) {#if swagger.info.contact}
function create_if_block_15(ctx) {
let div;
let a;
let t0_value = /*swagger*/ ctx[0].info.contact.name + "";
let t0;
let a_href_value;
let t1;
let t2_value = /*swagger*/ ctx[0].info.contact.email + "";
let t2;
return {
c() {
div = element("div");
a = element("a");
t0 = text(t0_value);
t1 = text(" - \n ");
t2 = text(t2_value);
attr(a, "href", a_href_value = /*swagger*/ ctx[0].info.contact.url);
attr(a, "target", "_blank");
attr(div, "class", "rf-col-xs-12 rf-col-lg-4");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, a);
append(a, t0);
append(div, t1);
append(div, t2);
},
p(ctx, dirty) {
if (dirty[0] & /*swagger*/ 1 && t0_value !== (t0_value = /*swagger*/ ctx[0].info.contact.name + "")) set_data(t0, t0_value);
if (dirty[0] & /*swagger*/ 1 && a_href_value !== (a_href_value = /*swagger*/ ctx[0].info.contact.url)) {
attr(a, "href", a_href_value);
}
if (dirty[0] & /*swagger*/ 1 && t2_value !== (t2_value = /*swagger*/ ctx[0].info.contact.email + "")) set_data(t2, t2_value);
},
d(detaching) {
if (detaching) detach(div);
}
};
}
// (145:18) {#if method.summary}
function create_if_block_14(ctx) {
let div;
let t_value = /*method*/ ctx[20].summary + "";
let t;
return {
c() {
div = element("div");
t = text(t_value);
attr(div, "class", "rf-btn rf-btn--secondary");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, t);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t_value !== (t_value = /*method*/ ctx[20].summary + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(div);
}
};
}
// (152:18) {#if method.requestBody && method.requestBody.content}
function create_if_block_9(ctx) {
let each_1_anchor;
let each_value_6 = Object.entries(/*method*/ ctx[20].requestBody.content);
let each_blocks = [];
for (let i = 0; i < each_value_6.length; i += 1) {
each_blocks[i] = create_each_block_6(get_each_context_6(ctx, each_value_6, i));
}
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths, requestBodyExample, getSchema*/ 224) {
each_value_6 = Object.entries(/*method*/ ctx[20].requestBody.content);
let i;
for (i = 0; i < each_value_6.length; i += 1) {
const child_ctx = get_each_context_6(ctx, each_value_6, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_6(child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value_6.length;
}
},
d(detaching) {
destroy_each(each_blocks, detaching);
if (detaching) detach(each_1_anchor);
}
};
}
// (184:26) {:else}
function create_else_block_3(ctx) {
let each_1_anchor;
let each_value_8 = Object.entries(/*requestBody*/ ctx[35][1]["schema"]["properties"]);
let each_blocks = [];
for (let i = 0; i < each_value_8.length; i += 1) {
each_blocks[i] = create_each_block_8(get_each_context_8(ctx, each_value_8, i));
}
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64) {
each_value_8 = Object.entries(/*requestBody*/ ctx[35][1]["schema"]["properties"]);
let i;
for (i = 0; i < each_value_8.length; i += 1) {
const child_ctx = get_each_context_8(ctx, each_value_8, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_8(child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value_8.length;
}
},
d(detaching) {
destroy_each(each_blocks, detaching);
if (detaching) detach(each_1_anchor);
}
};
}
// (166:28) {#if '$ref' in requestBody[1]["schema"]}
function create_if_block_11(ctx) {
let each_1_anchor;
let each_value_7 = Object.entries(/*getSchema*/ ctx[7](/*requestBody*/ ctx[35][1]["schema"]["$ref"]).properties);
let each_blocks = [];
for (let i = 0; i < each_value_7.length; i += 1) {
each_blocks[i] = create_each_block_7(get_each_context_7(ctx, each_value_7, i));
}
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*getSchema, paths*/ 192) {
each_value_7 = Object.entries(/*getSchema*/ ctx[7](/*requestBody*/ ctx[35][1]["schema"]["$ref"]).properties);
let i;
for (i = 0; i < each_value_7.length; i += 1) {
const child_ctx = get_each_context_7(ctx, each_value_7, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_7(child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value_7.length;
}
},
d(detaching) {
destroy_each(each_blocks, detaching);
if (detaching) detach(each_1_anchor);
}
};
}
// (196:32) {:else}
function create_else_block_4(ctx) {
let t;
return {
c() {
t = text("String");
},
m(target, anchor) {
insert(target, t, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(t);
}
};
}
// (194:32) {#if property[1].type}
function create_if_block_13(ctx) {
let t_value = /*property*/ ctx[29][1].type + "";
let t;
return {
c() {
t = text(t_value);
},
m(target, anchor) {
insert(target, t, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t_value !== (t_value = /*property*/ ctx[29][1].type + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(t);
}
};
}
// (185:26) {#each Object.entries(requestBody[1]["schema"]["properties"]) as property}
function create_each_block_8(ctx) {
let tr;
let td0;
let span;
let t0_value = /*property*/ ctx[29][0] + "";
let t0;
let t1;
let td1;
let raw_value = /*property*/ ctx[29][1].description + "";
let t2;
let td2;
let t3;
function select_block_type_3(ctx, dirty) {
if (/*property*/ ctx[29][1].type) return create_if_block_13;
return create_else_block_4;
}
let current_block_type = select_block_type_3(ctx);
let if_block = current_block_type(ctx);
return {
c() {
tr = element("tr");
td0 = element("td");
span = element("span");
t0 = text(t0_value);
t1 = space();
td1 = element("td");
t2 = space();
td2 = element("td");
if_block.c();
t3 = space();
},
m(target, anchor) {
insert(target, tr, anchor);
append(tr, td0);
append(td0, span);
append(span, t0);
append(tr, t1);
append(tr, td1);
td1.innerHTML = raw_value;
append(tr, t2);
append(tr, td2);
if_block.m(td2, null);
append(tr, t3);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t0_value !== (t0_value = /*property*/ ctx[29][0] + "")) set_data(t0, t0_value);
if (dirty[0] & /*paths*/ 64 && raw_value !== (raw_value = /*property*/ ctx[29][1].description + "")) td1.innerHTML = raw_value;
if (current_block_type === (current_block_type = select_block_type_3(ctx)) && if_block) {
if_block.p(ctx, dirty);
} else {
if_block.d(1);
if_block = current_block_type(ctx);
if (if_block) {
if_block.c();
if_block.m(td2, null);
}
}
},
d(detaching) {
if (detaching) detach(tr);
if_block.d();
}
};
}
// (178:32) {:else}
function create_else_block_2(ctx) {
let t;
return {
c() {
t = text("String");
},
m(target, anchor) {
insert(target, t, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(t);
}
};
}
// (176:32) {#if property[1].type}
function create_if_block_12(ctx) {
let t_value = /*property*/ ctx[29][1].type + "";
let t;
return {
c() {
t = text(t_value);
},
m(target, anchor) {
insert(target, t, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t_value !== (t_value = /*property*/ ctx[29][1].type + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(t);
}
};
}
// (167:28) {#each Object.entries(getSchema(requestBody[1]["schema"]["$ref"]).properties) as property}
function create_each_block_7(ctx) {
let tr;
let td0;
let span;
let t0_value = /*property*/ ctx[29][0] + "";
let t0;
let t1;
let td1;
let raw_value = /*property*/ ctx[29][1].description + "";
let t2;
let td2;
let t3;
function select_block_type_2(ctx, dirty) {
if (/*property*/ ctx[29][1].type) return create_if_block_12;
return create_else_block_2;
}
let current_block_type = select_block_type_2(ctx);
let if_block = current_block_type(ctx);
return {
c() {
tr = element("tr");
td0 = element("td");
span = element("span");
t0 = text(t0_value);
t1 = space();
td1 = element("td");
t2 = space();
td2 = element("td");
if_block.c();
t3 = space();
},
m(target, anchor) {
insert(target, tr, anchor);
append(tr, td0);
append(td0, span);
append(span, t0);
append(tr, t1);
append(tr, td1);
td1.innerHTML = raw_value;
append(tr, t2);
append(tr, td2);
if_block.m(td2, null);
append(tr, t3);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t0_value !== (t0_value = /*property*/ ctx[29][0] + "")) set_data(t0, t0_value);
if (dirty[0] & /*paths*/ 64 && raw_value !== (raw_value = /*property*/ ctx[29][1].description + "")) td1.innerHTML = raw_value;
if (current_block_type === (current_block_type = select_block_type_2(ctx)) && if_block) {
if_block.p(ctx, dirty);
} else {
if_block.d(1);
if_block = current_block_type(ctx);
if (if_block) {
if_block.c();
if_block.m(td2, null);
}
}
},
d(detaching) {
if (detaching) detach(tr);
if_block.d();
}
};
}
// (206:22) {#if '$ref' in requestBody[1]["schema"]}
function create_if_block_10(ctx) {
let div;
let label;
let t0;
let label_for_value;
let t1;
let textarea;
let textarea_id_value;
let mounted;
let dispose;
function textarea_input_handler() {
/*textarea_input_handler*/ ctx[12].call(textarea, /*method*/ ctx[20]);
}
return {
c() {
div = element("div");
label = element("label");
t0 = text("Example");
t1 = space();
textarea = element("textarea");
attr(label, "class", "rf-label");
attr(label, "for", label_for_value = "textarea-" + /*method*/ ctx[20]["id"]);
attr(textarea, "class", "rf-input");
attr(textarea, "id", textarea_id_value = "textarea-" + /*method*/ ctx[20]["id"]);
attr(textarea, "name", "textarea");
attr(textarea, "placeholder", "Fixed size textarea");
attr(div, "class", "rf-input-group");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, label);
append(label, t0);
append(div, t1);
append(div, textarea);
set_input_value(textarea, /*requestBodyExample*/ ctx[5][/*method*/ ctx[20]["id"]]);
if (!mounted) {
dispose = listen(textarea, "input", textarea_input_handler);
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty[0] & /*paths*/ 64 && label_for_value !== (label_for_value = "textarea-" + /*method*/ ctx[20]["id"])) {
attr(label, "for", label_for_value);
}
if (dirty[0] & /*paths*/ 64 && textarea_id_value !== (textarea_id_value = "textarea-" + /*method*/ ctx[20]["id"])) {
attr(textarea, "id", textarea_id_value);
}
if (dirty[0] & /*requestBodyExample, paths*/ 96) {
set_input_value(textarea, /*requestBodyExample*/ ctx[5][/*method*/ ctx[20]["id"]]);
}
},
d(detaching) {
if (detaching) detach(div);
mounted = false;
dispose();
}
};
}
// (153:18) {#each Object.entries(method.requestBody.content) as requestBody }
function create_each_block_6(ctx) {
let div1;
let h4;
let t0;
let t1_value = /*requestBody*/ ctx[35][0] + "";
let t1;
let t2;
let div0;
let table;
let thead;
let t9;
let tbody;
let t10;
let br;
let t11;
let t12;
function select_block_type_1(ctx, dirty) {
if ("$ref" in /*requestBody*/ ctx[35][1]["schema"]) return create_if_block_11;
return create_else_block_3;
}
let current_block_type = select_block_type_1(ctx);
let if_block0 = current_block_type(ctx);
let if_block1 = "$ref" in /*requestBody*/ ctx[35][1]["schema"] && create_if_block_10(ctx);
return {
c() {
div1 = element("div");
h4 = element("h4");
t0 = text("Request Body - ");
t1 = text(t1_value);
t2 = space();
div0 = element("div");
table = element("table");
thead = element("thead");
thead.innerHTML = `<tr><th>Name</th>
<th>Description</th>
<th>Type</th>
</tr><tr></tr>`;
t9 = space();
tbody = element("tbody");
if_block0.c();
t10 = space();
br = element("br");
t11 = space();
if (if_block1) if_block1.c();
t12 = space();
attr(h4, "class", "subtitle");
attr(table, "class", "rf-table");
set_style(table, "width", "100%");
attr(div0, "class", "table-container");
attr(div1, "class", "swagger-parameters");
},
m(target, anchor) {
insert(target, div1, anchor);
append(div1, h4);
append(h4, t0);
append(h4, t1);
append(div1, t2);
append(div1, div0);
append(div0, table);
append(table, thead);
append(table, t9);
append(table, tbody);
if_block0.m(tbody, null);
append(div0, t10);
append(div0, br);
append(div0, t11);
if (if_block1) if_block1.m(div0, null);
append(div1, t12);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t1_value !== (t1_value = /*requestBody*/ ctx[35][0] + "")) set_data(t1, t1_value);
if (current_block_type === (current_block_type = select_block_type_1(ctx)) && if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0.d(1);
if_block0 = current_block_type(ctx);
if (if_block0) {
if_block0.c();
if_block0.m(tbody, null);
}
}
if ("$ref" in /*requestBody*/ ctx[35][1]["schema"]) {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1 = create_if_block_10(ctx);
if_block1.c();
if_block1.m(div0, null);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
},
d(detaching) {
if (detaching) detach(div1);
if_block0.d();
if (if_block1) if_block1.d();
}
};
}
// (216:18) {#if method.parameters && method.parameters.length > 0}
function create_if_block_5(ctx) {
let div1;
let h4;
let t1;
let div0;
let table;
let thead;
let t12;
let tbody;
let each_value_5 = /*method*/ ctx[20].parameters;
let each_blocks = [];
for (let i = 0; i < each_value_5.length; i += 1) {
each_blocks[i] = create_each_block_5(get_each_context_5(ctx, each_value_5, i));
}
return {
c() {
div1 = element("div");
h4 = element("h4");
h4.textContent = "Parameters";
t1 = space();
div0 = element("div");
table = element("table");
thead = element("thead");
thead.innerHTML = `<tr><th>Name</th>
<th>Input</th>
<th>Description</th>
<th>Located in</th>
<th>Type</th>
</tr><tr></tr>`;
t12 = space();
tbody = element("tbody");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(h4, "class", "subtitle");
attr(table, "class", "rf-table");
set_style(table, "width", "100%");
attr(div0, "class", "table-container");
attr(div1, "class", "swagger-parameters");
},
m(target, anchor) {
insert(target, div1, anchor);
append(div1, h4);
append(div1, t1);
append(div1, div0);
append(div0, table);
append(table, thead);
append(table, t12);
append(table, tbody);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(tbody, null);
}
},
p(ctx, dirty) {
if (dirty[0] & /*paths, requestParams*/ 80) {
each_value_5 = /*method*/ ctx[20].parameters;
let i;
for (i = 0; i < each_value_5.length; i += 1) {
const child_ctx = get_each_context_5(ctx, each_value_5, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_5(child_ctx);
each_blocks[i].c();
each_blocks[i].m(tbody, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value_5.length;
}
},
d(detaching) {
if (detaching) detach(div1);
destroy_each(each_blocks, detaching);
}
};
}
// (238:32) {:else}
function create_else_block_1(ctx) {
let span;
let t_value = /*parameter*/ ctx[32].name + "";
let t;
return {
c() {
span = element("span");
t = text(t_value);
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t_value !== (t_value = /*parameter*/ ctx[32].name + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(span);
}
};
}
// (234:32) {#if parameter.required}
function create_if_block_8(ctx) {
let span;
let t_value = /*parameter*/ ctx[32].name + "";
let t;
return {
c() {
span = element("span");
t = text(t_value);
attr(span, "class", "swagger-parameter-required");
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t_value !== (t_value = /*parameter*/ ctx[32].name + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(span);
}
};
}
// (256:32) {:else}
function create_else_block(ctx) {
let t;
return {
c() {
t = text("String");
},
m(target, anchor) {
insert(target, t, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(t);
}
};
}
// (250:32) {#if parameter.type}
function create_if_block_6(ctx) {
let t0_value = /*parameter*/ ctx[32].type + "";
let t0;
let t1;
let if_block_anchor;
let if_block = /*parameter*/ ctx[32].items && create_if_block_7(ctx);
return {
c() {
t0 = text(t0_value);
t1 = space();
if (if_block) if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
insert(target, t0, anchor);
insert(target, t1, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t0_value !== (t0_value = /*parameter*/ ctx[32].type + "")) set_data(t0, t0_value);
if (/*parameter*/ ctx[32].items) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_7(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
d(detaching) {
if (detaching) detach(t0);
if (detaching) detach(t1);
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
// (252:34) {#if parameter.items }
function create_if_block_7(ctx) {
let t0;
let t1_value = /*parameter*/ ctx[32].items.type + "";
let t1;
return {
c() {
t0 = text("of\n ");
t1 = text(t1_value);
},
m(target, anchor) {
insert(target, t0, anchor);
insert(target, t1, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*paths*/ 64 && t1_value !== (t1_value = /*parameter*/ ctx[32].items.type + "")) set_data(t1, t1_value);
},
d(detaching) {
if (detaching) detach(t0);
if (detaching) detach(t1);
}
};
}
// (231:26) {#each method.parameters as parameter}
function create_each_block_5(ctx) {
let tr;
let td0;
let t0;
let td1;
let input;
let input_placeholder_value;
let t1;
let td2;
let raw_value = /*parameter*/ ctx[32].description + "";
let t2;
let td3;
let t3_value = /*parameter*/ ctx[32].in + "";
let t3;
l