Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active February 26, 2022 18:31
Show Gist options
  • Save justinyoo/890cb4f3e409e237cf8405a7a343a04a to your computer and use it in GitHub Desktop.
Save justinyoo/890cb4f3e409e237cf8405a7a343a04a to your computer and use it in GitHub Desktop.
# Run the function app in background
func start &
# Send request to the function app and save it to swagger.json
curl http://localhost:7071/api/swagger.json > swagger.json
# Read swagger.json
cat swagger.json
# Run the function app in background
Start-Process -NoNewWindow func @("start")
# Send request to the function app and save it to swagger.json
Invoke-RestMethod -Method Get -Uri http://localhost:7071/api/swagger.json | `
ConvertTo-Json -Depth 100 | `
Out-File -FilePath swagger.json -Force
# Read swagger.json
Get-Content -Path swagger.json
# Change the function app runner from .ps1 to .cmd
$func = $(Get-Command func).Source.Replace(".ps1", ".cmd")
# Run the function app in background
Start-Process -NoNewWindow "$func" @("start")
# Send request to the function app and save it to swagger.json
Invoke-RestMethod -Method Get -Uri http://localhost:7071/api/swagger.json | `
ConvertTo-Json -Depth 100 | `
Out-File -FilePath swagger.json -Force
# Read swagger.json
Get-Content -Path swagger.json
name: Build
on:
push:
jobs:
build_and_test:
name: Build
runs-on: 'ubuntu-latest'
steps:
- name: Build solution
shell: pwsh
run: |
pushd MyFunctionApp
dotnet build . -c Release -v minimal
popd
- name: Generate OpenAPI document
shell: pwsh
run: |
cd MyFunctionApp
Start-Process -NoNewWindow func @("start","--verbose","false")
Start-Sleep -s 60
Invoke-RestMethod -Method Get -Uri http://localhost:7071/api/swagger.json | `
ConvertTo-Json -Depth 100 | `
Out-File -FilePath swagger.json -Force
Get-Content -Path swagger.json -Raw
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment