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

Array<Long> is not supported in query parameters #190

Closed
plapinsc opened this issue Feb 25, 2019 · 11 comments
Closed

Array<Long> is not supported in query parameters #190

plapinsc opened this issue Feb 25, 2019 · 11 comments
Labels
bug Unexpected behaviour for functionality that either was intended to work, or has worked in the past good first issue Does not require deep knowledge of the codebase and is easily testable help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought

Comments

@plapinsc
Copy link

plapinsc commented Feb 25, 2019

The following swagger definition:

    /WTF:
    get:
      operationId: "wtf"
      produces:
      - "application/json"
      parameters:
      - name: "id"
        in: "query"
        required: false
        type: "array"
        items:
          type: "integer"
          format: "int64"
        collectionFormat: "multi"
      responses:
        200:
          description: "successful operation"

generates a method with Iterable[String] input parameters instead of Iterable[Long]:
def wtf(respond: Resource.wtfResponse.type)(id: Option[Iterable[String]] = None): scala.concurrent.Future[Resource.wtfResponse]

the expected result is:
def wtf(respond: Resource.wtfResponse.type)(id: Option[Iterable[Long]] = None): scala.concurrent.Future[Resource.wtfResponse]

To quickly mitigate the issue, I wanted to implement it with String and parse long by myself, but:
#184

@plapinsc
Copy link
Author

Quick workaround: x-scala-type: "Iterable[Long]" seems to be working...

@rtfpessoa
Copy link
Contributor

@blast-hardcheese if I wanted to fix this where should I start looking?

@blast-hardcheese
Copy link
Member

@plapinsc Which version of guardrail was this happening on?

@rtfpessoa Depending on the answer, likely propMeta.

That being said, this got upended in 0.44.0 due to the switch to OpenAPI 3.x; to save yourself some effort, I'd check to make sure this is still broken in master (or with what's in #192, as that'll be reviewed and merged at some point this week).

The easiest way to test this would be to just modify modules/sample/src/main/resources/server1.yaml and run runtimeSuite in sbt, examining the generated result in modules/sample-*

@plapinsc
Copy link
Author

Our guardrail version is: 0.43.0

@rtfpessoa
Copy link
Contributor

At least a handful of versions before and including 0.44.0 have this problem.
Will try to check master.

@rtfpessoa
Copy link
Contributor

@blast-hardcheese seems like this still happens in 0.45.1 will try to look at your suggestion when I get some time.

@blast-hardcheese
Copy link
Member

Excellent! Feel free to follow up here if things are not going as you expect, I may be able to dig up some more pointers

@blast-hardcheese blast-hardcheese added bug Unexpected behaviour for functionality that either was intended to work, or has worked in the past help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought good first issue Does not require deep knowledge of the codebase and is easily testable labels Mar 31, 2019
@rtfpessoa
Copy link
Contributor

@blast-hardcheese tried to look into this today but never had to work with a free codebase and following the flow seems quite hard to grasp.
Do you have any other ideas where it might be loosing the initial read value of ("integer", "int64") to "string"?

The only things I was able to check was that the initial array seems fine, but then when propMeta is invoked the items type change to string somehow.

@blast-hardcheese
Copy link
Member

A passable tool for debugging local issues is to ~cli scala --client --specPath modules/sample/src/main/resources/alias.yaml --outputPath modules/sample-akkaHttp/target/generated --packageName alias.client.akkaHttp --framework akka-http in the sbt console, as well as () = println(...) inside for comprehensions to track down where values are doing different things than what you expect.

Narrowing it down to propMeta is not at all surprising, but figuring out exactly what's wrong will require runtime analysis, as it's likely something like ArraySchema { items = ObjectSchema { schema = LongSchema {} } } or similar coming out of the swagger-parser data model that we are not correctly analyzing and representing in our generated code.

@blast-hardcheese
Copy link
Member

#1407 resolves this

@blast-hardcheese
Copy link
Member

Pardon for the delay here, this is now resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour for functionality that either was intended to work, or has worked in the past good first issue Does not require deep knowledge of the codebase and is easily testable help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought
Projects
None yet
Development

No branches or pull requests

3 participants