Skip to content
Snippets Groups Projects
Verified Commit fd3ca3ab authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Swagger spec renderer, image version from spec

parent 5a087391
No related branches found
No related tags found
No related merge requests found
Pipeline #6886 failed
...@@ -2,18 +2,19 @@ image: docker:20.10.9 ...@@ -2,18 +2,19 @@ image: docker:20.10.9
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 2.6.0
services: services:
- docker:20.10.9-dind - docker:20.10.9-dind
before_script: before_script:
- apk add --no-cache yq
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build: build:
stage: build stage: build
script: script:
- VERSION=`yq '.info.version' openapi.yaml`
- docker pull $CI_REGISTRY_IMAGE:latest || true - docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$IMAGE_VER --tag $CI_REGISTRY_IMAGE:latest . - docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$VERSION --tag $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$IMAGE_VER - docker push $CI_REGISTRY_IMAGE:$VERSION
- docker push $CI_REGISTRY_IMAGE:latest - docker push $CI_REGISTRY_IMAGE:latest
...@@ -21,7 +21,8 @@ RUN cpanm \ ...@@ -21,7 +21,8 @@ RUN cpanm \
Mojo::Pg \ Mojo::Pg \
Mojo::Redis \ Mojo::Redis \
Mojo::JWT \ Mojo::JWT \
Mojolicious::Plugin::OpenAPI Mojolicious::Plugin::OpenAPI \
Mojolicious::Plugin::SwaggerUI
ADD . /opt/cf ADD . /opt/cf
WORKDIR /opt/cf WORKDIR /opt/cf
......
...@@ -102,13 +102,19 @@ sub startup { ...@@ -102,13 +102,19 @@ sub startup {
} }
}); });
$self->plugin( SwaggerUI => {
url => "/api",
title => "CF Online",
});
$self->defaults( $self->defaults(
openapi_cors_allowed_origins => ['*'] openapi_cors_allowed_origins => ['*']
); );
# Router # Router
my $r = $self->routes; my $r = $self->routes;
$r->get('/')->to(cb => sub { shift->redirect_to('/api.html');}); $r->get('/')->to(cb => sub { shift->redirect_to('/swagger-ui');});
$r->websocket('/ws')->to('Websockets#main'); $r->websocket('/ws')->to('Websockets#main');
} }
......
openapi: 3.0.3 openapi: 3.0.3
info: info:
version: "2.0" version: "2.6.1"
title: CF Online title: CF Online
description: CF Online description: CF Online
license: license:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment