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

[Runtime] Async bodies + swift-http-types adoption #47

Merged
merged 60 commits into from
Sep 27, 2023

Conversation

czechboy0
Copy link
Contributor

@czechboy0 czechboy0 commented Sep 5, 2023

Motivation

Runtime changes of the approved proposals apple/swift-openapi-generator#255 and apple/swift-openapi-generator#254.

Blockers of merging this

  • 1.0 of swift-http-types

Modifications

⚠️ Contains breaking changes, this will land to main and then 0.3.0 will be tagged, so not backwards compatible with 0.2.0.

  • add a dependency on https://github.com/apple/swift-http-types
  • remove our currency types Request, Response, HeaderField
  • replace them with the types provided by HTTPTypes
  • remove ...AsString and the whole string-based serialization strategy, which was only ever used by bodies, but with streaming, we can't safely stream string chunks, only byte chunks, so we instead provide utils on HTTPBody to create it from string, and to collect it into a string. This means that the underlying type for the text/plain content type is now HTTPBody (a sequence of byte chunks) as opposed to String
  • adapted Converter extensions to work with the new types
  • added some internal utils for working with the query section of a path, as HTTPTypes doesn't provide that, the path property contains both the path and the query components (in setEscapedQueryItem)
  • adapted error types
  • adapted printing of request/response types, now no bytes of the body are printed, as they cannot be assumed to be consumable more than once
  • adjusted the transport and middleware protocols, as described in the proposal
  • removed the queryParameters property from ServerRequestMetadata, as now we parse the full query ourselves, instead of relying on the server transport to do it for us
  • removed RouterPathComponent as now we pass the full path string to the server transport in the register function, allowing transport with more flexible routers to handle mixed path components, e.g. /foo/{bar}.zip.
  • introduced HTTPBody, as described by the proposal
  • adjusted UniversalClient and UniversalServer
  • moved from String to Substring in a few types, to allow more passthrough of parsed string data without copying

Result

SOAR-0004 and SOAR-0005 implemented.

Test Plan

Introduced and adjusted tests for all of the above.

.swift-format Show resolved Hide resolved
Package.swift Outdated Show resolved Hide resolved
@czechboy0 czechboy0 changed the title [WIP] Async bodies + swift-http-types adoption [WIP] [Runtime] Async bodies + swift-http-types adoption Sep 7, 2023
czechboy0 and others added 19 commits September 18, 2023 19:09
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
@czechboy0
Copy link
Contributor Author

Ok, applied most of your feedback, @simonjbeaumont, and left some questions asking for clarification.

Copy link
Collaborator

@simonjbeaumont simonjbeaumont 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! Really nice work. Great attention to detail with docs and tests.

@czechboy0 czechboy0 merged commit 1eaf236 into apple:main Sep 27, 2023
@czechboy0 czechboy0 deleted the hd-adopt-http-types branch September 27, 2023 07:19
@czechboy0 czechboy0 added the 🆕 semver/minor Adds new public API. label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
3 participants