autorest.typescript
autorest.typescript copied to clipboard
Client parameters not usable for headers or body
Global parameters under #/components/parameters are meant to be reusable between endpoints via references. Autorest states that these are created as properties on the client for this purpose.
They are for TypeScript, however these parameters are only used useable in the path or query. Client-Core does not resolve these properties before invoking the pipeline and the serializer policy does not have access to or use the client as a fallback object when serializing the headers or body:
https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client/src/serializationPolicy.ts#L75
The result is the global properties values are never used for the header or body, and an error will be thrown if they were required.
This seems like a bug in client-core however that repo seems more focused on SDK bugs..
@xirzec @joheredi I think this is related to complex object type parameters being used in path and query, do you think we should support this in the ts emitter at least ? There's a similar ask from another customer before https://github.com/Azure/autorest.typescript/issues/2071
I'm currently working around this by subclassing the generated client and injecting the client parameters into the options object.