Skip to content

Commit

Permalink
1.0.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
goyounha11 committed Jul 24, 2024
1 parent 3c74af8 commit b8f1ea4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "io.github.goyounha11"
version = "1.0.0"
version = "1.0.3"

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 = '1.0.0'
PUBLISH_VERSION = '1.0.3'
PUBLISH_ARTIFACT_ID = 'automatedAPIDocsUtil'
PUBLISH_DESCRIPTION = 'restdocs simple create util'
PUBLISH_URL = 'https://github.com/goyounha11/automatedAPIDocsUtil'
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/goyounha11/core/reponse/ApiResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class ApiResult<T>(
val data: T? = null
) {
companion object {
fun of(exceptionCode: ErrorCode): ApiResult<*> {
fun of(exceptionCode: ErrorCode): ApiResult<Unit> {
return of(exceptionCode, null)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/goyounha11/core/reponse/Result.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class Result {

fun <T> created(data: T): ApiResult<T> = ApiResult.of(ErrorCode.SUCCESS_NORMAL, data)

fun ok(): ApiResult<*> = ApiResult.of(ErrorCode.SUCCESS_NORMAL)
fun ok(): ApiResult<Unit> = ApiResult.of(ErrorCode.SUCCESS_NORMAL)

fun <T> ok(data: T): ApiResult<T> = ApiResult.of(ErrorCode.SUCCESS_NORMAL, data)

fun error(): ApiResult<*> = ApiResult.of(ErrorCode.ERROR_SYSTEM)
fun error(): ApiResult<Unit> = ApiResult.of(ErrorCode.ERROR_SYSTEM)
}
}
21 changes: 12 additions & 9 deletions src/main/kotlin/com/goyounha11/docs/DocsUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ object DocsUtil {
identifier: String,
description: String,
resultActions: ResultActions,
parameterDescriptor: List<ParameterDescriptorWithType> = emptyList(),
requestClazz: Class<*>? = null,
responseClazz: Class<*>? = null,
requestSchema: String? = null,
responseSchema: String? = null
responseClazz: Class<*>? = null
): RestDocumentationResultHandler {
val resourceSnippetParametersBuilder =
ResourceSnippetParametersBuilder().tags(tag).description(description)
Expand All @@ -58,16 +57,16 @@ object DocsUtil {
val responseFieldDescriptors = createFieldDescriptors(responseNode, responseClazz?.kotlin)

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

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

val requestParameter = createParameters(request, ParameterType.QUERY)
val requestParameter = parameterDescriptor.ifEmpty { createParameters(request, ParameterType.QUERY) }
val requestPathParameter = createParameters(request, ParameterType.PATH)

resourceSnippetParametersBuilder.requestFields(requestFieldDescriptors)
Expand Down Expand Up @@ -217,7 +216,11 @@ object DocsUtil {
): List<ParameterDescriptorWithType> {
return if (type == ParameterType.QUERY) {
request.parameterMap.map { (key, value) ->
parameterWithName(key).description(value.joinToString())
if (value.joinToString().isNullOrBlank()) {
parameterWithName(key).description(value.joinToString()).optional()
} else {
parameterWithName(key).description(value.joinToString())
}
}
} else {
val uriVars =
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/com/goyounha11/api/UserApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ internal class UserApiTest {
"user/create",
"유저 회원가입 API",
resultAction,
UserCreateRequest::class.java,
UserCreateData::class.java
requestClazz = UserCreateRequest::class.java,
responseClazz = UserCreateData::class.java
// "UserCreateRequest",
// "UserCreateData"
)
Expand All @@ -93,8 +93,8 @@ internal class UserApiTest {
"{methodname}",
"유저 조회 API",
resultAction,
null,
UserCreateData::class.java
requestClazz = null,
responseClazz = UserCreateData::class.java
// "UserCreateRequest",
// "UserCreateData"
)
Expand Down

0 comments on commit b8f1ea4

Please sign in to comment.