Skip to content

Commit

Permalink
fix : Error where markdown format is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed Sep 16, 2024
1 parent b14b699 commit b735505
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 13 additions & 8 deletions api/src/main/kotlin/io/wwan13/api/document/ApiDocumentContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import org.springframework.restdocs.request.PathParametersSnippet
import org.springframework.restdocs.request.RequestDocumentation
import org.springframework.restdocs.request.RequestParametersSnippet
import org.springframework.restdocs.snippet.Snippet
import kotlin.String as String1

data class ApiDocumentContext(
val identifier: String,
val identifier: String1,
val summary: DocumentSummary,
val guide: DocumentGuide,
val enums: List<DocumentEnum>,
Expand Down Expand Up @@ -47,13 +48,17 @@ data class ApiDocumentContext(
return snippets.toTypedArray()
}

val description: String
get() = MarkdownConverter.join(
summary.description,
MarkdownConverter.convertGuide(guide),
MarkdownConverter.convertEnums(enums),
MarkdownConverter.convertErrors(errors),
)
val description: String1
get() {
val elements = mutableListOf<String1>()

if (summary.hasDescription()) elements.add(summary.description)
if (guide.hasValue()) elements.add(MarkdownConverter.convertGuide(guide))
if (enums.isNotEmpty()) elements.add(MarkdownConverter.convertEnums(enums))
if (errors.isNotEmpty()) elements.add(MarkdownConverter.convertErrors(errors))

return MarkdownConverter.join(elements)
}

private val allResponseFields: List<DocumentField>
get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object MarkdownConverter {

fun convertGuide(guide: DocumentGuide): String {
return """
|
|### Api Guide
|
|${guide.value.joinToString("\n") { "- $it" }}
Expand All @@ -26,6 +27,7 @@ object MarkdownConverter {
}

return """
|
|### Enum Values
|
|<details>
Expand All @@ -40,6 +42,7 @@ object MarkdownConverter {

fun convertErrors(errors: List<DocumentError>): String {
return """
|
|### Error Codes
|
|<details>
Expand All @@ -54,7 +57,7 @@ object MarkdownConverter {
""".trimMargin()
}

fun join(vararg values: String): String {
fun join(values: List<String>): String {
return values.joinToString("<br/>")
}
}

0 comments on commit b735505

Please sign in to comment.