Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,34 @@ using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;

@useAuth(OAuth2Auth<[ContosoAuthFlow]>)
Comment thread
mikeharder marked this conversation as resolved.
@service({
title: "Contoso Widget Manager",
})
@versioned(Contoso.WidgetManager.Versions)

namespace Azure.Contoso.WidgetManager;

#suppress "@azure-tools/typespec-azure-core/documentation-required" "https://github.com/Azure/typespec-azure/issues/3107"
Comment thread
mikeharder marked this conversation as resolved.
@doc("Versions info.")
enum Versions {
@doc("The 2022-11-01-preview version.")
@useDependency(Azure.Core.Versions.v1_0_Preview_1)
v2022_11_01_Preview: "2022-11-01-preview",
}

@doc("A faked auth model.")
model ContosoAuthFlow {
@doc("The auth flow type.")
type: OAuth2FlowType.implicit;
@doc("The auth flow authorization URL.")
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize";
@doc("The auth flow token URL.")
scopes: ["https://security.microsoft.com/.default"];
}

@doc("A widget.")
@resource("widgets")
model Widget {
model WidgetSuite {
@key("widgetName")
@doc("The widget name.")
@visibility("read")
Expand All @@ -38,22 +51,22 @@ model Widget {

interface Widgets {
@doc("Fetch a Widget by name.")
getWidget is ResourceRead<Widget>;
getWidget is ResourceRead<WidgetSuite>;

@doc("Gets status of a Widget operation.")
getWidgetOperationStatus is GetResourceOperationStatus<Widget>;
getWidgetOperationStatus is GetResourceOperationStatus<WidgetSuite>;

@doc("Creates or updates a Widget asynchronously.")
@pollingOperation(Widgets.getWidgetOperationStatus)
createOrUpdateWidget is LongRunningResourceCreateOrUpdate<Widget>;
createOrUpdateWidget is LongRunningResourceCreateOrUpdate<WidgetSuite>;

@doc("Delete a Widget asynchronously.")
@pollingOperation(Widgets.getWidgetOperationStatus)
deleteWidget is LongRunningResourceDelete<Widget>;
deleteWidget is LongRunningResourceDelete<WidgetSuite>;

@doc("List Widget resources")
listWidgets is ResourceList<
Widget,
WidgetSuite,
{
parameters: StandardListQueryParameters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ options:
"@azure-tools/typespec-autorest":
azure-resource-provider-folder: "data-plane"
emitter-output-dir: "{project-root}/.."
examples-directory: "examples"
examples-directory: "{project-root}/examples"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - issue#3182

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK working around this for now but do we know if we can get some of these to be defaults so we don't have to specify them in all the tspconfig files?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this issue was planned in July sprint. It's ok to use the correct value in sample config as this issue will be gone soon.

output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/widgets.json"
"@azure-tools/typespec-python":
package-dir: "azure-contoso-widgetmanager"
package-mode: "dataplane"
package-name: "{package-dir}"
"@azure-tools/typespec-csharp":
package-dir: "Azure.Contoso.WidgetManager"
package-dir: "Azure.Storage.Contoso"
Comment thread
raych1 marked this conversation as resolved.
Outdated
clear-output-folder: true
model-namespace: false
namespace: "{package-dir}"
Expand All @@ -28,4 +28,4 @@ options:
name: "@azure-rest/contoso-widgetmanager-rest"
"@azure-tools/typespec-java":
package-dir: "azure-contoso-widgetmanager"
namespace: com.azure.contoso.widgetmanager
namespace: com.azure.contoso.widgetmanager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ray Chen (@raych1): Please do not remove trailing newlines when editing files.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
"consumes": [
"application/json"
],
"security": [
{
"OAuth2Auth": [
"https://security.microsoft.com/.default"
]
}
],
"securityDefinitions": {
"OAuth2Auth": {
"type": "oauth2",
"flow": "implicit",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"scopes": {
"https://security.microsoft.com/.default": ""
}
}
},
"tags": [],
"paths": {
"/widgets": {
Expand All @@ -38,11 +55,11 @@
"value": {
"type": "array",
"items": {
"$ref": "#/definitions/Widget"
"$ref": "#/definitions/WidgetSuite"
},
"x-ms-identifiers": [],
"description": "The Widget items on this page",
"x-typespec-name": "Widget[]"
"description": "The WidgetSuite items on this page",
"x-typespec-name": "WidgetSuite[]"
},
"nextLink": {
"type": "string",
Expand All @@ -51,11 +68,11 @@
"x-typespec-name": "TypeSpec.Rest.ResourceLocation"
}
},
"description": "Paged collection of Widget items",
"description": "Paged collection of WidgetSuite items",
"required": [
"value"
],
"x-typespec-name": "Azure.Core.Foundations.CustomPage<Widget, Azure.Core.(anonymous model)>"
"x-typespec-name": "Azure.Core.Foundations.CustomPage<WidgetSuite, Azure.Core.(anonymous model)>"
}
},
"default": {
Expand Down Expand Up @@ -101,7 +118,7 @@
"200": {
"description": "The request has succeeded.",
"schema": {
"$ref": "#/definitions/Widget"
"$ref": "#/definitions/WidgetSuite"
}
},
"default": {
Expand Down Expand Up @@ -143,7 +160,7 @@
"required": true,
"description": "The resource instance.",
"schema": {
"$ref": "#/definitions/WidgetUpdate"
"$ref": "#/definitions/WidgetSuiteUpdate"
}
}
],
Expand All @@ -158,7 +175,7 @@
}
},
"schema": {
"$ref": "#/definitions/Widget"
"$ref": "#/definitions/WidgetSuite"
}
},
"201": {
Expand All @@ -171,7 +188,7 @@
}
},
"schema": {
"$ref": "#/definitions/Widget"
"$ref": "#/definitions/WidgetSuite"
}
},
"default": {
Expand Down Expand Up @@ -307,7 +324,7 @@
"description": "Error object that describes the error when status is \"Failed\"."
},
"result": {
"$ref": "#/definitions/Widget",
"$ref": "#/definitions/WidgetSuite",
"description": "The result of the operation."
}
},
Expand All @@ -316,7 +333,7 @@
"id",
"status"
],
"x-typespec-name": "Azure.Core.ResourceOperationStatus<Widget, Widget, Azure.Core.Foundations.Error>"
"x-typespec-name": "Azure.Core.ResourceOperationStatus<WidgetSuite, WidgetSuite, Azure.Core.Foundations.Error>"
}
},
"default": {
Expand Down Expand Up @@ -439,6 +456,40 @@
]
}
},
"ContosoAuthFlow": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"implicit"
],
"description": "The auth flow type."
},
"authorizationUrl": {
"type": "string",
"enum": [
"https://login.microsoftonline.com/common/oauth2/authorize"
],
"x-ms-enum": {
"modelAsString": false
},
"description": "The auth flow authorization URL."
},
"scopes": {
"type": "array",
"items": {},
"x-typespec-name": "[https://security.microsoft.com/.default]",
"description": "The auth flow token URL."
}
},
"description": "A faked auth model.",
"required": [
"type",
"authorizationUrl",
"scopes"
]
},
"FakedSharedModel": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -475,6 +526,7 @@
},
"Versions": {
"type": "string",
"description": "Versions info.",
"enum": [
"2022-11-01-preview"
],
Expand All @@ -484,12 +536,13 @@
"values": [
{
"name": "v2022_11_01_Preview",
"value": "2022-11-01-preview"
"value": "2022-11-01-preview",
"description": "The 2022-11-01-preview version."
}
]
}
},
"Widget": {
"WidgetSuite": {
"type": "object",
"properties": {
"name": {
Expand All @@ -512,7 +565,7 @@
"manufacturerId"
]
},
"WidgetUpdate": {
"WidgetSuiteUpdate": {
"type": "object",
"properties": {
"manufacturerId": {
Expand Down