Skip to content

[Scala] Async helper does not account for optional bodies #7272

@gmarz

Description

@gmarz
Description

RequestWriter is typed to the body parameter, but does not account for the case where a body is not required, and thus is of type Option[T].

For instance:

def someOperation(body: SomeBody)(implicit reader: ClientResponseReader[SomeResponse], writer: RequestWriter[SomeBody)

is fine, but if if body above is Option[SomeBody] (because it's not required), then the following is generated:

def someOperation(body: Option[SomeBody] = None)(implicit reader: ClientResponseReader[SomeResponse], writer: RequestWriter[SomeBody)

which causes an error at this line because writer.write() is expecting SomeBody when it's actually Option[SomeBody].

Swagger-codegen version

2.3.0

Swagger declaration file content or url

https://download.elasticsearch.org/cloud/1.1/elastic-cloud-enterprise-API-swagger.json

Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i https://download.elasticsearch.org/cloud/1.1/elastic-cloud-enterprise-API-swagger.json \
  -l scala 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions