Skip to content

Commit

Permalink
feat(preview): resolve nested references
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Sep 7, 2024
1 parent 45fa33a commit 1e6cf2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AsyncAPISpecificationHtmlRenderer {
)
}

private fun replaceLocalReferences(specification: String, specificationFile: VirtualFile, isJson: Boolean): String {
fun replaceLocalReferences(specification: String, specificationFile: VirtualFile, isJson: Boolean): String {
val objectMapper = if (isJson) {
ObjectMapper()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.jetbrains.io.send
import org.jetbrains.yaml.YAMLFileType
import java.io.File
import java.nio.charset.StandardCharsets
import kotlin.text.toByteArray

/**
* @author Pavel Bodiachevskii
Expand Down Expand Up @@ -128,7 +129,12 @@ class StaticServer : HttpRequestHandler() {
"application/x-yaml"
}

return Resource(contentType, requestedFile.readBytes())
val componentJson = asyncAPISpecificationHtmlRenderer.replaceLocalReferences(
requestedFile.readText(StandardCharsets.UTF_8),
referenceVirtualFile,
isJson
)
return Resource(contentType, componentJson.toByteArray(StandardCharsets.UTF_8))
}

private fun resolveResource(resourceName: String): Resource? {
Expand Down

0 comments on commit 1e6cf2b

Please sign in to comment.