Skip to content

Commit

Permalink
Allow nullable body type #424 (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso authored Sep 25, 2023
1 parent 2e45bd0 commit 249cdb3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
13 changes: 13 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All important changes of this project must be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

Unreleased
========================================

### Added

### Changed
- Allow nullable body type #424

### Deprecated
### Removed
### Fixed
### Security

1.7.0 - 2023-09-16
========================================
# Gradle plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class KtorfitError {
const val PART_MAP_PARAMETER_TYPE_MUST_BE_MAP = "@PartMap parameter type must be Map."
const val PART_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE = "Part parameter type may not be nullable"
const val PATH_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE = "Path parameter type may not be nullable"
const val BODY_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE = "Body parameter type may not be nullable"
const val API_DECLARATIONS_MUST_BE_INTERFACES = "API declarations must be interfaces."

const val PATH_CAN_ONLY_BE_USED_WITH_RELATIVE_URL_ON = "@Path can only be used with relative url on "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ fun KSValueParameter.getParamAnnotationList(logger: KSPLogger): List<ParameterAn
}

ksValueParameter.getBodyAnnotation()?.let {
if (ksValueParameter.type.resolve().isMarkedNullable) {
logger.error(KtorfitError.BODY_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE, ksValueParameter.type)
}
paramAnnos.add(it)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import de.jensklingenberg.ktorfit.http.Body
interface TestService {
@POST("user")
suspend fun test(@Body id: String): String
suspend fun test(@Body id: String?): String
}
"""
)
Expand Down

0 comments on commit 249cdb3

Please sign in to comment.