From 6d993f9973e5af78ff41becc451f7a2dc85d7f94 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 10 Jan 2024 22:42:11 +0000 Subject: [PATCH 1/4] Test new spec with invalid json --- .../preview/2022-11-01-preview/widgets.json | 564 ++++++++++++++++++ 1 file changed, 564 insertions(+) create mode 100644 specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json diff --git a/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json b/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json new file mode 100644 index 000000000000..c6688c8c2095 --- /dev/null +++ b/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json @@ -0,0 +1,564 @@ +invalid json +{ + "swagger": "2.0", + "info": { + "title": "Contoso Widget Manager", + "version": "2022-11-01-preview" + }, + "schemes": [ + "https" + ], + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "AadOauth2Auth": [ + "https://contoso.azure.com/.default" + ] + } + ], + "securityDefinitions": { + "AadOauth2Auth": { + "type": "oauth2", + "description": "The Azure Active Directory OAuth2 Flow", + "flow": "accessCode", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "https://contoso.azure.com/.default": "" + }, + "tokenUrl": "https://login.microsoftonline.com/common/oauth2/token" + } + }, + "tags": [], + "paths": { + "/widgets": { + "get": { + "operationId": "Widgets_ListWidgets", + "description": "List Widget resources", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/PagedWidgetSuite" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Widgets_ListWidgets": { + "$ref": "./examples/Widgets_ListWidgetsSample.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/widgets/{widgetName}": { + "get": { + "operationId": "Widgets_GetWidget", + "description": "Fetch a Widget by name.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/WidgetSuite" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Get widget by widget name.": { + "$ref": "./examples/Widgets_GetWidgetSample.json" + } + } + }, + "patch": { + "operationId": "Widgets_CreateOrUpdateWidget", + "description": "Creates or updates a Widget asynchronously.", + "consumes": [ + "application/merge-patch+json" + ], + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "resource", + "in": "body", + "description": "The resource instance.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetSuiteCreateOrUpdate" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/WidgetSuite" + }, + "headers": { + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + } + } + }, + "201": { + "description": "The request has succeeded and a new resource has been created as a result.", + "schema": { + "$ref": "#/definitions/WidgetSuite" + }, + "headers": { + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Widgets_CreateOrUpdateWidget": { + "$ref": "./examples/Widgets_CreateOrUpdateWidgetSample.json" + } + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "Widgets_DeleteWidget", + "description": "Delete a Widget asynchronously.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + } + ], + "responses": { + "202": { + "description": "The request has been accepted for processing, but processing has not yet completed.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + }, + "headers": { + "Operation-Location": { + "type": "string", + "format": "uri", + "description": "The location for monitoring the operation state." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Delete widget by widget name using long-running operation.": { + "$ref": "./examples/Widgets_DeleteWidgetSample.json" + } + }, + "x-ms-long-running-operation": true + } + }, + "/widgets/{widgetName}/operations/{operationId}": { + "get": { + "operationId": "Widgets_GetWidgetOperationStatus", + "description": "Gets status of a Widget operation.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + }, + "result": { + "$ref": "#/definitions/WidgetSuite", + "description": "The result of the operation." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Widgets_GetWidgetOperationStatus": { + "$ref": "./examples/Widgets_GetWidgetOperationStatusSample.json" + } + } + } + } + }, + "definitions": { + "Azure.Core.Foundations.Error": { + "type": "object", + "description": "The error object.", + "properties": { + "code": { + "type": "string", + "description": "One of a server-defined set of error codes." + }, + "message": { + "type": "string", + "description": "A human-readable representation of the error." + }, + "target": { + "type": "string", + "description": "The target of the error." + }, + "details": { + "type": "array", + "description": "An array of details about specific errors that led to this reported error.", + "items": { + "$ref": "#/definitions/Azure.Core.Foundations.Error" + }, + "x-ms-identifiers": [] + }, + "innererror": { + "$ref": "#/definitions/Azure.Core.Foundations.InnerError", + "description": "An object containing more specific information than the current object about the error." + } + }, + "required": [ + "code", + "message" + ] + }, + "Azure.Core.Foundations.ErrorResponse": { + "type": "object", + "description": "A response containing error details.", + "properties": { + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "The error object." + } + }, + "required": [ + "error" + ] + }, + "Azure.Core.Foundations.InnerError": { + "type": "object", + "description": "An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.", + "properties": { + "code": { + "type": "string", + "description": "One of a server-defined set of error codes." + }, + "innererror": { + "$ref": "#/definitions/Azure.Core.Foundations.InnerError", + "description": "Inner error." + } + } + }, + "Azure.Core.Foundations.OperationState": { + "type": "string", + "description": "Enum describing allowed operation states.", + "enum": [ + "NotStarted", + "Running", + "Succeeded", + "Failed", + "Canceled" + ], + "x-ms-enum": { + "name": "OperationState", + "modelAsString": true, + "values": [ + { + "name": "NotStarted", + "value": "NotStarted", + "description": "The operation has not started." + }, + { + "name": "Running", + "value": "Running", + "description": "The operation is in progress." + }, + { + "name": "Succeeded", + "value": "Succeeded", + "description": "The operation has completed successfully." + }, + { + "name": "Failed", + "value": "Failed", + "description": "The operation has failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "The operation has been canceled by the user." + } + ] + } + }, + "FakedSharedModel": { + "type": "object", + "description": "Faked shared model", + "properties": { + "tag": { + "type": "string", + "description": "The tag." + }, + "createdAt": { + "type": "string", + "format": "date-time", + "description": "The created date." + } + }, + "required": [ + "tag", + "createdAt" + ] + }, + "FakedSharedModelCreateOrUpdate": { + "type": "object", + "description": "Faked shared model", + "properties": { + "tag": { + "type": "string", + "description": "The tag." + }, + "createdAt": { + "type": "string", + "format": "date-time", + "description": "The created date." + } + } + }, + "PagedWidgetSuite": { + "type": "object", + "description": "Paged collection of WidgetSuite items", + "properties": { + "value": { + "type": "array", + "description": "The WidgetSuite items on this page", + "items": { + "$ref": "#/definitions/WidgetSuite" + }, + "x-ms-identifiers": [] + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "Versions": { + "type": "string", + "description": "Versions info.", + "enum": [ + "2022-11-01-preview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_11_01_Preview", + "value": "2022-11-01-preview", + "description": "The 2022-11-01-preview version." + } + ] + } + }, + "WidgetSuite": { + "type": "object", + "description": "A widget.", + "properties": { + "name": { + "type": "string", + "description": "The widget name.", + "readOnly": true + }, + "manufacturerId": { + "type": "string", + "description": "The ID of the widget's manufacturer." + }, + "sharedModel": { + "$ref": "#/definitions/FakedSharedModel", + "description": "The faked shared model." + } + }, + "required": [ + "name", + "manufacturerId" + ] + }, + "WidgetSuiteCreateOrUpdate": { + "type": "object", + "description": "A widget.", + "properties": { + "manufacturerId": { + "type": "string", + "description": "The ID of the widget's manufacturer." + }, + "sharedModel": { + "$ref": "#/definitions/FakedSharedModelCreateOrUpdate", + "description": "The faked shared model." + } + } + } + }, + "parameters": { + "Azure.Core.Foundations.ApiVersionParameter": { + "name": "api-version", + "in": "query", + "description": "The API version to use for this operation.", + "required": true, + "type": "string", + "minLength": 1, + "x-ms-parameter-location": "method", + "x-ms-client-name": "apiVersion" + } + } +} From 327d363bbcc863b56ea9c9635c397b8d30d90b03 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 10 Jan 2024 22:59:23 +0000 Subject: [PATCH 2/4] Add commit parameters for easier local testing --- eng/scripts/ChangedFiles-Functions.ps1 | 4 ++-- eng/scripts/TypeSpec-Requirement.ps1 | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eng/scripts/ChangedFiles-Functions.ps1 b/eng/scripts/ChangedFiles-Functions.ps1 index 0968b252df54..a2c9202db867 100644 --- a/eng/scripts/ChangedFiles-Functions.ps1 +++ b/eng/scripts/ChangedFiles-Functions.ps1 @@ -18,8 +18,8 @@ function Get-ChangedFiles($baseCommitish = "HEAD^", $targetCommitish = "HEAD", $ return $changedFiles } -function Get-ChangedSwaggerFiles() { - $changedFiles = Get-ChangedFilesUnderSpecification +function Get-ChangedSwaggerFiles($changedFiles = (Get-ChangedFiles)) { + $changedFiles = Get-ChangedFilesUnderSpecification($changedFiles) $changedSwaggerFiles = $changedFiles.Where({ $_.EndsWith(".json") diff --git a/eng/scripts/TypeSpec-Requirement.ps1 b/eng/scripts/TypeSpec-Requirement.ps1 index ee4855316a8b..3df72e56681e 100644 --- a/eng/scripts/TypeSpec-Requirement.ps1 +++ b/eng/scripts/TypeSpec-Requirement.ps1 @@ -1,5 +1,10 @@ [CmdletBinding()] param ( + [Parameter(Position = 0)] + [string] $BaseCommitish = "HEAD^", + [Parameter(Position = 1)] + [string] $TargetCommitish = "HEAD" + ) Set-StrictMode -Version 3 @@ -9,7 +14,7 @@ Set-StrictMode -Version 3 $repoPath = Resolve-Path "$PSScriptRoot/../.." $pathsWithErrors = @() -$filesToCheck = @(Get-ChangedSwaggerFiles).Where({ +$filesToCheck = (Get-ChangedSwaggerFiles (Get-ChangedFiles $BaseCommitish $TargetCommitish)).Where({ ($_ -notmatch "/(examples|scenarios|restler|common|common-types)/") -and ($_ -match "specification/[^/]+/(data-plane|resource-manager).*?/(preview|stable)/[^/]+/[^/]+\.json$") }) From c208df02cb8e0262d2a3dda8a7935e4e9b2965d5 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 17 Jan 2024 00:51:35 +0000 Subject: [PATCH 3/4] Catch exception parsing OpenAPI as JSON --- eng/scripts/TypeSpec-Requirement.ps1 | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/eng/scripts/TypeSpec-Requirement.ps1 b/eng/scripts/TypeSpec-Requirement.ps1 index 3df72e56681e..e7909dc10026 100644 --- a/eng/scripts/TypeSpec-Requirement.ps1 +++ b/eng/scripts/TypeSpec-Requirement.ps1 @@ -35,15 +35,21 @@ else { foreach ($file in $filesToCheck) { LogInfo "Checking $file" - $jsonContent = Get-Content (Join-Path $repoPath $file) | ConvertFrom-Json -AsHashtable + try { + $jsonContent = Get-Content (Join-Path $repoPath $file) | ConvertFrom-Json -AsHashtable - if ($null -ne ${jsonContent}?["info"]?["x-typespec-generated"]) { - LogInfo " OpenAPI was generated from TypeSpec (contains '/info/x-typespec-generated')" - # Skip further checks, since spec is already using TypeSpec - continue + if ($null -ne ${jsonContent}?["info"]?["x-typespec-generated"]) { + LogInfo " OpenAPI was generated from TypeSpec (contains '/info/x-typespec-generated')" + # Skip further checks, since spec is already using TypeSpec + continue + } + else { + LogInfo " OpenAPI was not generated from TypeSpec (missing '/info/x-typespec-generated')" + } } - else { - LogInfo " OpenAPI was not generated from TypeSpec (missing '/info/x-typespec-generated')" + catch { + LogWarning " OpenAPI cannot be parsed as JSON, so assuming not generated from TypeSpec" + LogWarning " $_" } # Extract path between "specification/" and "/(preview|stable)" From 3f22f442ae314ddce0c23f7f68f7198d252805ad Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 17 Jan 2024 00:55:09 +0000 Subject: [PATCH 4/4] Revert "Test new spec with invalid json" This reverts commit 6d993f9973e5af78ff41becc451f7a2dc85d7f94. --- .../preview/2022-11-01-preview/widgets.json | 564 ------------------ 1 file changed, 564 deletions(-) delete mode 100644 specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json diff --git a/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json b/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json deleted file mode 100644 index c6688c8c2095..000000000000 --- a/specification/contosowidgetmanager2/data-plane/Azure.Contoso.WidgetManager2/preview/2022-11-01-preview/widgets.json +++ /dev/null @@ -1,564 +0,0 @@ -invalid json -{ - "swagger": "2.0", - "info": { - "title": "Contoso Widget Manager", - "version": "2022-11-01-preview" - }, - "schemes": [ - "https" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "AadOauth2Auth": [ - "https://contoso.azure.com/.default" - ] - } - ], - "securityDefinitions": { - "AadOauth2Auth": { - "type": "oauth2", - "description": "The Azure Active Directory OAuth2 Flow", - "flow": "accessCode", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "https://contoso.azure.com/.default": "" - }, - "tokenUrl": "https://login.microsoftonline.com/common/oauth2/token" - } - }, - "tags": [], - "paths": { - "/widgets": { - "get": { - "operationId": "Widgets_ListWidgets", - "description": "List Widget resources", - "parameters": [ - { - "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "schema": { - "$ref": "#/definitions/PagedWidgetSuite" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" - }, - "headers": { - "x-ms-error-code": { - "type": "string", - "description": "String error code indicating what went wrong." - } - } - } - }, - "x-ms-examples": { - "Widgets_ListWidgets": { - "$ref": "./examples/Widgets_ListWidgetsSample.json" - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/widgets/{widgetName}": { - "get": { - "operationId": "Widgets_GetWidget", - "description": "Fetch a Widget by name.", - "parameters": [ - { - "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "widgetName", - "in": "path", - "description": "The widget name.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "schema": { - "$ref": "#/definitions/WidgetSuite" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" - }, - "headers": { - "x-ms-error-code": { - "type": "string", - "description": "String error code indicating what went wrong." - } - } - } - }, - "x-ms-examples": { - "Get widget by widget name.": { - "$ref": "./examples/Widgets_GetWidgetSample.json" - } - } - }, - "patch": { - "operationId": "Widgets_CreateOrUpdateWidget", - "description": "Creates or updates a Widget asynchronously.", - "consumes": [ - "application/merge-patch+json" - ], - "parameters": [ - { - "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "widgetName", - "in": "path", - "description": "The widget name.", - "required": true, - "type": "string" - }, - { - "name": "resource", - "in": "body", - "description": "The resource instance.", - "required": true, - "schema": { - "$ref": "#/definitions/WidgetSuiteCreateOrUpdate" - } - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "schema": { - "$ref": "#/definitions/WidgetSuite" - }, - "headers": { - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." - } - } - }, - "201": { - "description": "The request has succeeded and a new resource has been created as a result.", - "schema": { - "$ref": "#/definitions/WidgetSuite" - }, - "headers": { - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." - } - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" - }, - "headers": { - "x-ms-error-code": { - "type": "string", - "description": "String error code indicating what went wrong." - } - } - } - }, - "x-ms-examples": { - "Widgets_CreateOrUpdateWidget": { - "$ref": "./examples/Widgets_CreateOrUpdateWidgetSample.json" - } - }, - "x-ms-long-running-operation": true - }, - "delete": { - "operationId": "Widgets_DeleteWidget", - "description": "Delete a Widget asynchronously.", - "parameters": [ - { - "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "widgetName", - "in": "path", - "description": "The widget name.", - "required": true, - "type": "string" - } - ], - "responses": { - "202": { - "description": "The request has been accepted for processing, but processing has not yet completed.", - "schema": { - "type": "object", - "description": "Provides status details for long running operations.", - "properties": { - "id": { - "type": "string", - "description": "The unique ID of the operation." - }, - "status": { - "$ref": "#/definitions/Azure.Core.Foundations.OperationState", - "description": "The status of the operation" - }, - "error": { - "$ref": "#/definitions/Azure.Core.Foundations.Error", - "description": "Error object that describes the error when status is \"Failed\"." - } - }, - "required": [ - "id", - "status" - ] - }, - "headers": { - "Operation-Location": { - "type": "string", - "format": "uri", - "description": "The location for monitoring the operation state." - } - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" - }, - "headers": { - "x-ms-error-code": { - "type": "string", - "description": "String error code indicating what went wrong." - } - } - } - }, - "x-ms-examples": { - "Delete widget by widget name using long-running operation.": { - "$ref": "./examples/Widgets_DeleteWidgetSample.json" - } - }, - "x-ms-long-running-operation": true - } - }, - "/widgets/{widgetName}/operations/{operationId}": { - "get": { - "operationId": "Widgets_GetWidgetOperationStatus", - "description": "Gets status of a Widget operation.", - "parameters": [ - { - "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "widgetName", - "in": "path", - "description": "The widget name.", - "required": true, - "type": "string" - }, - { - "name": "operationId", - "in": "path", - "description": "The unique ID of the operation.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "schema": { - "type": "object", - "description": "Provides status details for long running operations.", - "properties": { - "id": { - "type": "string", - "description": "The unique ID of the operation." - }, - "status": { - "$ref": "#/definitions/Azure.Core.Foundations.OperationState", - "description": "The status of the operation" - }, - "error": { - "$ref": "#/definitions/Azure.Core.Foundations.Error", - "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/WidgetSuite", - "description": "The result of the operation." - } - }, - "required": [ - "id", - "status" - ] - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" - }, - "headers": { - "x-ms-error-code": { - "type": "string", - "description": "String error code indicating what went wrong." - } - } - } - }, - "x-ms-examples": { - "Widgets_GetWidgetOperationStatus": { - "$ref": "./examples/Widgets_GetWidgetOperationStatusSample.json" - } - } - } - } - }, - "definitions": { - "Azure.Core.Foundations.Error": { - "type": "object", - "description": "The error object.", - "properties": { - "code": { - "type": "string", - "description": "One of a server-defined set of error codes." - }, - "message": { - "type": "string", - "description": "A human-readable representation of the error." - }, - "target": { - "type": "string", - "description": "The target of the error." - }, - "details": { - "type": "array", - "description": "An array of details about specific errors that led to this reported error.", - "items": { - "$ref": "#/definitions/Azure.Core.Foundations.Error" - }, - "x-ms-identifiers": [] - }, - "innererror": { - "$ref": "#/definitions/Azure.Core.Foundations.InnerError", - "description": "An object containing more specific information than the current object about the error." - } - }, - "required": [ - "code", - "message" - ] - }, - "Azure.Core.Foundations.ErrorResponse": { - "type": "object", - "description": "A response containing error details.", - "properties": { - "error": { - "$ref": "#/definitions/Azure.Core.Foundations.Error", - "description": "The error object." - } - }, - "required": [ - "error" - ] - }, - "Azure.Core.Foundations.InnerError": { - "type": "object", - "description": "An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.", - "properties": { - "code": { - "type": "string", - "description": "One of a server-defined set of error codes." - }, - "innererror": { - "$ref": "#/definitions/Azure.Core.Foundations.InnerError", - "description": "Inner error." - } - } - }, - "Azure.Core.Foundations.OperationState": { - "type": "string", - "description": "Enum describing allowed operation states.", - "enum": [ - "NotStarted", - "Running", - "Succeeded", - "Failed", - "Canceled" - ], - "x-ms-enum": { - "name": "OperationState", - "modelAsString": true, - "values": [ - { - "name": "NotStarted", - "value": "NotStarted", - "description": "The operation has not started." - }, - { - "name": "Running", - "value": "Running", - "description": "The operation is in progress." - }, - { - "name": "Succeeded", - "value": "Succeeded", - "description": "The operation has completed successfully." - }, - { - "name": "Failed", - "value": "Failed", - "description": "The operation has failed." - }, - { - "name": "Canceled", - "value": "Canceled", - "description": "The operation has been canceled by the user." - } - ] - } - }, - "FakedSharedModel": { - "type": "object", - "description": "Faked shared model", - "properties": { - "tag": { - "type": "string", - "description": "The tag." - }, - "createdAt": { - "type": "string", - "format": "date-time", - "description": "The created date." - } - }, - "required": [ - "tag", - "createdAt" - ] - }, - "FakedSharedModelCreateOrUpdate": { - "type": "object", - "description": "Faked shared model", - "properties": { - "tag": { - "type": "string", - "description": "The tag." - }, - "createdAt": { - "type": "string", - "format": "date-time", - "description": "The created date." - } - } - }, - "PagedWidgetSuite": { - "type": "object", - "description": "Paged collection of WidgetSuite items", - "properties": { - "value": { - "type": "array", - "description": "The WidgetSuite items on this page", - "items": { - "$ref": "#/definitions/WidgetSuite" - }, - "x-ms-identifiers": [] - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items" - } - }, - "required": [ - "value" - ] - }, - "Versions": { - "type": "string", - "description": "Versions info.", - "enum": [ - "2022-11-01-preview" - ], - "x-ms-enum": { - "name": "Versions", - "modelAsString": true, - "values": [ - { - "name": "v2022_11_01_Preview", - "value": "2022-11-01-preview", - "description": "The 2022-11-01-preview version." - } - ] - } - }, - "WidgetSuite": { - "type": "object", - "description": "A widget.", - "properties": { - "name": { - "type": "string", - "description": "The widget name.", - "readOnly": true - }, - "manufacturerId": { - "type": "string", - "description": "The ID of the widget's manufacturer." - }, - "sharedModel": { - "$ref": "#/definitions/FakedSharedModel", - "description": "The faked shared model." - } - }, - "required": [ - "name", - "manufacturerId" - ] - }, - "WidgetSuiteCreateOrUpdate": { - "type": "object", - "description": "A widget.", - "properties": { - "manufacturerId": { - "type": "string", - "description": "The ID of the widget's manufacturer." - }, - "sharedModel": { - "$ref": "#/definitions/FakedSharedModelCreateOrUpdate", - "description": "The faked shared model." - } - } - } - }, - "parameters": { - "Azure.Core.Foundations.ApiVersionParameter": { - "name": "api-version", - "in": "query", - "description": "The API version to use for this operation.", - "required": true, - "type": "string", - "minLength": 1, - "x-ms-parameter-location": "method", - "x-ms-client-name": "apiVersion" - } - } -}