From f18caf0a80a77907fac3fdd72f9264ea5bec2c62 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 12 Mar 2024 23:47:57 -0700 Subject: [PATCH 1/7] updating autorest to emit response headers in lexicographic order --- .../typespec-autorest/2022-08-31/openapi.json | 52 +++++------ .../openapi3/openapi.2022-08-31.yaml | 60 ++++++------- .../typespec-autorest/2022-08-31/openapi.json | 36 ++++---- .../openapi3/openapi.2022-08-31.yaml | 40 ++++----- .../typespec-autorest/2022-08-31/openapi.json | 20 ++--- .../typespec-autorest/2023-02-07/openapi.json | 52 +++++------ .../openapi3/openapi.2022-08-31.yaml | 24 ++--- .../openapi3/openapi.2023-02-07.yaml | 60 ++++++------- .../typespec-autorest/2022-08-31/openapi.json | 76 ++++++++-------- .../openapi3/openapi.2022-08-31.yaml | 90 +++++++++---------- .../typespec-autorest/openapi.json | 44 ++++----- .../appconfig/@typespec/openapi3/openapi.yaml | 48 +++++----- .../typespec-autorest/openapi.json | 40 ++++----- .../2021-10-01-preview/openapi.json | 16 ++-- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../2021-06-13-preview/openapi.json | 16 ++-- .../2022-04-30-preview/openapi.json | 16 ++-- .../typespec-autorest/openapi.json | 16 ++-- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 16 ++-- .../typespec-autorest/openapi.json | 40 ++++----- .../typespec-autorest/openapi.json | 64 ++++++------- .../2023-08-01-preview/openapi.json | 8 +- .../2023-11-01-preview/openapi.json | 8 +- .../typespec-autorest/openapi.json | 8 +- .../typespec-autorest/openapi.json | 32 +++---- .../typespec-autorest/openapi.json | 40 ++++----- packages/typespec-autorest/src/openapi.ts | 2 +- .../test/response-headers-order.test.ts | 40 +++++++++ 34 files changed, 530 insertions(+), 490 deletions(-) create mode 100644 packages/typespec-autorest/test/response-headers-order.test.ts diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 5d1caeae47..ee69be2c5e 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -179,6 +179,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -203,10 +207,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -220,6 +220,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -244,10 +248,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -674,6 +674,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -698,19 +707,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -720,6 +720,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -744,19 +753,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml index 38bbd1046a..952b637f51 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -388,27 +388,27 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -416,27 +416,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 9bc882df32..8e2b05f674 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -182,6 +182,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -206,19 +215,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -228,6 +228,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -252,19 +261,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml index ca981503e5..760c65bb1d 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml @@ -57,27 +57,27 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -85,27 +85,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json index ae8877d224..69add89f3b 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -598,6 +598,11 @@ "$ref": "#/definitions/Widget" }, "headers": { + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -626,11 +631,6 @@ "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -640,6 +640,11 @@ "$ref": "#/definitions/Widget" }, "headers": { + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -668,11 +673,6 @@ "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json index 5996ef3418..a7215dde33 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json @@ -179,6 +179,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -203,10 +207,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -220,6 +220,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -244,10 +248,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -674,6 +674,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -698,19 +707,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -720,6 +720,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -744,19 +753,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml index 688b6e0ded..1094184b25 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml @@ -357,6 +357,12 @@ paths: '200': description: The request has succeeded. headers: + Operation-Location: + required: true + description: The location for monitoring the operation state. + schema: + type: string + format: uri Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. @@ -367,12 +373,6 @@ paths: description: An opaque, globally-unique, client-generated string identifier for the request. schema: $ref: '#/components/schemas/Azure.Core.uuid' - Operation-Location: - required: true - description: The location for monitoring the operation state. - schema: - type: string - format: uri content: application/json: schema: @@ -380,6 +380,12 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + Operation-Location: + required: true + description: The location for monitoring the operation state. + schema: + type: string + format: uri Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. @@ -390,12 +396,6 @@ paths: description: An opaque, globally-unique, client-generated string identifier for the request. schema: $ref: '#/components/schemas/Azure.Core.uuid' - Operation-Location: - required: true - description: The location for monitoring the operation state. - schema: - type: string - format: uri content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml index 26d533be6d..99b48e3284 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -388,27 +388,27 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -416,27 +416,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 4133a06cce..7e1d7cbb02 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -179,6 +179,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -203,10 +207,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -220,6 +220,10 @@ "$ref": "#/definitions/Manufacturer" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -244,10 +248,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -674,6 +674,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -698,19 +707,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -720,6 +720,15 @@ "$ref": "#/definitions/Widget" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -744,19 +753,10 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", "description": "An opaque, globally-unique, client-generated string identifier for the request." - }, - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." } } }, @@ -1127,6 +1127,10 @@ "$ref": "#/definitions/WidgetAnalytics" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -1151,10 +1155,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -1168,6 +1168,10 @@ "$ref": "#/definitions/WidgetAnalytics" }, "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Repeatability-Result": { "type": "string", "description": "Indicates whether the repeatable request was accepted or rejected.", @@ -1192,10 +1196,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", @@ -1385,6 +1385,10 @@ "201": { "description": "The request has succeeded and a new resource has been created as a result.", "headers": { + "ETag": { + "type": "string", + "description": "The entity tag for the response." + }, "Location": { "type": "string", "format": "uri", @@ -1414,10 +1418,6 @@ ] } }, - "ETag": { - "type": "string", - "description": "The entity tag for the response." - }, "x-ms-client-request-id": { "type": "string", "format": "uuid", diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index fc93bd852d..ec438ca44d 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -440,27 +440,27 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -468,27 +468,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -697,16 +697,16 @@ paths: '200': description: The request has succeeded. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -719,16 +719,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -837,6 +837,11 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + ETag: + required: false + description: The entity tag for the response. + schema: + type: string Location: required: true schema: @@ -847,11 +852,6 @@ paths: description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' - ETag: - required: false - description: The entity tag for the response. - schema: - type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json index 33dd5aa703..2cfce7dc9a 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json @@ -322,16 +322,16 @@ "$ref": "#/definitions/KeyValue" }, "headers": { - "sync-token": { - "type": "string", - "description": "Used to guarantee real-time consistency between requests." + "e-tag": { + "type": "string" }, "last-modified": { "type": "string", "format": "date" }, - "e-tag": { - "type": "string" + "sync-token": { + "type": "string", + "description": "Used to guarantee real-time consistency between requests." } } }, @@ -388,16 +388,16 @@ "$ref": "#/definitions/KeyValue" }, "headers": { - "sync-token": { - "type": "string", - "description": "Used to guarantee real-time consistency between requests." + "e-tag": { + "type": "string" }, "last-modified": { "type": "string", "format": "date" }, - "e-tag": { - "type": "string" + "sync-token": { + "type": "string", + "description": "Used to guarantee real-time consistency between requests." } } }, @@ -458,16 +458,16 @@ "$ref": "#/definitions/KeyValue" }, "headers": { - "sync-token": { - "type": "string", - "description": "Used to guarantee real-time consistency between requests." + "e-tag": { + "type": "string" }, "last-modified": { "type": "string", "format": "date" }, - "e-tag": { - "type": "string" + "sync-token": { + "type": "string", + "description": "Used to guarantee real-time consistency between requests." } } }, @@ -515,12 +515,12 @@ "$ref": "#/definitions/KeyValue" }, "headers": { + "e-tag": { + "type": "string" + }, "sync-token": { "type": "string", "description": "Used to guarantee real-time consistency between requests." - }, - "e-tag": { - "type": "string" } } }, @@ -568,13 +568,13 @@ "200": { "description": "The request has succeeded.", "headers": { - "sync-token": { - "type": "string", - "description": "Used to guarantee real-time consistency between requests." - }, "last-modified": { "type": "string", "format": "date" + }, + "sync-token": { + "type": "string", + "description": "Used to guarantee real-time consistency between requests." } } }, diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml index f2cc5b088e..c1791ced6b 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml @@ -188,9 +188,8 @@ paths: '200': description: The request has succeeded. headers: - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string last-modified: @@ -198,8 +197,9 @@ paths: schema: type: string format: date - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string content: @@ -228,16 +228,16 @@ paths: '200': description: The request has succeeded. headers: - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. - schema: - type: string last-modified: required: true schema: type: string format: date + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. + schema: + type: string default: description: An unexpected error response. content: @@ -256,9 +256,8 @@ paths: '200': description: The request has succeeded. headers: - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string last-modified: @@ -266,8 +265,9 @@ paths: schema: type: string format: date - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string content: @@ -318,9 +318,8 @@ paths: '200': description: The request has succeeded. headers: - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string last-modified: @@ -328,8 +327,9 @@ paths: schema: type: string format: date - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string content: @@ -370,15 +370,15 @@ paths: '200': description: The request has succeeded. headers: + e-tag: + required: true + schema: + type: string sync-token: required: false description: Used to guarantee real-time consistency between requests. schema: type: string - e-tag: - required: true - schema: - type: string content: application/vnd.microsoft.appconfig.kv+json: schema: diff --git a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json index 8e7a96bd90..ece4695a69 100644 --- a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json @@ -267,14 +267,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -516,14 +516,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -866,14 +866,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1333,14 +1333,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1561,14 +1561,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/arm-scenarios/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/arm-scenarios/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 904f9a56c4..a4ab9e6e92 100644 --- a/packages/samples/test/output/azure/resource-manager/arm-scenarios/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/arm-scenarios/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -416,14 +416,14 @@ "202": { "description": "Resource operation accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -473,14 +473,14 @@ "202": { "description": "Resource operation accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/codesigning/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/codesigning/@azure-tools/typespec-autorest/openapi.json index 102b4e3c7a..f7401cff3d 100644 --- a/packages/samples/test/output/azure/resource-manager/codesigning/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/codesigning/@azure-tools/typespec-autorest/openapi.json @@ -340,14 +340,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json index 27de199ae0..4c23b612cd 100644 --- a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json @@ -337,14 +337,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/csharpattributetest/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/csharpattributetest/@azure-tools/typespec-autorest/openapi.json index 2c34bfd5de..ead904b37e 100644 --- a/packages/samples/test/output/azure/resource-manager/csharpattributetest/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/csharpattributetest/@azure-tools/typespec-autorest/openapi.json @@ -332,14 +332,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/customer-managed-keys/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/customer-managed-keys/@azure-tools/typespec-autorest/openapi.json index bf3d57bc21..39271ca1fc 100644 --- a/packages/samples/test/output/azure/resource-manager/customer-managed-keys/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/customer-managed-keys/@azure-tools/typespec-autorest/openapi.json @@ -330,14 +330,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/discriminatortest/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/discriminatortest/@azure-tools/typespec-autorest/openapi.json index 3451cfde71..b66833f9bd 100644 --- a/packages/samples/test/output/azure/resource-manager/discriminatortest/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/discriminatortest/@azure-tools/typespec-autorest/openapi.json @@ -337,14 +337,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2021-06-13-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2021-06-13-preview/openapi.json index 0fab89d28e..5d43f17dfd 100644 --- a/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2021-06-13-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2021-06-13-preview/openapi.json @@ -415,14 +415,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1033,14 +1033,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2022-04-30-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2022-04-30-preview/openapi.json index 045e37a5fd..8281ce3f09 100644 --- a/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2022-04-30-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/dynatrace/@azure-tools/typespec-autorest/2022-04-30-preview/openapi.json @@ -415,14 +415,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1033,14 +1033,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/envelopetest/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/envelopetest/@azure-tools/typespec-autorest/openapi.json index 8d6e901aa2..b8506e2c5b 100644 --- a/packages/samples/test/output/azure/resource-manager/envelopetest/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/envelopetest/@azure-tools/typespec-autorest/openapi.json @@ -369,14 +369,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -617,14 +617,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/liftr.confluent/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/liftr.confluent/@azure-tools/typespec-autorest/openapi.json index 401039b810..8be2e5eca8 100644 --- a/packages/samples/test/output/azure/resource-manager/liftr.confluent/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/liftr.confluent/@azure-tools/typespec-autorest/openapi.json @@ -409,14 +409,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/liftr.frs/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/liftr.frs/@azure-tools/typespec-autorest/openapi.json index f6fd413f2d..425a6cbb08 100644 --- a/packages/samples/test/output/azure/resource-manager/liftr.frs/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/liftr.frs/@azure-tools/typespec-autorest/openapi.json @@ -332,14 +332,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/liftr.playfab/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/liftr.playfab/@azure-tools/typespec-autorest/openapi.json index 1fabd48baf..aa27c9f54d 100644 --- a/packages/samples/test/output/azure/resource-manager/liftr.playfab/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/liftr.playfab/@azure-tools/typespec-autorest/openapi.json @@ -369,14 +369,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -617,14 +617,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/logz/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/logz/@azure-tools/typespec-autorest/openapi.json index f8cd277816..7a2cd0aef3 100644 --- a/packages/samples/test/output/azure/resource-manager/logz/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/logz/@azure-tools/typespec-autorest/openapi.json @@ -344,14 +344,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -572,14 +572,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -828,14 +828,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1155,14 +1155,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1383,14 +1383,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/operationsTest/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/operationsTest/@azure-tools/typespec-autorest/openapi.json index 3d22391d70..70cfc8dfb2 100644 --- a/packages/samples/test/output/azure/resource-manager/operationsTest/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/operationsTest/@azure-tools/typespec-autorest/openapi.json @@ -734,14 +734,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -950,14 +950,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1648,14 +1648,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1852,14 +1852,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -2397,14 +2397,14 @@ "202": { "description": "Resource operation accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -2475,14 +2475,14 @@ "202": { "description": "Resource operation accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -3397,14 +3397,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -3625,14 +3625,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json index 53f16522b6..0d68dd2161 100644 --- a/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json @@ -338,14 +338,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json index 7fc97b75af..00e4acdf5d 100644 --- a/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json @@ -338,14 +338,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/servicelinker/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/servicelinker/@azure-tools/typespec-autorest/openapi.json index 398d6584ee..1414db822c 100644 --- a/packages/samples/test/output/azure/resource-manager/servicelinker/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/servicelinker/@azure-tools/typespec-autorest/openapi.json @@ -252,14 +252,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/tagsUpdateTest/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/tagsUpdateTest/@azure-tools/typespec-autorest/openapi.json index e06c6b5e6d..ea0378d2db 100644 --- a/packages/samples/test/output/azure/resource-manager/tagsUpdateTest/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/tagsUpdateTest/@azure-tools/typespec-autorest/openapi.json @@ -425,14 +425,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -705,14 +705,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -973,14 +973,14 @@ "202": { "description": "Resource update request accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1038,14 +1038,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/samples/test/output/azure/resource-manager/tenantResource/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/tenantResource/@azure-tools/typespec-autorest/openapi.json index 2d1d3c3848..89d43e099e 100644 --- a/packages/samples/test/output/azure/resource-manager/tenantResource/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/tenantResource/@azure-tools/typespec-autorest/openapi.json @@ -264,14 +264,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -513,14 +513,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -717,14 +717,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1083,14 +1083,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -1352,14 +1352,14 @@ "202": { "description": "Resource deletion accepted.", "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, "Retry-After": { "type": "integer", "format": "int32", "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." - }, - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index b03e7354ac..2fe5aef57e 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -848,7 +848,7 @@ function createOAPIEmitter( for (const data of response.responses) { if (data.headers && Object.keys(data.headers).length > 0) { openapiResponse.headers ??= {}; - for (const [key, value] of Object.entries(data.headers)) { + for (const [key, value] of Object.entries(data.headers).sort()) { openapiResponse.headers[key] = getResponseHeader(value); } } diff --git a/packages/typespec-autorest/test/response-headers-order.test.ts b/packages/typespec-autorest/test/response-headers-order.test.ts new file mode 100644 index 0000000000..5d29952be9 --- /dev/null +++ b/packages/typespec-autorest/test/response-headers-order.test.ts @@ -0,0 +1,40 @@ +import { strictEqual } from "assert"; +import { describe, it } from "vitest"; +import { openApiFor } from "./test-host.js"; + +describe("typespec-autorest: response headers order", () => { + const headerDefinitions = ` + model A_Header { @header a : string }; + model B_Header { @header b : string }; + model C_Header { @header c : string }; + `; + it("header already in lexical order", async () => { + const res = await openApiFor( + ` + ${headerDefinitions} + model Headers { ...A_Header, ...B_Header, ...C_Header }; + + op read(): {@statusCode _: 200, content: string, headers: Headers}; + ` + ); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + }); + + it("header not in lexical order", async () => { + const res = await openApiFor( + ` + ${headerDefinitions} + model Headers { ...C_Header, ...A_Header, ...B_Header }; + + op read(): {@statusCode _: 200, content: string, headers: Headers}; + ` + ); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + }); +}); From ec9631969c1f6a95b03c30e83e278f320074d533 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 12 Mar 2024 23:50:23 -0700 Subject: [PATCH 2/7] Create azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md --- ...azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md diff --git a/.chronus/changes/azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md b/.chronus/changes/azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md new file mode 100644 index 0000000000..13b3779e1d --- /dev/null +++ b/.chronus/changes/azhang_fixResponseHeadersOrdering-2024-2-13-6-49-41.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-autorest" +--- + +updating autorest to emit response headers in lexicographic order From 9bae5b993552883b0e50c5f7ea2479bef3652254 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Wed, 13 Mar 2024 21:07:41 -0700 Subject: [PATCH 3/7] Updated with correct sorting configuration via schema --- .../openapi3/openapi.2022-08-31.yaml | 60 ++++++------- .../openapi3/openapi.2022-08-31.yaml | 40 ++++----- .../openapi3/openapi.2022-08-31.yaml | 24 ++--- .../openapi3/openapi.2023-02-07.yaml | 60 ++++++------- .../openapi3/openapi.2022-08-31.yaml | 90 +++++++++---------- .../appconfig/@typespec/openapi3/openapi.yaml | 48 +++++----- .../schema/autorest-openapi-schema.tsp | 1 - packages/typespec-autorest/src/openapi.ts | 2 +- 8 files changed, 162 insertions(+), 163 deletions(-) diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml index 952b637f51..38bbd1046a 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -388,27 +388,27 @@ paths: '200': description: The request has succeeded. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -416,27 +416,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml index 760c65bb1d..ca981503e5 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml @@ -57,27 +57,27 @@ paths: '200': description: The request has succeeded. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -85,27 +85,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml index 1094184b25..688b6e0ded 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml @@ -357,12 +357,6 @@ paths: '200': description: The request has succeeded. headers: - Operation-Location: - required: true - description: The location for monitoring the operation state. - schema: - type: string - format: uri Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. @@ -373,6 +367,12 @@ paths: description: An opaque, globally-unique, client-generated string identifier for the request. schema: $ref: '#/components/schemas/Azure.Core.uuid' + Operation-Location: + required: true + description: The location for monitoring the operation state. + schema: + type: string + format: uri content: application/json: schema: @@ -380,12 +380,6 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - Operation-Location: - required: true - description: The location for monitoring the operation state. - schema: - type: string - format: uri Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. @@ -396,6 +390,12 @@ paths: description: An opaque, globally-unique, client-generated string identifier for the request. schema: $ref: '#/components/schemas/Azure.Core.uuid' + Operation-Location: + required: true + description: The location for monitoring the operation state. + schema: + type: string + format: uri content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml index 99b48e3284..26d533be6d 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -388,27 +388,27 @@ paths: '200': description: The request has succeeded. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -416,27 +416,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index ec438ca44d..fc93bd852d 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -59,16 +59,16 @@ paths: '200': description: The request has succeeded. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -81,16 +81,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -440,27 +440,27 @@ paths: '200': description: The request has succeeded. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -468,27 +468,27 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: + Repeatability-Result: + required: false + description: Indicates whether the repeatable request was accepted or rejected. + schema: + $ref: '#/components/schemas/RepeatabilityResult' ETag: required: false description: The entity tag for the response. schema: type: string + x-ms-client-request-id: + required: false + description: An opaque, globally-unique, client-generated string identifier for the request. + schema: + $ref: '#/components/schemas/Azure.Core.uuid' Operation-Location: required: true description: The location for monitoring the operation state. schema: type: string format: uri - Repeatability-Result: - required: false - description: Indicates whether the repeatable request was accepted or rejected. - schema: - $ref: '#/components/schemas/RepeatabilityResult' - x-ms-client-request-id: - required: false - description: An opaque, globally-unique, client-generated string identifier for the request. - schema: - $ref: '#/components/schemas/Azure.Core.uuid' content: application/json: schema: @@ -697,16 +697,16 @@ paths: '200': description: The request has succeeded. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -719,16 +719,16 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Repeatability-Result: required: false description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. @@ -837,11 +837,6 @@ paths: '201': description: The request has succeeded and a new resource has been created as a result. headers: - ETag: - required: false - description: The entity tag for the response. - schema: - type: string Location: required: true schema: @@ -852,6 +847,11 @@ paths: description: Indicates whether the repeatable request was accepted or rejected. schema: $ref: '#/components/schemas/RepeatabilityResult' + ETag: + required: false + description: The entity tag for the response. + schema: + type: string x-ms-client-request-id: required: false description: An opaque, globally-unique, client-generated string identifier for the request. diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml index c1791ced6b..f2cc5b088e 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml @@ -188,8 +188,9 @@ paths: '200': description: The request has succeeded. headers: - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string last-modified: @@ -197,9 +198,8 @@ paths: schema: type: string format: date - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string content: @@ -228,16 +228,16 @@ paths: '200': description: The request has succeeded. headers: - last-modified: - required: true - schema: - type: string - format: date sync-token: required: false description: Used to guarantee real-time consistency between requests. schema: type: string + last-modified: + required: true + schema: + type: string + format: date default: description: An unexpected error response. content: @@ -256,8 +256,9 @@ paths: '200': description: The request has succeeded. headers: - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string last-modified: @@ -265,9 +266,8 @@ paths: schema: type: string format: date - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string content: @@ -318,8 +318,9 @@ paths: '200': description: The request has succeeded. headers: - e-tag: - required: true + sync-token: + required: false + description: Used to guarantee real-time consistency between requests. schema: type: string last-modified: @@ -327,9 +328,8 @@ paths: schema: type: string format: date - sync-token: - required: false - description: Used to guarantee real-time consistency between requests. + e-tag: + required: true schema: type: string content: @@ -370,15 +370,15 @@ paths: '200': description: The request has succeeded. headers: - e-tag: - required: true - schema: - type: string sync-token: required: false description: Used to guarantee real-time consistency between requests. schema: type: string + e-tag: + required: true + schema: + type: string content: application/vnd.microsoft.appconfig.kv+json: schema: diff --git a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp index b71f5f0ba2..d0d7a5adf8 100644 --- a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp +++ b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp @@ -303,7 +303,6 @@ model fileSchema { example?: unknown; } -@extension("x-ordering", Json<"keep">) model Headers is Record
; alias CollectionFormat = "csv" | "ssv" | "tsv" | "pipes"; diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index 2fe5aef57e..b03e7354ac 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -848,7 +848,7 @@ function createOAPIEmitter( for (const data of response.responses) { if (data.headers && Object.keys(data.headers).length > 0) { openapiResponse.headers ??= {}; - for (const [key, value] of Object.entries(data.headers).sort()) { + for (const [key, value] of Object.entries(data.headers)) { openapiResponse.headers[key] = getResponseHeader(value); } } From 0dd1e1e95ebc3122f076b0ceeb2a47c1603d6dfb Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 26 Mar 2024 01:17:44 -0700 Subject: [PATCH 4/7] Moving tests to sorting.test.ts --- .../test/response-headers-order.test.ts | 40 ------------------- .../typespec-autorest/test/sorting.test.ts | 39 +++++++++++++++++- 2 files changed, 38 insertions(+), 41 deletions(-) delete mode 100644 packages/typespec-autorest/test/response-headers-order.test.ts diff --git a/packages/typespec-autorest/test/response-headers-order.test.ts b/packages/typespec-autorest/test/response-headers-order.test.ts deleted file mode 100644 index 5d29952be9..0000000000 --- a/packages/typespec-autorest/test/response-headers-order.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { openApiFor } from "./test-host.js"; - -describe("typespec-autorest: response headers order", () => { - const headerDefinitions = ` - model A_Header { @header a : string }; - model B_Header { @header b : string }; - model C_Header { @header c : string }; - `; - it("header already in lexical order", async () => { - const res = await openApiFor( - ` - ${headerDefinitions} - model Headers { ...A_Header, ...B_Header, ...C_Header }; - - op read(): {@statusCode _: 200, content: string, headers: Headers}; - ` - ); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); - }); - - it("header not in lexical order", async () => { - const res = await openApiFor( - ` - ${headerDefinitions} - model Headers { ...C_Header, ...A_Header, ...B_Header }; - - op read(): {@statusCode _: 200, content: string, headers: Headers}; - ` - ); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); - }); -}); diff --git a/packages/typespec-autorest/test/sorting.test.ts b/packages/typespec-autorest/test/sorting.test.ts index 231e91a942..ee67c8f4bd 100644 --- a/packages/typespec-autorest/test/sorting.test.ts +++ b/packages/typespec-autorest/test/sorting.test.ts @@ -1,8 +1,15 @@ -import { deepStrictEqual } from "assert"; +import { deepStrictEqual, strictEqual } from "assert"; import { describe, it } from "vitest"; import { sortOpenAPIDocument } from "../src/openapi.js"; +import { openApiFor } from "./test-host.js"; describe("typespec-autorest: OpenAPI output should be determinstic", () => { + const headerDefinitions = ` + model A_Header { @header a : string }; + model B_Header { @header b : string }; + model C_Header { @header c : string }; +`; + it("sorts root", () => { const sorted = sortOpenAPIDocument({ info: {} as any, @@ -72,4 +79,34 @@ describe("typespec-autorest: OpenAPI output should be determinstic", () => { "head", ]); }); + + it("header already in lexical order", async () => { + const res = await openApiFor( + ` + ${headerDefinitions} + model Headers { ...A_Header, ...B_Header, ...C_Header }; + + op read(): {@statusCode _: 200, content: string, headers: Headers}; + ` + ); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + }); + + it("header not in lexical order", async () => { + const res = await openApiFor( + ` + ${headerDefinitions} + model Headers { ...C_Header, ...A_Header, ...B_Header }; + + op read(): {@statusCode _: 200, content: string, headers: Headers}; + ` + ); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); + strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + }); }); From ff2c61b4d4d2b4cc3073411bc56f616396f2988b Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 26 Mar 2024 10:02:16 -0700 Subject: [PATCH 5/7] Update packages/typespec-autorest/test/sorting.test.ts Co-authored-by: Timothee Guerin --- packages/typespec-autorest/test/sorting.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/typespec-autorest/test/sorting.test.ts b/packages/typespec-autorest/test/sorting.test.ts index ee67c8f4bd..7c4d087d0b 100644 --- a/packages/typespec-autorest/test/sorting.test.ts +++ b/packages/typespec-autorest/test/sorting.test.ts @@ -104,9 +104,10 @@ describe("typespec-autorest: OpenAPI output should be determinstic", () => { op read(): {@statusCode _: 200, content: string, headers: Headers}; ` ); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), [ + "a", + "b", + "c" + ]); }); }); From 29fa12d044a3446aedc4150b4e2062ca93523218 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 26 Mar 2024 10:02:42 -0700 Subject: [PATCH 6/7] Update packages/typespec-autorest/test/sorting.test.ts Co-authored-by: Timothee Guerin --- packages/typespec-autorest/test/sorting.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/typespec-autorest/test/sorting.test.ts b/packages/typespec-autorest/test/sorting.test.ts index 7c4d087d0b..85afa1d635 100644 --- a/packages/typespec-autorest/test/sorting.test.ts +++ b/packages/typespec-autorest/test/sorting.test.ts @@ -89,10 +89,11 @@ describe("typespec-autorest: OpenAPI output should be determinstic", () => { op read(): {@statusCode _: 200, content: string, headers: Headers}; ` ); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers).length, 3); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[0], "a"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[1], "b"); - strictEqual(Object.keys(res.paths["/"].get.responses["200"].headers)[2], "c"); + deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), [ + "a", + "b", + "c" + ]); }); it("header not in lexical order", async () => { From f88d64c2a96a515de0ac7a8ae3ffc7e2a5d3c0a8 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 26 Mar 2024 13:02:52 -0700 Subject: [PATCH 7/7] update formating. --- packages/typespec-autorest/test/sorting.test.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/typespec-autorest/test/sorting.test.ts b/packages/typespec-autorest/test/sorting.test.ts index 85afa1d635..ca5139fcae 100644 --- a/packages/typespec-autorest/test/sorting.test.ts +++ b/packages/typespec-autorest/test/sorting.test.ts @@ -1,4 +1,4 @@ -import { deepStrictEqual, strictEqual } from "assert"; +import { deepStrictEqual } from "assert"; import { describe, it } from "vitest"; import { sortOpenAPIDocument } from "../src/openapi.js"; import { openApiFor } from "./test-host.js"; @@ -89,11 +89,7 @@ describe("typespec-autorest: OpenAPI output should be determinstic", () => { op read(): {@statusCode _: 200, content: string, headers: Headers}; ` ); - deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), [ - "a", - "b", - "c" - ]); + deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), ["a", "b", "c"]); }); it("header not in lexical order", async () => { @@ -105,10 +101,6 @@ describe("typespec-autorest: OpenAPI output should be determinstic", () => { op read(): {@statusCode _: 200, content: string, headers: Headers}; ` ); - deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), [ - "a", - "b", - "c" - ]); + deepStrictEqual(Object.keys(res.paths["/"].get.responses["200"].headers), ["a", "b", "c"]); }); });