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

Ensure that retrofit body is not nullable #20

Merged
merged 1 commit into from
Mar 13, 2019

Conversation

macisamuele
Copy link
Collaborator

During some internal use of the plugin we did noticed that specs that allow a body parameter to be optional are converted to something similar to

  @Headers(
    "X-Operation-ID: operation_id"
  )
  @POST("/path")
  fun postBodyOptional(
    @retrofit2.http.Body  myBodyProp: MyBodyProp?
  ): Single<XnullableTypeResponses>

Due to some retrofit limitation/design choices it's not possible to pass null as body (retrofit will have issues on determining the content-type). More information are available on square/retrofit#1488

There are multiple possible approaches to address this issues on the codegen and few of them require some code duplication.

The objective of this PR is just to make sure that the body will not marked as nullable, so we're basically ignoring the fact that body is an optional parameter.

Copy link
Collaborator

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@cortinico cortinico merged commit 74d2a2b into Yelp:master Mar 13, 2019
@macisamuele macisamuele deleted the maci-body-cannot-be-optional branch March 13, 2019 09:15
@cortinico cortinico added this to the 1.1.0 milestone Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants