diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 2c8cb8735..9c94a117e 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -22,9 +22,6 @@ variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' - REGISTRY: 'msgraphprodregistry.azurecr.io' - IMAGE_NAME: 'public/openapi/hidi' - PREVIEW_BRANCH: 'refs/heads/main' resources: repositories: @@ -51,10 +48,6 @@ extends: displayName: 'Publish Artifact: Nugets' artifactName: Nugets targetPath: '$(Build.ArtifactStagingDirectory)/Nugets' - - output: pipelineArtifact - displayName: 'Publish Artifact: RepoFiles' - artifactName: RepoFiles - targetPath: '$(Build.ArtifactStagingDirectory)/RepoFiles' steps: - task: UseDotNet@2 displayName: 'Use .NET 6' @@ -173,10 +166,6 @@ extends: - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack YamlReader' - # Pack hidi - - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - displayName: 'pack Hidi' - - task: EsrpCodeSigning@6 displayName: 'ESRP CodeSigning Nuget Packages' inputs: @@ -211,16 +200,6 @@ extends: MaxRetryAttempts: '5' PendingAnalysisWaitTimeoutMinutes: '5' - # publish hidi as an .exe - - task: DotNetCoreCLI@2 - displayName: publish Hidi as executable - inputs: - command: 'publish' - arguments: -c Release --runtime win-x64 -p:RestoreConfigFile=$(Build.SourcesDirectory)\nuget.config /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi - projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' - publishWebProjects: False - zipAfterPublish: false - - task: CopyFiles@2 displayName: Prepare staging folder for upload inputs: @@ -228,51 +207,14 @@ extends: sourceFolder: $(Build.ArtifactStagingDirectory) content: '*.nupkg' - # Copy repository files to be used in the deploy stage - - task: CopyFiles@2 - displayName: 'Copy repository files for deploy stage' - inputs: - SourceFolder: '$(Build.SourcesDirectory)' - Contents: | - **/* - !**/bin/** - !**/obj/** - !**/.git/** - TargetFolder: '$(Build.ArtifactStagingDirectory)/RepoFiles' - - stage: deploy - condition: and(or(contains(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), succeeded()) + condition: and(contains(variables['Build.SourceBranch'], 'refs/tags/v'), succeeded()) dependsOn: build pool: name: Azure-Pipelines-1ESPT-ExDShared os: linux image: ubuntu-latest jobs: - - deployment: deploy_hidi - condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) - templateContext: - type: releaseJob - isProduction: true - inputs: - - input: pipelineArtifact - artifactName: Nugets - targetPath: '$(Pipeline.Workspace)' - dependsOn: [] - environment: nuget-org - strategy: - runOnce: - deploy: - pool: - vmImage: ubuntu-latest - steps: - - task: 1ES.PublishNuget@1 - displayName: 'NuGet push' - inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg' - packageParentPath: '$(Pipeline.Workspace)' - nuGetFeedType: external - publishFeedCredentials: 'OpenAPI Nuget Connection' - - deployment: deploy_lib condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded()) templateContext: @@ -290,18 +232,10 @@ extends: pool: vmImage: ubuntu-latest steps: - - pwsh: | - $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg" - foreach($fileName in $fileNames) { - if(Test-Path $fileName) { - Remove-Item $fileName -Verbose - } - } - displayName: remove other nupkgs to avoid duplication - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: - packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg' + packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.[0-9]*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' @@ -364,139 +298,8 @@ extends: tagSource: userSpecifiedTag tag: 'v$(artifactVersion)' releaseNotesSource: inline - assets: '$(Pipeline.Workspace)\**\*.exe' addChangeLog: false - - deployment: deploy_docker_image - environment: docker-images-deploy - templateContext: - type: releaseJob - isProduction: true - inputs: - - input: pipelineArtifact - artifactName: RepoFiles - targetPath: '$(Pipeline.Workspace)' - strategy: - runOnce: - deploy: - pool: - vmImage: 'ubuntu-latest' - steps: - - task: AzureCLI@2 - displayName: 'Login to Azure Container Registry' - inputs: - azureSubscription: 'ACR Images Push Service Connection' - scriptType: bash - scriptLocation: inlineScript - inlineScript: | - az acr login --name $(REGISTRY) - - - pwsh: | - $content = [XML](Get-Content $(Pipeline.Workspace)/Directory.Build.props) - Write-Host "XML loaded, finding version..." - - # Handle PropertyGroup as either a single element or array - $version = $null - if ($content.Project.PropertyGroup -is [array]) { - Write-Host "PropertyGroup is an array, checking each entry..." - foreach ($pg in $content.Project.PropertyGroup) { - if ($pg.Version) { - $version = $pg.Version.ToString().Trim() - Write-Host "Found version in PropertyGroup array: $version" - break - } - } - } else { - # Single PropertyGroup - $version = $content.Project.PropertyGroup.Version - if ($version) { - $version = $version.ToString().Trim() - Write-Host "Found version in PropertyGroup: $version" - } - } - - if (-not $version) { - Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props" - exit 1 - } - - Write-Host "Version found: $version" - Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version" - Write-Host "##vso[task.setvariable variable=VERSION]$version" - displayName: 'Get version from csproj' - name: getversion - - - bash: | - # Debug output to verify version variable - echo "Version from previous step: $VERSION" - displayName: 'Verify version variable' - - - bash: | - echo "Build Number: $(Build.BuildNumber)" - # Extract the last 3 characters for the run number - runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$') - echo "Extracted Run Number: $runnumber" - - # If extraction fails, set a default - if [ -z "$runnumber" ]; then - echo "Extraction failed, using default value" - runnumber=$(date +"%S%N" | cut -c1-3) - echo "Generated fallback run number: $runnumber" - fi - - # Set the variable for later steps - echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber" - echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber" - displayName: 'Get truncated run number' - name: getrunnumber - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - - bash: | - date=$(date +'%Y%m%d') - echo "Date value: $date" - echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date" - echo "##vso[task.setvariable variable=BUILDDATE]$date" - displayName: 'Get current date' - name: setdate - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - - script: | - docker run --privileged --rm msgraphprodregistry.azurecr.io/tonistiigi/binfmt --install all - displayName: "Enable multi-platform builds" - - - script: | - docker buildx create --use --name mybuilder - displayName: "Set up Docker BuildX" - - - script: | - docker buildx inspect --bootstrap - displayName: "Ensure BuildX is working" - - - bash: | - echo "Building Docker image..." - echo "Using build date: ${BUILDDATE}" - # Using quotes around tags to prevent flag interpretation - docker buildx build \ - --platform linux/amd64,linux/arm64/v8 \ - --push \ - -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \ - -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \ - "$(Pipeline.Workspace)" - - displayName: 'Build and Push Nightly Image' - condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) - - - bash: | - echo "Building Docker image for release..." - docker buildx build\ - --platform linux/amd64,linux/arm64/v8 \ - --push \ - -t "$(REGISTRY)/$(IMAGE_NAME):latest" \ - -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}" \ - "$(Pipeline.Workspace)" - displayName: 'Build and Push Release Image' - condition: contains(variables['Build.SourceBranch'], 'refs/tags/v') - # once the nuget has been released, fill this form to get the public documentation updated. # https://dev.azure.com/msft-skilling/Content/_workitems/create/User%20Story?templateId=39fb91e3-64a2-4c8a-83db-b2bdf3603dd3&ownerId=c4a28f90-17ae-4384-b514-7273392b082b # https://learn.microsoft.com/en-us/dotnet/api/microsoft.openapi diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8ae3c621e..8fca113a9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -44,8 +44,7 @@ jobs: run: | $projectsArray = @( '.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj', - '.\src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj', - '.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj' + '.\src\Microsoft.OpenApi.YamlReader\Microsoft.OpenApi.YamlReader.csproj' ) $projectsArray | ForEach-Object { diff --git a/.vscode/launch.json b/.vscode/launch.json index ad2bdf11d..fb87186c4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,24 +1,6 @@ { "version": "0.2.0", "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/main/debugger-launchjson.md - "name": "Launch Hidi", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.dll", - "args": ["plugin", - "-m","${workspaceFolder}/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/exampleapimanifest.json", - "--of","./output"], - "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false - }, { // Use IntelliSense to find out which attributes exist for C# debugging // Use hover for the description of the existing attributes diff --git a/.vscode/settings.json b/.vscode/settings.json index 619467ff3..4bfa8971f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,6 @@ }, "cSpell.words": [ "csdl", - "Hidi", "Xunit" ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c61ccd31c..4372c2f45 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -29,20 +29,6 @@ "--collect:\"XPlat Code Coverage\"" ], "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "group": "build", - "args": [ - "watch", - "run", - "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7719a3839..ab18b4794 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,9 @@ OpenAPI.net is a mono-repo containing source code for the following packages: |----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Microsoft.OpenAPI](./src/Microsoft.OpenAPI/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI/) | | [Microsoft.OpenAPI.YamlReader](./src/Microsoft.OpenApi.YamlReader/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.YamlReader?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.YamlReader/) | -| [Microsoft.OpenAPI.Hidi](./src/Microsoft.OpenAPI.Hidi/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.Hidi?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.Hidi/) | + +The OpenAPI.NET v2-compatible [Microsoft.OpenApi.Hidi command line tool](https://github.com/microsoft/OpenAPI.NET.OData/blob/support/v2/src/Microsoft.OpenApi.Hidi/readme.md) is maintained separately. +Contribute to Hidi in [OpenAPI.NET.OData's support/v2 branch](https://github.com/microsoft/OpenAPI.NET.OData/tree/support/v2). OpenAPI.net is open to contributions. There are a couple of different recommended paths to get contributions into the released version of this library. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 46cb00637..000000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env -WORKDIR /app - -COPY ./src ./hidi/src -COPY ./Directory.Build.props ./hidi/Directory.Build.props -COPY ./README.md ./hidi/README.md -WORKDIR /app/hidi -RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release - -FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS runtime -WORKDIR /app - -COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net8.0 ./ - -VOLUME /app/output -VOLUME /app/openapi.yml -VOLUME /app/api.csdl -VOLUME /app/collection.json -ENV HIDI_CONTAINER=true DOTNET_TieredPGO=1 DOTNET_TC_QuickJitForLoops=1 -ENTRYPOINT ["dotnet", "Microsoft.OpenApi.Hidi.dll"] -LABEL description="# Welcome to Hidi \ -To start transforming OpenAPI documents checkout [the getting started documentation](https://github.com/microsoft/OpenAPI.NET/tree/main/src/Microsoft.OpenApi.Hidi) \ -[Source dockerfile](https://github.com/microsoft/OpenAPI.NET/blob/main/Dockerfile)" diff --git a/Microsoft.OpenApi.slnx b/Microsoft.OpenApi.slnx index 8356bb428..007071a9e 100644 --- a/Microsoft.OpenApi.slnx +++ b/Microsoft.OpenApi.slnx @@ -8,12 +8,10 @@ - - diff --git a/README.md b/README.md index 753d02588..f26ae8ea5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ |--|--| |Models and Writers|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi/) | |YamlReader | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.YamlReader.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) | -|Hidi|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Hidi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi/) The **OpenAPI.NET** SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model. @@ -86,10 +85,9 @@ var outputString = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion ``` # Validating/Testing OpenAPI descriptions -In order to test the validity of an OpenApi document, we avail the following tools: -- [Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi) - - A commandline tool for validating and transforming OpenAPI descriptions. [Installation guidelines and documentation](https://github.com/microsoft/OpenAPI.NET/blob/main/src/Microsoft.OpenApi.Hidi/readme.md) +[Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi) is a command line tool for validating and transforming OpenAPI descriptions. +The OpenAPI.NET v2-compatible tool is maintained in [OpenAPI.NET.OData's support/v2 branch](https://github.com/microsoft/OpenAPI.NET.OData/tree/support/v2/src/Microsoft.OpenApi.Hidi). +See its [installation guidelines and documentation](https://github.com/microsoft/OpenAPI.NET.OData/blob/support/v2/src/Microsoft.OpenApi.Hidi/readme.md). # Contributing diff --git a/build.cmd b/build.cmd index 43cc95956..feb43db52 100644 --- a/build.cmd +++ b/build.cmd @@ -13,11 +13,4 @@ dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts -Echo Building Microsoft.OpenApi.Hidi - -SET PROJ=%~dp0src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj -dotnet msbuild %PROJ% /t:restore /p:Configuration=Release -dotnet msbuild %PROJ% /t:build /p:Configuration=Release -dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts - :end diff --git a/build.sh b/build.sh index e716aa272..93dad1570 100755 --- a/build.sh +++ b/build.sh @@ -13,10 +13,3 @@ PROJ="$(dirname "$0")/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.cs dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release dotnet msbuild "$PROJ" /t:build /p:Configuration=Release dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" - -echo "Building Microsoft.OpenApi.Hidi" - -PROJ="$(dirname "$0")/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj" -dotnet msbuild "$PROJ" /t:restore /p:Configuration=Release -dotnet msbuild "$PROJ" /t:build /p:Configuration=Release -dotnet msbuild "$PROJ" /t:pack "/p:Configuration=Release;PackageOutputPath=$(dirname "$0")/artifacts" \ No newline at end of file diff --git a/install-tool.ps1 b/install-tool.ps1 deleted file mode 100644 index 0b4615c67..000000000 --- a/install-tool.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$latest = Get-ChildItem .\artifacts\Microsoft.OpenApi.Hidi* | select-object -Last 1 -$version = $latest.Name.Split(".")[3..5] | join-string -Separator "." - -if (Test-Path -Path ./artifacts/hidi.exe) { - dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Hidi -} -dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Hidi \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt b/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt deleted file mode 100644 index ee3bf0d40..000000000 --- a/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs deleted file mode 100644 index 1a2dc477d..000000000 --- a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using System.Collections.Generic; -using System.CommandLine; - -namespace Microsoft.OpenApi.Hidi.Extensions -{ - internal static class CommandExtensions - { - public static void AddOptions(this Command command, IReadOnlyList