guardrail-dev / guardrail-dev/guardrail

Guardrail generates invalid Scala method when operation has two parameters from different sources but with the same name

Open
#175 1 comment 0 reactions 0 assignees View on GitHub
bug help wanted scala
Dominant language
Scala
Stars
541
Forks
138
PR merge metrics
No merged PRs in 30d

Description

Hi, I have an existing server that for a certain path, receives a query parameter and a multi-part form parameter both with the same name (let's call it "foo"), plus other parameters. The relevant part in the swagger spec for that would be:

```yaml
/some/path:
post:
operationId: "theOperation"
produces:
- "application/json"
parameters:
- name: "foo"
in: "formData"
required: false
type: "string"
- name: "foo"
in: "query"
required: false
type: "string"
enum:
- "FIRST"
- "SECOND"
- "THIRD"
```

I believe that's valid swagger 2.0.

Guardrail generates the following definition for it:

```scala
def theOperation(respond: Resource.theOperationResponse.type)(foo: Option[String] = None, foo: Option[String] = None, ...): scala.concurrent.Future[Resource.theOperationResponse]
```

This fails to compile because Scala methods can't have two parameters with the same name.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.