diff --git a/lib/NGCP/Panel/Controller/API/Root.pm b/lib/NGCP/Panel/Controller/API/Root.pm index c696f86931..d435e5732d 100644 --- a/lib/NGCP/Panel/Controller/API/Root.pm +++ b/lib/NGCP/Panel/Controller/API/Root.pm @@ -54,6 +54,10 @@ sub auto :Private { sub GET : Allow { my ($self, $c) = @_; + if ($c->req->params->{swaggerui}) { + $c->detach('swaggerui'); + } + my $blacklist = { "DomainPreferenceDefs" => 1, "SubscriberPreferenceDefs" => 1, @@ -275,6 +279,19 @@ sub swagger :Private { return; } +sub swaggerui :Private { + my ($self, $c) = @_; + + + $c->stash(template => 'api/swaggerui.tt'); + $c->forward($c->view); + # $c->response->headers(HTTP::Headers->new( + # Content_Language => 'en', + # Content_Type => 'application/xhtml+xml', + # #$self->collections_link_headers, + # )); +} + sub HEAD : Allow { my ($self, $c) = @_; $c->forward(qw(GET)); diff --git a/lib/NGCP/Panel/Utils/API.pm b/lib/NGCP/Panel/Utils/API.pm index ae4be80efa..c35e8ae8a4 100644 --- a/lib/NGCP/Panel/Utils/API.pm +++ b/lib/NGCP/Panel/Utils/API.pm @@ -154,7 +154,7 @@ sub generate_swagger_datastructure { schema => { # '$ref' => 'http://json.schemastore.org/json-patch.json#/', # "$ref": "https://raw.githubusercontent.com/fge/sample-json-schemas/master/json-patch/json-patch.json" - '$ref' => '/js/schemas/json-patch.json#/', + '$ref' => '/static/js/schemas/json-patch.json#/', # type => 'array', # items => { # type => 'object', diff --git a/share/static/css/sipwise-apidoc.css b/share/static/css/sipwise-apidoc.css new file mode 100644 index 0000000000..22788beafa --- /dev/null +++ b/share/static/css/sipwise-apidoc.css @@ -0,0 +1,54 @@ +.sipwclass { padding: 1em } +.content .sipwclass { margin-left: 2em } +h1 { color: white; background-color: #54893B; padding: 1.7em; } +.sipwclass h6 { font-size: 1.1em; } +.sipwclass code { white-space: pre-wrap; background-color: transparent; border: none; color: #000; font-size: 0.9em; display: block; margin: 0 0 20px 0;} +.sipwclass table { width: 100%; border-collapse: collapse; } +.sipwclass th, .sipwclass td { border: 1px solid #aaa; width: 50%; padding: 20px; } +.sipwclass td { vertical-align: top; } +.sipwclass span { font-family: monospace; } + +.sipwclass a { color: #54893B; border-bottom: 1px dotted #54893B; } +.sipwclass a:hover { color: #54893B; text-decoration: underline; border: none; } +.sipwclass .ui-state-active { border: 1px solid #54893B; color: #54893B; } +.sipwclass .ui-state-default { color: #54893B; } +.sipwclass .ui-widget { font-family: inherit; } +.sipwclass .ui-widget-content { background: none; } + +/* toc numbering */ +.sipwclass nav ol { counter-reset: item } +.sipwclass nav li { display: block } +.sipwclass nav li:before { content: counters(item, ".") " "; counter-increment: item } + +/* header numbering */ +.sipwclass body { counter-reset: h2counter; counter-reset: h3counter; } +h1 { counter-reset: h2counter; } +.sipwclass h2:before { content: counter(h2counter) "\0000a0\0000a0"; counter-increment: h2counter; counter-reset: h3counter; } +.sipwclass h2.nocount:before { content: none; counter-increment: none; } +.sipwclass h2 { counter-reset: h3counter; } +.sipwclass h3:before { counter-increment: h3counter; content: counter(h2counter) "." counter(h3counter) "\0000a0\0000a0"; } +/*.sipwclass h3:before { content: counter(h2counter) "." counter(h3counter) "\0000a0\0000a0"; counter-increment: h3counter; }*/ + +/* print properties */ +@media print { .ui-accordion > *{display:block !important;} } +.pagebreak { page-break-after: always; } +.sipwclass.chapter { page-break-inside: avoid; } + +.sipwclass { + font-family: 'Open Sans', sans-serif; +} + +/* use same width as swagger doc for intro chapters */ +body { + width: 100%; + max-width: 1460px; + margin: 8px auto; +} + +/* own additions: remove servers view and swagger file URI */ +.swagger-ui .global-server-container { + display: none; +} +.swagger-ui .info a { + display: none; +} \ No newline at end of file diff --git a/share/templates/api/root/chswaggerui.tt b/share/templates/api/root/chswaggerui.tt new file mode 100644 index 0000000000..01373a1eb2 --- /dev/null +++ b/share/templates/api/root/chswaggerui.tt @@ -0,0 +1,166 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[% # vim: set tabstop=4 syntax=html expandtab: -%] diff --git a/share/templates/api/swaggerui.tt b/share/templates/api/swaggerui.tt new file mode 100644 index 0000000000..7fe51399eb --- /dev/null +++ b/share/templates/api/swaggerui.tt @@ -0,0 +1,58 @@ + + + +