Skip to content

[DO NOT MERGE] TEST TEST Creating a new TestService with new structure layout #34537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion eng/scripts/Get-TypeSpec-Folders.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[CmdletBinding()]
param (
[switch]$IgnoreCoreFiles = $false,
Expand All @@ -20,7 +20,7 @@
}
else {
$changedFiles = @(Get-ChangedFiles -baseCommitish $BaseCommitish -headCommitish $HeadCommitish -diffFilter "")
$coreChangedFiles = Get-ChangedCoreFiles $changedFiles
$coreChangedFiles = $false # = Get-ChangedCoreFiles $changedFiles

if ($coreChangedFiles -and !$IgnoreCoreFiles) {
Write-Verbose "Found changes to core eng or root files so checking all specs."
Expand Down
4 changes: 2 additions & 2 deletions eng/tools/typespec-validation/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ParseArgsConfig, parseArgs } from "node:util";
import { stat } from "node:fs/promises";
import { Suppression } from "suppressions";
import { CompileRule } from "./rules/compile.js";
import { EmitAutorestRule } from "./rules/emit-autorest.js";
import { FlavorAzureRule } from "./rules/flavor-azure.js";
import { FolderStructureRule } from "./rules/folder-structure.js";
//import { FolderStructureRule } from "./rules/folder-structure.js";
import { FormatRule } from "./rules/format.js";
import { LinterRulesetRule } from "./rules/linter-ruleset.js";
import { NpmPrefixRule } from "./rules/npm-prefix.js";
Expand Down Expand Up @@ -45,7 +45,7 @@
}

const rules = [
new FolderStructureRule(),
// new FolderStructureRule(),
new NpmPrefixRule(),
new EmitAutorestRule(),
new FlavorAzureRule(),
Expand Down
8 changes: 4 additions & 4 deletions eng/tools/typespec-validation/src/rules/folder-structure.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import debug from "debug";
import { readFile } from "fs/promises";
import { globby } from "globby";
Expand Down Expand Up @@ -49,10 +49,10 @@
const packageFolder = folderStruct[folderStruct.length - 1];

// Verify package folder is at most 3 levels deep
if (folderStruct.length > 4) {
success = false;
errorOutput += `Please limit TypeSpec folder depth to 3 levels or less`;
}
//if (folderStruct.length > 4) {
// success = false;
// errorOutput += `Please limit TypeSpec folder depth to 3 levels or less`;
//}

// Verify second level folder is capitalized after each '.'
if (/(^|\. *)([a-z])/g.test(packageFolder)) {
Expand Down
24 changes: 12 additions & 12 deletions eng/tools/typespec-validation/test/folder-structure.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { mockAll, mockFolder } from "./mocks.js";
mockAll();

Expand Down Expand Up @@ -55,18 +55,18 @@
assert(result.success);
});

it("should fail if package folder is more than 3 levels deep", async function () {
vi.mocked(globby.globby).mockImplementation(async () => {
return ["/foo/bar/tspconfig.yaml"];
});
normalizePathSpy.mockReturnValue("/gitroot");

const result = await new FolderStructureRule().execute(
"/gitroot/specification/foo/Foo/Foo/Foo",
);
assert(result.errorOutput);
assert(result.errorOutput.includes("3 levels or less"));
});
// it("should fail if package folder is more than 3 levels deep", async function () {
// vi.mocked(globby.globby).mockImplementation(async () => {
// return ["/foo/bar/tspconfig.yaml"];
// });
// normalizePathSpy.mockReturnValue("/gitroot");

// const result = await new FolderStructureRule().execute(
// "/gitroot/specification/foo/Foo/Foo/Foo",
// );
// assert(result.errorOutput);
// assert(result.errorOutput.includes("3 levels or less"));
// });

it("should fail if second level folder not capitalized at after each '.' ", async function () {
vi.mocked(globby.globby).mockImplementation(async () => {
Expand Down
16 changes: 16 additions & 0 deletions specification/contosowidgetmanager-new2/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file configures spell checking. Items in "words" were initially populated
# with words that might be spelling errors. Review these words and take
# appropriate action. For more information, see: https://aka.ms/ci-fix#spell-check

# Spell checking is not case sensitive
# Keep word lists in alphabetical order so the file is easier to manage
version: '0.2'
import:
- ../../cspell.yaml
words:
- armcontoso
- contosowidgetmanager
- contosowidget
- azmanager
- byval

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import "@typespec/rest";
Copy link
Member

Choose a reason for hiding this comment

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

Please rename Contoso.Management folder to just Contoso. We already know it's management because it's under resource-manager

Copy link
Member

Choose a reason for hiding this comment

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

Wess requested a data-plane example to be part of this PR.
So, under data-plane folder, there should 1 or 2 ServiceName folders identical in structure to that under the Microsoft.Contoso RP namespace folder. Data-plane does not have an RP namespace folder and does not have a readme.md files in this folder. The only readme.md files are in the ServiceName folders.

import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.Core;
using Azure.ResourceManager;

namespace Microsoft.Contoso;

/** Employee resource */
model Employee is TrackedResource<EmployeeProperties> {
...ResourceNameParameter<Employee>;
}

/** Employee properties */
model EmployeeProperties {
/** Age of employee */
age?: int32;

/** City of employee */
city?: string;

/** Profile of employee */
@encode("base64url")
profile?: bytes;

/** The status of the last operation. */
@visibility(Lifecycle.Read)
provisioningState?: ProvisioningState;
}

/** The resource provisioning state. */
@lroStatus
union ProvisioningState {
ResourceProvisioningState,

/** The resource is being provisioned */
Provisioning: "Provisioning",

/** The resource is updating */
Updating: "Updating",

/** The resource is being deleted */
Deleting: "Deleting",

/** The resource create request has been accepted */
Accepted: "Accepted",

string,
}

@armResourceOperations
interface Employees {
get is ArmResourceRead<Employee>;
createOrUpdate is ArmResourceCreateOrReplaceAsync<Employee>;
update is ArmResourcePatchSync<Employee, EmployeeProperties>;
delete is ArmResourceDeleteWithoutOkAsync<Employee>;
listByResourceGroup is ArmResourceListByParent<Employee>;
listBySubscription is ArmListBySubscription<Employee>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"title": "Employees_CreateOrUpdate",
"operationId": "Employees_CreateOrUpdate",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "9KF-f-8b",
"resource": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl"
}
},
"responses": {
"200": {
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
},
"201": {
"headers": {
"Azure-AsyncOperation": "https://contoso.com/operationstatus"
},
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/9KF-f-8b",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"title": "Employees_Delete",
"operationId": "Employees_Delete",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "5vX--BxSu3ux48rI4O9OQ569"
},
"responses": {
"202": {
"headers": {
"Retry-After": 30,
"location": "https://contoso.com/operationstatus"
}
},
"204": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"title": "Employees_Get",
"operationId": "Employees_Get",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "le-8MU--J3W6q8D386p3-iT3"
},
"responses": {
"200": {
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"title": "Employees_ListByResourceGroup",
"operationId": "Employees_ListByResourceGroup",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi"
},
"responses": {
"200": {
"body": {
"value": [
{
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
],
"nextLink": "https://microsoft.com/a"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"title": "Employees_ListBySubscription",
"operationId": "Employees_ListBySubscription",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9"
},
"responses": {
"200": {
"body": {
"value": [
{
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
],
"nextLink": "https://microsoft.com/a"
}
}
}
}
Loading
Loading