Skip to content

Commit

Permalink
작업완료
Browse files Browse the repository at this point in the history
  • Loading branch information
goyounha11 committed Jul 23, 2024
1 parent 4014164 commit 4426b6c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
id("org.springframework.boot") version "3.3.1"
id("io.spring.dependency-management") version "1.1.5"
id("com.epages.restdocs-api-spec") version "0.18.2"
id("org.hidetake.swagger.generator") version "2.19.2"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
Expand All @@ -12,7 +12,7 @@ plugins {
}

group = "io.github.goyounha11"
version = "0.0.5"
version = "0.0.6"

apply(from = "${rootDir}/scripts/publish-maven.gradle")
apply(from = "publish.gradle")
Expand Down
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
PUBLISH_GROUP_ID = 'io.github.goyounha11'
PUBLISH_VERSION = '0.0.5'
PUBLISH_VERSION = '0.0.6'
PUBLISH_ARTIFACT_ID = 'automatedAPIDocsUtil'
PUBLISH_DESCRIPTION = 'restdocs simple create util'
PUBLISH_URL = 'https://github.com/goyounha11/automatedAPIDocsUtil'
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/goyounha11/core/reponse/ApiResult.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.goyounha11.core.reponse

import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotNull
import java.time.LocalDateTime


data class ApiResult<T>(
@field:NotBlank
val code: String,
@field:NotBlank
val message: String,
@field:NotNull
val responseAt: LocalDateTime = LocalDateTime.now(),
val data: T? = null
) {
Expand Down
15 changes: 14 additions & 1 deletion src/main/kotlin/com/goyounha11/docs/DocsUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.epages.restdocs.apispec.ParameterDescriptorWithType
import com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName
import com.epages.restdocs.apispec.ResourceDocumentation.resource
import com.epages.restdocs.apispec.ResourceSnippetParametersBuilder
import com.epages.restdocs.apispec.Schema
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
Expand Down Expand Up @@ -40,7 +41,9 @@ object DocsUtil {
description: String,
resultActions: ResultActions,
requestClazz: Class<*>? = null,
responseClazz: Class<*>? = null
responseClazz: Class<*>? = null,
requestSchema: String? = null,
responseSchema: String? = null
): RestDocumentationResultHandler {
val resourceSnippetParametersBuilder = ResourceSnippetParametersBuilder().tags(tag).description(description)

Expand All @@ -66,6 +69,16 @@ object DocsUtil {
resourceSnippetParametersBuilder.pathParameters(requestPathParameter)
resourceSnippetParametersBuilder.responseFields(responseFieldDescriptors)

resourceSnippetParametersBuilder.apply {
requestSchema?.let { schema ->
requestSchema(Schema(schema))
}

responseSchema?.let { schema ->
responseSchema(Schema(schema))
}
}

return document(
identifier,
Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
Expand Down
4 changes: 3 additions & 1 deletion src/test/kotlin/com/goyounha11/api/UserApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ internal class UserApiTest {
"유저 회원가입 API",
resultAction,
UserCreateRequest::class.java,
UserCreateData::class.java
UserCreateData::class.java,
"UserCreateRequest",
"UserCreateData"
)
)
}
Expand Down

0 comments on commit 4426b6c

Please sign in to comment.