-
Notifications
You must be signed in to change notification settings - Fork 243
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
Use value syntax for @header
, and add explode option
#6130
base: main
Are you sure you want to change the base?
Conversation
All changed packages have been documented.
|
@@ -67,37 +66,37 @@ export const namespace = "TypeSpec.Http"; | |||
export const $header: HeaderDecorator = ( | |||
context: DecoratorContext, | |||
entity: ModelProperty, | |||
headerNameOrOptions?: StringLiteral | Type, | |||
headerNameOrOptions, | |||
) => { | |||
const options: HeaderFieldOptions = { | |||
type: "header", | |||
name: entity.name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), | |||
}; | |||
if (headerNameOrOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we also need to deprecate format
You can try these changes here
|
@header({ | ||
format: "csv", | ||
}) | ||
@header(#{ format: "csv" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this is actually used in any Azure specs. @header
isn't called with options in any typespec file in the azure specs repo. I also wrote a regex to look for any header parameter of type array or object, and came up with 0 hits in the azure specs repo.
What we want is for csv
to be the default behavior here, but I'm not sure what work is needed on our emitters to make that the case yet.
Fixes #4114
One question is whether to add a new http-specs test for the explode scenarios as part of this PR. Currently there aren't any specs for headers defined as objects - I presume since swagger doesn't allow it.
Related typespec-azure PR: Azure/typespec-azure#2257