Skip to content

Non-required query parameters throw errors during parsing instead of returning nil #249

@tib

Description

@tib

Hi,

first of all I really like the updated version of the Swift OpenAPI tools (0.2.0). However I strongly believe that I discovered a runtime issue. Let me explain this through an example:

Imagine a basic GET endpoint with two optional query parameters, foo & bar, the type of those really doesn't matter to reproduce this issue. When you provide none of the query parameters (or all of them), the server responds just fine, but otherwise it'll throw the following error: "Cannot parse a value from a node with multiple values"

e.g.:

I suppose the problematic code is inside the Converter+Server.swift file (line 115). The getOptionalQueryItemAsURI function should return an optional value if the key does not exists in the query string, but right now the convert block will always throw an error. Maybe the decode call should be try? decoder.decode(...), I'm not 100% sure if this is the right way to solve this, but I'm happy to submit a PR with the fix if you need help solving the issue.

Many thanks in advance.

Metadata

Metadata

Assignees

Labels

area/runtimeAffects: the runtime library.kind/bugFeature doesn't work as expected.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions