Skip to content

Commit

Permalink
feat: restdoc openapi 연동 (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan authored Jan 17, 2024
1 parent 15e012a commit 8109b5d
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 1,920 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ src/main/resources/config
!application-test.yml
src/main/generated
dump.rdb
/src/main/resources/firebase-local.json
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 👨‍👨‍👧 Backend Team 소개

| 김영명 | 김희빈 | 박세연(PO) | 신재윤 | 홍혁준(SM) |
| 김영명 | 김희빈(PO) | 박세연 | 신재윤 | 홍혁준(SM) |
|:------------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|
| DEVELOPER | DEVELOPER | DEVELOPER | DEVELOPER | DEVELOPER |
| <img src="https://avatars.githubusercontent.com/u/83266154?v=4" width="250" /> | <img src="https://avatars.githubusercontent.com/u/72112845?v=4" width="250" /> | <img src="https://avatars.githubusercontent.com/u/54196094?v=4" width="250" /> | <img src="https://avatars.githubusercontent.com/u/87688023?v=4" width="250" /> | <img src="https://avatars.githubusercontent.com/u/31675711?v=4" width="250" /> |
Expand All @@ -29,6 +29,14 @@

![img.png](readme-image/파이프라인.png)

## 테이블 아키텍처

![img.png](readme-image/table.png)

## API 명세

![img.png](readme-image/api.png)

## 컨벤션

![img_1.png](readme-image/컨벤션.png)
Expand Down
61 changes: 20 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'org.sonarqube' version '4.4.1.3373'
id 'jacoco'
id 'checkstyle'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'com.epages.restdocs-api-spec' version '0.18.4'
}

group = 'com.moabam'
Expand All @@ -25,10 +25,6 @@ compileTestJava {
options.encoding = 'UTF-8'
}

ext {
snippetsDir = file('build/generated-snippets')
}

def querydslSrcDir = 'src/main/generated'

clean {
Expand All @@ -40,8 +36,6 @@ tasks.withType(JavaCompile) {
}

configurations {
asciidoctorExtensions

compileOnly {
extendsFrom annotationProcessor
}
Expand Down Expand Up @@ -70,7 +64,14 @@ dependencies {

// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0'
testImplementation 'com.squareup.okhttp3:mockwebserver'

// RestDocs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'com.epages:restdocs-api-spec-mockmvc:0.18.4'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

// Querydsl
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
Expand Down Expand Up @@ -107,12 +108,6 @@ dependencies {
// JSON parser
implementation 'org.json:json:20230618'

// Asciidoctor
asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor'

// RestDocs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'

// S3
implementation platform("io.awspring.cloud:spring-cloud-aws-dependencies:3.0.2")
implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3'
Expand All @@ -125,9 +120,6 @@ dependencies {

// Logback Slack Appender
implementation 'com.github.maricn:logback-slack-appender:1.6.1'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
}

tasks.named('test') {
Expand Down Expand Up @@ -196,30 +188,17 @@ sonar {
}
}

test {
outputs.dir snippetsDir
}
openapi3 {
servers = [
{ url = 'http://localhost:8080' },
{ url = 'http://dev.moabam.com' }
]

asciidoctor {
configurations 'asciidoctorExtensions'
inputs.dir snippetsDir
dependsOn test
}
title = 'MOABAM API DOCS'
format = 'json'

asciidoctor.doFirst {
delete file('src/main/resources/static/docs')
}

tasks.register('copyDocument', Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}

bootJar {
dependsOn copyDocument
}

build {
dependsOn copyDocument
copy {
from 'build/api-spec'
into 'src/main/resources/static/docs'
}
}
Binary file added readme-image/api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme-image/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/java/com/moabam/global/auth/filter/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.Objects;

import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
Expand All @@ -22,6 +23,7 @@

@Slf4j
@Order(0)
@Profile("!local")
@Component
@RequiredArgsConstructor
public class CorsFilter extends OncePerRequestFilter {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/moabam/global/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public PathResolver pathResolver() {
PathMapper.parsePath("/favicon/*"),
PathMapper.parsePath("/*/icon-*"),
PathMapper.parsePath("/favicon.ico"),
PathMapper.parsePath("/v3/api-docs"),
PathMapper.parsePath("/swagger*/**"),
PathMapper.parsePath("/swagger-ui/**"),
PathMapper.parsePath("/swagger-resources/**"),
PathMapper.parsePath("/v3/api-docs/**"),
PathMapper.pathWithMethod("/serverTime", List.of(HttpMethod.GET))))
.build();

Expand Down
Loading

0 comments on commit 8109b5d

Please sign in to comment.