Autorest: Content-Type header shouldn't be synthesized when an explicit one exists.

Created on 23 Feb 2021  路  13Comments  路  Source: Azure/autorest

If the operation already has a Content-Type parameter defined we shouldn't add another one.

Modeler bug

All 13 comments

I think this is an invalid swagger

Note: Header parameters named Accept, Content-Type and Authorization are not allowed. To describe these headers, use the corresponding OpenAPI keywords:

from https://swagger.io/docs/specification/describing-parameters/

Yeah, but they need to be able to set the multipart boundary that contains a dynamically generated part:

Content-Type: multipart/mixed; boundary=batch_5cf6a349-1eec-4fe4-a183-5aca29153062

Hhm, I see, so is that something they expect the user of the SDK to set or the generator is automatically going to generate an UUID for the boundary for them?

Wondering if the best option here is to allow specifying Content-Type for:

  • All requests
  • Multipart/mixed only
  • Somehow have a way to specify the boundary for multipart request only

Hhm, I see, so is that something they expect the user of the SDK to set or the generator is automatically going to generate an UUID for the boundary for them?

The internal machinery of Storage.Blobs.Batch SDK formats the body and generates the boundary as part of that process.

We are not filtering or throwing because of this "invalid" parameter. I think it's the case where there is no reason to overcomplicate things. We should just disable the "Content-Type" synthesis logic when there is already a parameter like that and avoid having duplicates.

fair enough

@pakrym can you confirm this resolve the problem https://github.com/Azure/autorest/pull/3916#issuecomment-784384589

The tinyurl versions do not seem to work.

>autorest --version:https://tinyurl.com/y7ogpxtf --use:https://tinyurl.com/ycuwzbxd --csharp https://github.com/Azure/azure-rest-api-specs/blob/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-06-12/blob.json

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.1; node: v15.8.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Failure:
Error: Unable to find a valid AutoRest core package '@autorest/core' @ 'https://tinyurl.com/y7ogpxtf'.
Error: Unable to find a valid AutoRest core package '@autorest/core' @ 'https://tinyurl.com/y7ogpxtf'.
    at Object.selectVersion (C:\Users\pakrym\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts-src_coloring_ts.js:303:23)
    at async main (C:\Users\pakrym\AppData\Roaming\npm\node_modules\autorest\dist\app.js:213:31)

hhm intresting, never had the tinyurl not work before. There is another build on its way

@pakrym this one should work https://github.com/Azure/autorest/pull/3916#issuecomment-784425882

 autorest --version:https://tinyurl.com/ya7qay4q --use:https://tinyurl.com/yalhx8za  --csharp --input-file:https://github.com/Azure/azure-rest-api-specs/blob/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-06-12/blob.json

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.1; node: v15.8.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\pakrym\.autorest\@[email protected]\node_modules\@autorest\core\dist' (3.0.6375)
INFORMATION: > Loading AutoRest extension '@autorest/modelerfour' (https://tinyurl.com/yalhx8za->4.17.0)
INFORMATION: > Loading AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20210219.1)

it looks like the M4 version is not being overriden.

Did you run autorest --reset before? I think we could resolve this annoyance by adding a suffix(with the commit id maybe) to the version build in a pr.

Works 馃憤

Was this page helpful?
0 / 5 - 0 ratings