Azure / autorest

OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
MIT License
4.63k stars 739 forks source link

[openapi to tsp] Fix `accept` header logic #4941

Open catalinaperalta opened 7 months ago

catalinaperalta commented 7 months ago

Given the following swagger definition:

        "produces": [
          "application/vnd.microsoft.appconfig.kv+json",
          "application/problem+json"
        ],

The converter outputs the following typespec code where all of the supported content types are bundled into 1 string:

accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json";

The correct code should represent each content type individually:

accept: "application/vnd.microsoft.appconfig.kv+json" | "application/problem+json";

cc @joheredi

pshao25 commented 3 months ago

@catalinaperalta could you show me the full swagger so that I could know which template we should use for this operation. I assume it might be ResourceRead, which seems lack of ability to override the content type. So I'm going to ask TSP team. Before that I need to know the full story.

catalinaperalta commented 3 months ago

This spec was converted to typespec a few months ago so you'll have to look at an older version of the swagger, linking it here: https://github.com/Azure/azure-rest-api-specs/blob/c1af3ab8e803da2f40fc90217a6d023bc13b677f/specification/appconfiguration/data-plane/Microsoft.AppConfiguration/stable/2023-11-01/appconfiguration.json

IIRC you'll be able to see that there are several operations with multiple produces statements it wasnt just a 1 time occurrence in the converted code.