Skip to content

Commit

Permalink
close #9 README.md 수정 및 코드내용 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
honeymon-enterprise committed Sep 27, 2022
1 parent 6348c75 commit 77b8345
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 39 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Spring Rest Docs 사용 가이드

<!-- ABOUT THE PROJECT -->
## 프로젝트 소개
곧 기술블로그를 통해 'Spring REST Docs 작성가이드 공유드리겠습니다.'
'Spring REST Docs 작성 가이드'를 윟나 예제프로젝트입니다.

'Spring Boot'를 기반으로 하고 있으며 간단하게 Spring REST Docs 와 Springfox 를 활용한 API문서를 제공합니다.

<p style="text-align: right">(<a href="#readme-top">최상단 이동</a>)</p>

<!-- GETTING STARTED -->
Expand All @@ -32,6 +35,8 @@ Spring Rest Docs 사용 가이드
프로젝트를 로컬에서 시작하려면 다음 안내를 따라주시면 됩니다.

### 요구사항
* Java 17 이상
* Java 설치방법: [여러 개의 JDK를 설치하고 선택해서 사용하기](https://blog.benelog.net/installing-jdk.html)

### 설치

Expand All @@ -55,25 +60,29 @@ Spring Rest Docs 사용 가이드
1. Spring REST Docs: `build/docs/index.html`
2. SwaggerUI: `api-spec/openapi3.yaml`

<p style="text-align: right">(<a href="#readme-top">최상단 이동</a>)</p>
5. 애플리케이션 실행
```sh
./gradlew apiBuild
cd build/libs
java -jar application.jar
```

### 확인
#### Spring REST Docs
[http://localhost:8080/docs/index.html]()

<!-- CONTRIBUTION GUIDE -->
### 협업방법
#### Spring REST Docs - OpenAPI Specification Integration
[http://localhost:8080/swagger/swagger-ui.html]()

* 프로젝트를 새롭게 시작했거나 프로젝트 문서가 없다면 확인자가 문서를 생성합니다.
* PUSH 전에 checkStyle, sonarlint 등을 이용해 코드를 정리해주세요.
* Pull Request 전에는 로컬 테스트를 반드시 수행해 주세요. <!-- 커밋 훅으로 강제하는 방법도 있겠으나, 핫픽스 등의 급한 처리건이 발생할 수 있으니... -->
#### Springdoc
[http://localhost:8080/swagger-ui/index.html]()

<p style="text-align: right">(<a href="#readme-top">최상단 이동</a>)</p>

<!-- APPENDIX -->
## 부록

* [Choose an Open Source License](https://choosealicense.com)
* [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
* [sdkman.io](https://sdkman.io/)
* [Markdown Guide](https://www.markdownguide.org/)
* [Best-README-Template](https://github.com/othneildrew/Best-README-Template)
* [여러 개의 JDK를 설치하고 선택해서 사용하기](https://blog.benelog.net/installing-jdk.html)

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ plugins {
id "java"
}

group = "com.kurly.tet"
version = "0.0.1-SNAPSHOT"
group = "${projectGroup}"
version = "${projectVersion}"
sourceCompatibility = JavaVersion.VERSION_17

configurations {
Expand Down Expand Up @@ -85,8 +85,8 @@ openapi3 {
{ url = 'http://localhost:8080' },
]
title = 'spring-rest-docs-guide'
description = 'spring-rest-docs-guide description'
version = '0.1.0'
description = 'Spring REST Docs 테스트 생성물 생성시 추가생성되는 OpenAPI 문서이용'
version = "${project.version}"
format = 'yaml'
}

Expand All @@ -106,13 +106,13 @@ gitProperties {

bootJar {
from("swagger-ui") {
into "BOOT-INF/classes/static/swagger-ui"
into "BOOT-INF/classes/static/swagger"
}
from("${asciidoctor.outputDir}") {
into "BOOT-INF/classes/static/docs"
}
from("build/api-spec") {
into "BOOT-INF/classes/static/swagger-ui"
into "BOOT-INF/classes/static/swagger"
}

archiveFileName.set "application.jar"
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
projectGroup=com.kurly.tet
projectVersion=1.0.0

org.gradle.cache=false
org.gradle.parallel=true
5 changes: 2 additions & 3 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
= Spring REST Docs 가이드
김지헌, <jiheon[email protected]>
v2022.09.23, 2022-09-23
//문서 초기 설정
김지헌(팀 엔지니어링 팀), <jiheon[email protected]>
v2022.09.28, 2022-09-28
:doctype: book
:icons: font
:source-highlighter: coderay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Constant {
public static final String PROFILE_PRODUCTION = "prod";

public static final String HOST_LOCAL = "12.0.0.1";
public static final String HOST_DEV = "spring-rest-docs-guide.dev.kurly.in";
public static final String HOST_DEV = ""; // 개발DNS 는 배포에 따라 맞춰 진행

public static final String FORMAT_LOCAL_DATE_TIME = "yyyy-MM-dd'T'HH:mm:ss";
public static final String FORMAT_LOCAL_DATE = "yyyy-MM-dd";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
info = @Info(
title = "Spring REST Docs 가이드(Swagger 구성) 응?",
version = "v2022.09.26",
description = "Spring REST Docs 가이드를 작성하려고 했는데, 일이 너무 커저벼린 건에 대해서 반성중...",
contact = @Contact(url = "https://helloworld.kurly.com/", name = "김지헌", email = "[email protected]")
description = """
Spring REST Docs 가이드를 작성하려고 했는데, 일이 너무 커저버린 건에 대해서 반성중....
생각외로 간단하게 적용가능해서 놀람""",
contact = @Contact(url = "https://helloworld.kurly.com/", name = "김지헌(팀 엔지니어링 팀)", email = "[email protected]")
)
)
@Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import java.util.UUID;

import static com.epages.restdocs.apispec.ResourceDocumentation.resource;
import static com.kurly.tet.guide.springrestdocs.config.Constant.FORMAT_LOCAL_DATE_TIME;
import static com.kurly.tet.guide.springrestdocs.config.Constant.HOST_DEV;
import static com.kurly.tet.guide.springrestdocs.config.Constant.*;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentFormatGenerator.customFormat;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentFormatGenerator.generateEnumAttrs;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentUtils.getDocumentRequest;
Expand Down Expand Up @@ -243,7 +242,7 @@ void test01(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.hasContent").type(BOOLEAN).description("컨텐츠가있는가?"),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.get("/orders")
.param("page", "0")
.param("size", "20")
Expand Down Expand Up @@ -351,7 +350,7 @@ void test02(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.completedDateTime").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("결제완료일시").optional(),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.post("/orders")
.contentType(MediaType.APPLICATION_JSON)
.content(createCommandJson)
Expand Down Expand Up @@ -457,7 +456,7 @@ void test03(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.completedDateTime").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("결제완료일시").optional(),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.put("/orders/{orderNo}/payment", orderNo)
.contentType(MediaType.APPLICATION_JSON)
.content(commandJson)
Expand Down Expand Up @@ -562,7 +561,7 @@ void test06(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.completedDateTime").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("결제완료일시").optional(),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.get("/orders/{orderNo}", orderNo)
.contentType(MediaType.APPLICATION_JSON)
)
Expand Down Expand Up @@ -660,7 +659,7 @@ void test04(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.completedDateTime").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("결제완료일시").optional(),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.put("/orders/{orderNo}/shipping", orderNo)
.contentType(MediaType.APPLICATION_JSON)
)
Expand Down Expand Up @@ -757,7 +756,7 @@ void test05(RestDocumentationContextProvider contextProvider) throws Exception {
fieldWithPath("data.completedDateTime").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("결제완료일시").optional(),
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.put("/orders/{orderNo}/complete", orderNo)
.contentType(MediaType.APPLICATION_JSON)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static com.epages.restdocs.apispec.ResourceDocumentation.resource;
import static com.kurly.tet.guide.springrestdocs.config.Constant.FORMAT_LOCAL_DATE_TIME;
import static com.kurly.tet.guide.springrestdocs.config.Constant.HOST_DEV;
import static com.kurly.tet.guide.springrestdocs.config.Constant.HOST_LOCAL;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentFormatGenerator.customFormat;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentFormatGenerator.generateEnumAttrs;
import static com.kurly.tet.guide.springrestdocs.documenation.DocumentUtils.getDocumentRequest;
Expand Down Expand Up @@ -140,7 +140,7 @@ void testSearchProduct(RestDocumentationContextProvider contextProvider) throws
};


MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.get("/products")
.param("page", "0")
.param("size", "20")
Expand Down Expand Up @@ -214,7 +214,7 @@ void testCreateProduct(RestDocumentationContextProvider contextProvider) throws
};

var expectedContent = "{\"code\":\"0000\",\"message\":\"정상\",\"data\":{\"id\":1,\"productName\":\"테스트상품\",\"productNo\":\"TEST01\",\"productStatus\":\"CREATED\",\"created\":\"2022-09-23T05:46:10\",\"modified\":\"2022-09-23T05:46:10\",\"productStatusDescription\":\"생성\"}}";
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.post("/products")
.contentType(MediaType.APPLICATION_JSON)
.content(createCommandJson)
Expand Down Expand Up @@ -279,7 +279,7 @@ void testGetProduct(RestDocumentationContextProvider contextProvider) throws Exc
fieldWithPath("data.modified").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("변경일시")
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.get("/products/{id}", 1L)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultHandlers.print())
Expand Down Expand Up @@ -356,7 +356,7 @@ void testModifyProduct(RestDocumentationContextProvider contextProvider) throws
fieldWithPath("data.modified").type(STRING).attributes(customFormat(FORMAT_LOCAL_DATE_TIME)).description("변경일시")
};

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.put("/products/{id}", 1L)
.contentType(MediaType.APPLICATION_JSON)
.content(modifyCommandJson)
Expand Down Expand Up @@ -402,7 +402,7 @@ void testDeleteProduct(RestDocumentationContextProvider contextProvider) throws

var parameterDescriptor = parameterWithName("id").description("상품번호");

MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_DEV, controller)
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, controller)
.perform(RestDocumentationRequestBuilders.delete("/products/{id}", 1L)
.contentType(MediaType.APPLICATION_JSON)
)
Expand Down
2 changes: 1 addition & 1 deletion swagger-ui/swagger-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
window.onload = function () {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "/swagger-ui/openapi3.yaml",
url: "/swagger/openapi3.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down

0 comments on commit 77b8345

Please sign in to comment.