-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve #3046 [Playground](https://cadlplayground.z22.web.core.windows.net/prs/3342/) 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
- Loading branch information
1 parent
75f407c
commit 40df1ec
Showing
37 changed files
with
1,773 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
changeKind: internal | ||
packages: | ||
- "@typespec/rest" | ||
--- | ||
|
15 changes: 15 additions & 0 deletions
15
.chronus/changes/feature-multipart-v2-2024-4-14-22-58-52.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking | ||
changeKind: feature | ||
packages: | ||
- "@typespec/http" | ||
--- | ||
|
||
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; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking | ||
changeKind: fix | ||
packages: | ||
- "@typespec/openapi3" | ||
--- | ||
|
||
Add support for new multipart constructs in http library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import type { DecoratorContext, Model } from "@typespec/compiler"; | ||
import type { DecoratorContext, Model, Type } from "@typespec/compiler"; | ||
|
||
export type PlainDataDecorator = (context: DecoratorContext, target: Model) => void; | ||
|
||
export type HttpFileDecorator = (context: DecoratorContext, target: Model) => void; | ||
|
||
export type HttpPartDecorator = ( | ||
context: DecoratorContext, | ||
target: Model, | ||
type: Type, | ||
options: unknown | ||
) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "../dist/src/private.decorators.js"; | ||
|
||
/** | ||
* Private decorators. Those are meant for internal use inside Http types only. | ||
*/ | ||
namespace TypeSpec.Http.Private; | ||
|
||
extern dec plainData(target: TypeSpec.Reflection.Model); | ||
extern dec httpFile(target: TypeSpec.Reflection.Model); | ||
extern dec httpPart( | ||
target: TypeSpec.Reflection.Model, | ||
type: unknown, | ||
options: valueof HttpPartOptions | ||
); |
Oops, something went wrong.