Skip to content

Adopt OAuth spector scenarios #49430

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

Merged
merged 5 commits into from
Apr 16, 2025
Merged
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
9 changes: 4 additions & 5 deletions eng/packages/http-client-csharp/eng/scripts/Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
param(
$filter,
[bool]$Stubbed = $true,
[bool]$LaunchOnly = $false,
[switch]$ForceNewProject = $false
[bool]$LaunchOnly = $false
)

Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force;
Expand All @@ -22,7 +21,7 @@ if (-not $LaunchOnly) {

$basicTypespecTestProject = Join-Path $testProjectsLocalDir "Basic-TypeSpec"

Invoke (Get-TspCommand "$basicTypespecTestProject/Basic-TypeSpec.tsp" $basicTypespecTestProject -forceNewProject $ForceNewProject)
Invoke (Get-TspCommand "$basicTypespecTestProject/Basic-TypeSpec.tsp" $basicTypespecTestProject)

# exit if the generation failed
if ($LASTEXITCODE -ne 0) {
Expand Down Expand Up @@ -162,7 +161,7 @@ foreach ($directory in $directories) {
}

Write-Host "Generating $subPath" -ForegroundColor Cyan
Invoke (Get-TspCommand $specFile $generationDir $stubbed -forceNewProject $ForceNewProject)
Invoke (Get-TspCommand $specFile $generationDir $stubbed)

# exit if the generation failed
if ($LASTEXITCODE -ne 0) {
Expand All @@ -185,7 +184,7 @@ if ($null -eq $filter) {

foreach ($kvp in $spectorLaunchProjects.GetEnumerator()) {
$launchSettings["profiles"].Add($kvp.Key, @{})
$launchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll `$(SolutionDir)/$($kvp.Value) -g AzureClientGenerator")
$launchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll `$(SolutionDir)/$($kvp.Value) -g AzureStubGenerator")
$launchSettings["profiles"][$kvp.Key].Add("commandName", "Executable")
$launchSettings["profiles"][$kvp.Key].Add("executablePath", "dotnet")
}
Expand Down
13 changes: 5 additions & 8 deletions eng/packages/http-client-csharp/eng/scripts/Generation.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function Get-TspCommand {
[string]$specFile,
[string]$generationDir,
[bool]$generateStub = $false,
[string]$apiVersion = $null,
[bool]$forceNewProject = $false
[string]$apiVersion = $null
)
$command = "npx tsp compile $specFile"
$command += " --trace @azure-typespec/http-client-csharp"
Expand All @@ -45,9 +44,7 @@ function Get-TspCommand {
$command += " --option @azure-typespec/http-client-csharp.api-version=$apiVersion"
}

if ($forceNewProject) {
$command += " --option @azure-typespec/http-client-csharp.new-project=true"
}
$command += " --option @azure-typespec/http-client-csharp.new-project=true"

return $command
}
Expand All @@ -63,7 +60,7 @@ function Get-Mgmt-TspCommand {
$command = "npx tsp compile $specFile"
$command += " --trace @azure-typespec/http-client-csharp-mgmt"
$command += " --emit $repoRoot/../../http-client-csharp-mgmt"

$configFile = Join-Path $generationDir "tspconfig.yaml"
if (Test-Path $configFile) {
$command += " --config=$configFile"
Expand All @@ -73,7 +70,7 @@ function Get-Mgmt-TspCommand {
if ($generateStub) {
$command += " --option @azure-typespec/http-client-csharp-mgmt.plugin-name=AzureStubPlugin"
}

if ($apiVersion) {
$command += " --option @azure-typespec/http-client-csharp-mgmt.api-version=$apiVersion"
}
Expand All @@ -87,7 +84,7 @@ function Get-Mgmt-TspCommand {

function Refresh-Build {
Write-Host "Building emitter and generator" -ForegroundColor Cyan
Invoke "npm run build:emitter"
Invoke "npm run build:emitter"
# exit if the generation failed
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public class AzureTypeFactory : ScmTypeFactory
/// </summary>
protected internal virtual IReadOnlyList<CSharpProjectWriter.CSProjDependencyPackage> AzureDependencyPackages =>
[
new("Azure.Core"),
new("System.ClientModel"),
new("System.Text.Json")
new("Azure.Core")
];

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,147 +6,147 @@
"executablePath": "dotnet"
},
"http-authentication-api-key": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/api-key -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/api-key -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-authentication-http-custom": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/http/custom -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/http/custom -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-authentication-oauth2": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/oauth2 -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/oauth2 -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-authentication-union": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/union -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/authentication/union -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-client-structure-default": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/client/structure/default -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/client/structure/default -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-encode-numeric": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/encode/numeric -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/encode/numeric -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-parameters-basic": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/basic -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/basic -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-parameters-body-optionality": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/body-optionality -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/body-optionality -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-parameters-spread": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/spread -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/parameters/spread -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-payload-content-negotiation": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/content-negotiation -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/content-negotiation -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-payload-json-merge-patch": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/json-merge-patch -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/json-merge-patch -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-payload-media-type": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/media-type -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/payload/media-type -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-serialization-encoded-name-json": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/serialization/encoded-name/json -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/serialization/encoded-name/json -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-server-endpoint-not-defined": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/endpoint/not-defined -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/endpoint/not-defined -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-server-path-single": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/path/single -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/path/single -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-server-versions-not-versioned": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/versions/not-versioned -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/server/versions/not-versioned -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-special-headers-conditional-request": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-headers/conditional-request -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-headers/conditional-request -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-special-headers-repeatability": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-headers/repeatability -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-headers/repeatability -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-special-words": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-words -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/special-words -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-streaming-jsonl": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/streaming/jsonl -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/streaming/jsonl -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-enum-fixed": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/enum/fixed -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/enum/fixed -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-empty": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/empty -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/empty -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-inheritance-nested-discriminator": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/nested-discriminator -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/nested-discriminator -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-inheritance-not-discriminated": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/not-discriminated -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/not-discriminated -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-inheritance-recursive": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/recursive -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/recursive -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-inheritance-single-discriminator": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/single-discriminator -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/single-discriminator -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-usage": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/usage -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/usage -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-model-visibility": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/visibility -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/visibility -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
},
"http-type-property-nullable": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/nullable -g AzureClientGenerator",
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/nullable -g AzureStubGenerator",
"commandName": "Executable",
"executablePath": "dotnet"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>
</Project>
Loading