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

Multipart explicit parts #3342

Merged
merged 47 commits into from
Jun 3, 2024

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented May 13, 2024

resolve #3046 Playground

Add the following:

  • @multipartBody decorator
  • File type
  • HttpPart<Type, Options> type

Had to do a decent amount of refactoring to be able to reuse the body parsing, this result in a much cleaner resolution of the body and other metadata properties across request, response and metadata.

The way it works now is instead of calling gatherMetadata that would just get the properties that are metadata but also ones with @body and @bodyRoot we now call a resolveHtpProperties, this does the same resolution in term of filtering properties but it also figure out what is the kind of property in the concept of http(header, query, body, etc.) this leaves the error resolution to this function for duplicate annotations.
What is nice is now we don't need to keep asking oh is this a query or a header or a body we can just check the kind of HttpProperty

also resolve #1311

@timotheeguerin timotheeguerin changed the title Feature/multipart v2 Multipart explicit parts May 13, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented May 13, 2024

All changed packages have been documented.

  • @typespec/http
  • @typespec/openapi3
  • @typespec/rest
Show changes

@typespec/rest - internal ✏️

@typespec/http - feature ✏️

Add new multipart handling. Using @multipartBody with HttpPart<Type, Options>. See [multipart docs] for more information https://typespec.io/docs/next/libraries/http/multipart,> ,> tsp,> op upload(@header contentType: "multipart/mixed", @multipartBody body: {,> name: HttpPart<string>;,> avatar: HttpPart<bytes>[];,> }): void;,>

@typespec/openapi3 - fix ✏️

Add support for new multipart constructs in http library

@timotheeguerin timotheeguerin marked this pull request as ready for review May 14, 2024 23:00
@azure-sdk
Copy link
Collaborator

You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/3342/

Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/prs/3342/

@markcowl
Copy link
Contributor

@timotheeguerin What are our plans for moving support for this into typespec-autorest?

@timotheeguerin
Copy link
Member Author

@timotheeguerin What are our plans for moving support for this into typespec-autorest?

Need to make a follow up PR, though autorest support will be much more limited

Copy link
Contributor

@markcowl markcowl left a comment

Choose a reason for hiding this comment

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

A few questions. Also, is there an uptake PR for typespec-azure, and can we look at the impact on the azure-rest-api-specs repo before merging?

packages/http/src/http-property.ts Show resolved Hide resolved
packages/http/src/http-property.ts Outdated Show resolved Hide resolved
packages/http/src/http-property.ts Outdated Show resolved Hide resolved
packages/http/src/types.ts Show resolved Hide resolved
packages/http/src/types.ts Outdated Show resolved Hide resolved
@timotheeguerin
Copy link
Member Author

A few questions. Also, is there an uptake PR for typespec-azure, and can we look at the impact on the azure-rest-api-specs repo before merging?

I do not but this doesn't affect the existing implicit multipart (if it did it would be a bug)

typespec autorest PR Azure/typespec-azure#902

@timotheeguerin timotheeguerin added this pull request to the merge queue Jun 3, 2024
Merged via the queue into microsoft:main with commit 40df1ec Jun 3, 2024
21 checks passed
@timotheeguerin timotheeguerin deleted the feature/multipart-v2 branch June 3, 2024 22:23
github-merge-queue bot pushed a commit to Azure/typespec-azure that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for explicit HTTP parts Move content type default resolution to rest library
4 participants