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

Request uses incorrect body instead of asQuery #179

Open
mikakruschel opened this issue Dec 30, 2022 · 1 comment
Open

Request uses incorrect body instead of asQuery #179

mikakruschel opened this issue Dec 30, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mikakruschel
Copy link

Hi, I'm working on a library for DeepL (it's amazing to see the capabilities of CreateAPI) and while doing so I encountered a bug that even seams to be present in the tests (https://github.com/CreateAPI/CreateAPI/blob/da8730b23dab769414229bb386b3dcc2a77d6e42/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift).

The problem is that CreateAPI generates a POST request using URLQueryEncoder.encode(body).percentEncodedQuery as the body, but it should be using the asQuery property instead. This causes the request to be incorrect because URLQueryEncoder.encode(body).percentEncodedQuery uses camelCase for the property names, but the expected format is snake_case, which asQuery correctly uses.

In the test the property pattern_without_delimiter incorrectly would be called patternWithoutDelimiter in the POST request.

So instead of

Request(path: path, method: "POST", body: body.map(URLQueryEncoder.encode)?.percentEncodedQuery, id: "testEndpointParameters")

I would expect:

 Request(path: path, method: "POST", query: body?.asQuery, id: "testEndpointParameters") 
@liamnichols liamnichols added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers and removed help wanted Extra attention is needed labels Feb 21, 2023
@mikepitre
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants