Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nullable body type #424 #425

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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