Skip to content

Commit

Permalink
docs(friendships-service): add enpoints api specs
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-borriello00 authored and alemazzo committed May 10, 2024
1 parent adada6f commit 6dc6174
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
package piperkt.services.friendships

import io.micronaut.runtime.Micronaut.run
import io.swagger.v3.oas.annotations.OpenAPIDefinition
import io.swagger.v3.oas.annotations.info.Contact
import io.swagger.v3.oas.annotations.info.Info

fun main(vararg args: String) {
run(*args)
@OpenAPIDefinition(
info =
Info(
title = "Piper-kt Friendships API",
version = "1.0",
description = "Piper-kt Friendships Service API",
contact =
Contact(
url = "https://piper-kt.com",
name = "Zucchero Sintattico",
email = "[email protected]"
)
)
)
object Application {

@JvmStatic
fun main(args: Array<String>) {
run(Application.javaClass)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,80 @@ import io.micronaut.http.annotation.PathVariable
import io.micronaut.http.annotation.QueryValue
import io.micronaut.security.annotation.Secured
import io.micronaut.security.rules.SecurityRule
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import java.security.Principal
import piperkt.services.friendships.interfaces.web.api.interactions.FriendshipApi

@Secured(SecurityRule.IS_AUTHENTICATED)
interface FriendshipHttpApi {

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendship request sent successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "403", description = "Forbidden"),
)
fun sendFriendshipRequest(
@Body request: FriendshipApi.SendFriendshipRequest.Request,
principal: Principal
): FriendshipApi.SendFriendshipRequest.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendship request accepted successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "404", description = "Friendship request not found"),
)
fun acceptFriendshipRequest(
@Body request: FriendshipApi.AcceptFriendshipRequest.Request,
principal: Principal
): FriendshipApi.AcceptFriendshipRequest.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendship request declined successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "404", description = "Friendship request not found"),
)
fun declineFriendshipRequest(
@Body request: FriendshipApi.DeclineFriendshipRequest.Request,
principal: Principal
): FriendshipApi.DeclineFriendshipRequest.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendship requests found successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
)
fun getFriendshipRequests(principal: Principal): FriendshipApi.GetFriendshipRequests.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendships found successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
)
fun getFriendships(principal: Principal): FriendshipApi.GetFriendships.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Friendship messages found successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "404", description = "Friendship not found"),
)
fun getFriendshipMessages(
@PathVariable friendUsername: String,
@QueryValue from: Int,
@QueryValue limit: Int,
principal: Principal
): FriendshipApi.GetFriendshipMessages.Response

@ApiResponses(
ApiResponse(responseCode = "200", description = "Message sent successfully"),
ApiResponse(responseCode = "400", description = "Bad request"),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "404", description = "Friendship not found"),
)
fun sendMessage(
@PathVariable friendUsername: String,
@Body request: FriendshipApi.SendMessage.Request,
Expand Down
3 changes: 3 additions & 0 deletions friendships-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ application:
mongodb:
package-names:
- piperkt.services.friendships.infrastructure.persistence
micronaut:
openapi:
filename: "openapi-friendships"
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,3 @@ object Application {
Micronaut.run(Application.javaClass)
}
}
// LEVEL -> WHATS -> DEPENDENCIES
// --------------------------------
// DOMAIN -> Language:
// - Entities
// - Value Objects
// - Repositories
// - Factories
// APPLICATION -> Domain
// - Services
// INTERFACES ->
// - Controller (Indepedent of the framework)
// INFRASTRUCTURE

0 comments on commit 6dc6174

Please sign in to comment.