diff --git a/ktorfit-annotations/Readme.md b/ktorfit-annotations/Readme.md index 48c5065bf..c8aa75afa 100644 --- a/ktorfit-annotations/Readme.md +++ b/ktorfit-annotations/Readme.md @@ -1,2 +1,3 @@ # Annotations + The annotations for Ktorfit \ No newline at end of file diff --git a/ktorfit-annotations/build.gradle.kts b/ktorfit-annotations/build.gradle.kts index d4be3679d..3da0ac25e 100644 --- a/ktorfit-annotations/build.gradle.kts +++ b/ktorfit-annotations/build.gradle.kts @@ -163,5 +163,6 @@ publishing { } rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class) { - rootProject.the(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class).nodeVersion = "18.0.0" + rootProject.the(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class).nodeVersion = + "18.0.0" } \ No newline at end of file diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Body.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Body.kt index 87896e7c6..250caab9d 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Body.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Body.kt @@ -1,10 +1,12 @@ package de.jensklingenberg.ktorfit.http /** + * Use this to upload data in an HTTP Body * -Use this to upload data in an HTTP Body -@POST("createIssue") -fun upload(@Body issue: Issue) + * ``` + * @POST("createIssue") + * fun upload(@Body issue: Issue) + * ``` */ @Target(AnnotationTarget.VALUE_PARAMETER) annotation class Body \ No newline at end of file diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/DELETE.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/DELETE.kt index c0bf65581..2a409816a 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/DELETE.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/DELETE.kt @@ -1,7 +1,13 @@ package de.jensklingenberg.ktorfit.http /** Make a DELETE request. + * + * ``` + * @DELETE("deleteIssue") + * fun deleteIssue(@Query("id") id: String) + * ``` * @param value relative url path, if empty, you need to have a parameter with [Url] - * */ + * + */ @Target(AnnotationTarget.FUNCTION) annotation class DELETE(val value: String = "") \ No newline at end of file diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Field.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Field.kt index 90ba8ff5c..7f1d75b4d 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Field.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Field.kt @@ -5,7 +5,6 @@ package de.jensklingenberg.ktorfit.http * Needs to be used in combination with [FormUrlEncoded] * @param value The default value will be replaced with the name of the parameter that is annotated. * @param encoded true means that this value is already URL encoded and will not be encoded again - * @see FormUrlEncoded * @see FieldMap */ diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/FieldMap.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/FieldMap.kt index b34fec918..90a36d723 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/FieldMap.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/FieldMap.kt @@ -1,7 +1,7 @@ package de.jensklingenberg.ktorfit.http /** - * Needs to be used in combination with [FormUrlEncoded] + * Needs to be used in combination with [FormUrlEncoded] * @param encoded true means that this value is already URL encoded and will not be encoded again */ @Target(AnnotationTarget.VALUE_PARAMETER) diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/GET.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/GET.kt index e63b95f0e..81fbf542b 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/GET.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/GET.kt @@ -1,6 +1,10 @@ package de.jensklingenberg.ktorfit.http /** Make a GET request. + * ``` + * @GET("getIssue") + * fun getIssue(@Query("id") id: String) : Issue + * ``` * @param value relative url path, if empty, you need to have a parameter with [Url] * */ @Target(AnnotationTarget.FUNCTION) diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Header.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Header.kt index 3896664d7..c50200cc6 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Header.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Header.kt @@ -3,9 +3,10 @@ package de.jensklingenberg.ktorfit.http /** * Add a header to a request * - * @ GET("comments") - * - * suspend fun request( @ Header("Content-Type") name: String): List< Comment> + * ``` + * @GET("comments") + * suspend fun request( @Header("Content-Type") name: String): List + * ``` * * A request with request("Hello World") will have the header "Content-Type:Hello World" * header with null values will be ignored diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/HeaderMap.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/HeaderMap.kt index 204660448..f4896ba43 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/HeaderMap.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/HeaderMap.kt @@ -3,8 +3,10 @@ package de.jensklingenberg.ktorfit.http /** * Add headers to a request * - * @ GET("comments") - * suspend fun requestWithHeaders( @HeaderMap headerMap : Map): List + * ``` + * @GET("comments") + * suspend fun requestWithHeaders(@HeaderMap headerMap : Map): List + * ``` * * @see Headers * @see Header diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Headers.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Headers.kt index ef6b02ff5..673f8aec0 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Headers.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Headers.kt @@ -3,9 +3,11 @@ package de.jensklingenberg.ktorfit.http /** * Add headers to a request * + * ``` * @Headers("Accept: application/json","Content-Type: application/json") * @GET("comments") * suspend fun requestWithHeaders(): List + * ``` */ @Target(AnnotationTarget.FUNCTION) annotation class Headers(vararg val value: String) \ No newline at end of file diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Path.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Path.kt index d2b08b81e..fc4fc6e8f 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Path.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Path.kt @@ -10,10 +10,10 @@ package de.jensklingenberg.ktorfit.http *

Path parameters type may not be nullable. * * -


-@GET("post/{postId}")
-suspend fun getPosts(@Path("postId") postId: Int): List< Post>
-
+ * ``` + * @GET("post/{postId}") + * suspend fun getPosts(@Path("postId") postId: Int): List< Post> + * ``` */ @Target(AnnotationTarget.VALUE_PARAMETER) diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Query.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Query.kt index 7de1ed63d..c02f16473 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Query.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Query.kt @@ -4,18 +4,20 @@ package de.jensklingenberg.ktorfit.http /** * Used for query parameters * - * @ GET("comments") + * ``` + * @GET("comments") * suspend fun getCommentsById(@Query("postId") postId: String): List - * + * ``` * A request with getCommentsById(3) will result in the relative URL “comments?postId=3” * - * @ GET("comments") + * ``` + * @GET("comments") * suspend fun getCommentsById(@Query("postId") postId: List): List + * ``` * * A request with getCommentsById(listOf("3",null,"4")) will result in the relative URL “comments?postId=3&postId=4” * - * ===== - * @param value The default value will be replaced with the name of the parameter that is annotated.It is the key of the query parameter + * @param value The default value will be replaced with the name of the parameter that is annotated.It is the key of the query parameter. * null values are ignored * @param encoded true means that this value is already URL encoded and will not be encoded again */ diff --git a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Url.kt b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Url.kt index 3b1800b6f..ce31908a7 100644 --- a/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Url.kt +++ b/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktorfit/http/Url.kt @@ -1,14 +1,10 @@ package de.jensklingenberg.ktorfit.http - /** + * ``` + * @GET + * suspend fun request(@Url url: String): List * - - -@GET() - -suspend fun request(@Url url: String): List< Comment> - */ @Target(AnnotationTarget.VALUE_PARAMETER) annotation class Url \ No newline at end of file