Try client generator
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-07-01 22:58:56 +02:00
parent 3a05120da4
commit 2b18120c0b
Signed by: armin
GPG key ID: 48C726EEE7FBCBC8
4 changed files with 125 additions and 3 deletions

View file

@ -47,9 +47,17 @@ steps:
context: ./container context: ./container
repo: arminfriedl/fling repo: arminfriedl/fling
tags: dev tags: dev
when:
branch: - name: runservice
- master image: arminfriedl/fling:dev
pull: always
detach: true
- name: generate-clients
image: openapitools/openapi-generator-cli
commands:
- sleep 35
- java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i http://runservice:3000/v3/api-docs -g python -o flingclient
volumes: volumes:
- name: m2-cache - name: m2-cache

9
LICENSE Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright © 2020 Armin Friedl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -27,6 +27,40 @@ server {
client_max_body_size 5G; client_max_body_size 5G;
} }
# handle openapi requests by openapi servlet
location /v3/api-docs {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for web sockets to function
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# handle openapi requests by openapi servlet
location /swagger-ui.html {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for web sockets to function
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# always respond with index.html for unknown paths # always respond with index.html for unknown paths
# (routing is client side) # (routing is client side)
location / { location / {

View file

@ -0,0 +1,71 @@
package net.friedl.fling.controller;
import java.util.Optional;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.security.SecurityScheme.Type;
import io.swagger.v3.oas.models.servers.Server;
import lombok.Data;
@Data
@Configuration
@ConfigurationProperties("fling.api")
public class OpenApiConfiguration {
private String version;
private String serverUrl;
private String serverDescription;
@Bean
public OpenAPI openApi() {
OpenAPI openApi = new OpenAPI()
.components(new Components()
.addSecuritySchemes("bearer", bearerScheme())
.addSchemas("resource", new Schema<Resource>()
.type("string").format("binary")))
.info(apiInfo());
serverItem().ifPresent(openApi::addServersItem);
return openApi;
}
public SecurityScheme bearerScheme() {
return new SecurityScheme()
.name("bearerAuth")
.type(Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT");
}
public Info apiInfo() {
return new Info()
.contact(new Contact()
.name("Armin Friedl")
.url("https://www.friedl.net")
.email("dev@friedl.net"))
.license(new License()
.name("The MIT License (MIT)"))
.title("The Fling API")
.description("Share file collections with expiration, protection and short urls")
.version(version);
}
public Optional<Server> serverItem() {
if (serverUrl == null) return Optional.empty();
return Optional.of(
new Server()
.description(serverDescription)
.url(serverUrl));
}
}