diff --git a/README.md b/README.md index 3ab348c..f0d5ed2 100644 --- a/README.md +++ b/README.md @@ -1 +1,20 @@ # kirby +**The Hive's note-taking API** + +*"(੭。╹▿╹。)੭ Kirby will swallow and spit notes for you"* +### First steps +(Configuring the environment): + +1. git clone https://github.com/hex-g/kirby.git + 1. cd kirby +2. git checkout [branch] +3. git submodule init +4. git submodule update +5. Run the project in your IDE + 1. required JDK 11+ + 2. required Gradle compatible + +default swagger location: http://localhost:9400/swagger-ui.html + +--- + diff --git a/build.gradle b/build.gradle index 957437a..d2e4c66 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client' testImplementation 'org.springframework.boot:spring-boot-starter-test' + + compile 'io.springfox:springfox-swagger2:2.9.2' + compile 'io.springfox:springfox-swagger-ui:2.9.2' } dependencyManagement { @@ -48,3 +51,7 @@ dependencyManagement { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } + +bootJar { + launchScript() +} diff --git a/src/main/java/hive/kirby/swagger/SwaggerConfig.java b/src/main/java/hive/kirby/swagger/SwaggerConfig.java new file mode 100644 index 0000000..0b3dbe1 --- /dev/null +++ b/src/main/java/hive/kirby/swagger/SwaggerConfig.java @@ -0,0 +1,58 @@ +package hive.kirby.swagger; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.HashSet; +import java.util.Set; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig extends WebMvcConfigurationSupport { + + @Bean + public Docket apiDocumentation() { + Set responseContentTypes = new HashSet<>(); + responseContentTypes.add("*/*"); + responseContentTypes.add("text/plain"); + responseContentTypes.add("application/json"); + responseContentTypes.add("image/jpeg"); + return new + Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("hive.kirby")) + .build() + .produces(responseContentTypes) + .consumes(responseContentTypes) + .apiInfo(metaData()); + } + + private ApiInfo metaData() { + return new + ApiInfoBuilder() + .title("Kirby endpoints") + .description("\"Profile image management API\"" + + "\n Repository: https://github.com/hex-g/kirby" + + "\n Created by: https://github.com/hex-g/") + .version("v1.0") + .license("") + .licenseUrl("") + .build(); + } + + @Override + protected void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + } +} \ No newline at end of file