Test openapi schema of /follow/*

This commit is contained in:
2021-03-20 02:43:53 +01:00
parent 46cc61fc25
commit 0e5943864d
3 changed files with 87 additions and 2 deletions

View File

@@ -59,7 +59,7 @@ sealed class FollowRepository<IN : TargetRef, OUT : TargetRef>(override var requ
open fun findFollow(
citizen: CitizenI,
target: TargetRef
): FollowForView<OUT>? =
): FollowForView<TargetRef>? =
requester
.getFunction("find_follow")
.selectOne(

View File

@@ -1,5 +1,6 @@
package fr.dcproject.component.follow.routes.article
import fr.dcproject.common.response.toOutput
import fr.dcproject.common.security.assert
import fr.dcproject.component.article.database.ArticleRef
import fr.dcproject.component.auth.citizen
@@ -13,6 +14,7 @@ import io.ktor.locations.Location
import io.ktor.locations.get
import io.ktor.response.respond
import io.ktor.routing.Route
import org.joda.time.DateTime
import java.util.UUID
@KtorExperimentalLocationsAPI
@@ -26,7 +28,22 @@ object GetFollowArticle {
get<ArticleFollowRequest> {
repo.findFollow(citizen, it.article)?.let { follow ->
ac.assert { canView(follow, citizenOrNull) }
call.respond(follow)
call.respond(
HttpStatusCode.OK,
follow.let { f ->
object {
val id: UUID = f.id
val createdBy: Any = f.createdBy.toOutput()
val target: Any = f.target.let { t ->
object {
val id: UUID = t.id
val reference: String = f.target.reference
}
}
val createdAt: DateTime = f.createdAt
}
}
)
} ?: call.respond(HttpStatusCode.NoContent)
}
}