Reputation: 105
My project is an AspNet Core 2.2 Api, I am building it in Azure Pipelines (classic) I want to generate the swagger document during an azure pipeline build - for this I am using Swashbuckle.AspNetCore.Cli and the documents in Retrieve Swagger Directly from a Startup Assembly
install swashbuckle.aspnetcore.cli --version 5.0.0-rc4 --global
, this seemed to work; If I run this task again it fails with message that tool is already installed.Then in my CI Build, I added a .NET Core task with settings
swagger
tofile --output $(Build.ArtifactStagingDirectory)/swagger.json $($(Build.ArtifactStagingDirectory)_Dxxxxx.Api.dll v1
I'm getting this error No executable found matching command "dotnet-swagger"
Upvotes: 1
Views: 4972
Reputation: 1777
Here is a working example using the JAR maintained by the Swagger Codegen team.
I used the public microsoft speech-to-text-api-v3
API but feel free to change it.
trigger:
- master
variables:
jar_version: 3.0.29
- job: swagger_client
pool:
vmImage: 'ubuntu-latest'
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
displayName: 'Set-up Java'
- script: |
java -version
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/$(jar_version)/swagger-codegen-cli-$(jar_version).jar -O swagger-codegen-cli.jar
java -jar swagger-codegen-cli.jar generate \
-i https://westus.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/export\?DocumentFormat\=Swagger\&ApiName\=Speech%20to%20Text%20API%20v3.0 \
-l python \
-o lib/python-client
- task: DownloadPipelineArtifact@2
inputs:
patterns: 'python-client/**'
path: $(Build.SourcesDirectory)/lib/python-client
Upvotes: 0