Skip to content

Update uri decoder for non encoded comma strings #52

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

Merged

Conversation

bfrearson
Copy link
Contributor

Motivation

Makes decoding of non-percent encoded strings containing commas more permissive as per discussion in 278. This is not strictly necessary to adhere to the Openapi spec, but encompasses header values that are not percent encoded.

Modifications

Update the simple unexploded decoder to return a single string of comma separated values.

Result

Simple, unexploded nodes containing commas should be decoded correctly. e.g. foo, bar should be a single string, rather than an array.

Test Plan

Add tests for non percent encoded comma separated strings and percent encoded strings for additional coverage.

Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@czechboy0
Copy link
Contributor

@swift-server-bot test this please

@czechboy0 czechboy0 enabled auto-merge (squash) September 18, 2023 13:15
@czechboy0 czechboy0 disabled auto-merge September 18, 2023 13:15
@czechboy0
Copy link
Contributor

@bfrearson Please run ./scripts/soundness.sh and reformat the code, otherwise lgtm!

@bfrearson
Copy link
Contributor Author

Hopefully all ready to go now!

@czechboy0
Copy link
Contributor

@swift-server-bot add to allowlist

@czechboy0
Copy link
Contributor

@bfrearson the soundness check is still failing, can you check the CI output why?

@bfrearson
Copy link
Contributor Author

Looks to be an issue with swift-format:

** ✅ Found no files with missing license header.
** Running /code/scripts/run-swift-format.sh...
Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Client.swift:15:17: warning: [Spacing] remove 1 space
Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift:15:17: warning: [Spacing] remove 1 space
Tests/OpenAPIRuntimeTests/Interface/Test_UniversalServer.swift:15:17: warning: [Spacing] remove 1 space
Tests/OpenAPIRuntimeTests/Deprecated/Test_Deprecated.swift:15:17: warning: [Spacing] remove 1 space
Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Server.swift:15:17: warning: [Spacing] remove 1 space
Tests/OpenAPIRuntimeTests/URICoder/Test_URICodingRoundtrip.swift:15:17: warning: [Spacing] remove 1 space
** ERROR: ❌ Running swift-format produced errors.

  To fix, run the following command:

    % swift-format format --parallel --recursive --in-place Sources Tests
  
** ERROR: ❌ 1 soundness check(s) failed.
1
Build step 'Execute shell' marked build as failure
$ ssh-agent -k

I've run the suggested command locally and there's no changes though. Will take a close look at it tomorrow

@czechboy0
Copy link
Contributor

Might be the version of swift-format? We clone it from main in CI I believe.

@czechboy0
Copy link
Contributor

Actually likely the opposite, we clone the 508.0.0 tag, so you might be using a newer one: https://github.com/apple/swift-openapi-generator/blob/main/docker/Dockerfile

@bfrearson
Copy link
Contributor Author

yep that was it!

@czechboy0 czechboy0 merged commit 5f7e7ee into apple:main Sep 19, 2023
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Sep 19, 2023
@bfrearson bfrearson deleted the update-URIDecoder-for-non-encoded-comma-strings branch September 19, 2023 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants