name: OpenAPI Generate

on:
  workflow_call:
    inputs:
      ref:
        required: true
        type: string
      repository:
        required: true
        type: string
      artifact:
        required: true
        type: string

permissions:
  contents: read

jobs:
  main:
    name: Main
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Repository
      uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      with:
        ref: ${{ inputs.ref }}
        repository: ${{ inputs.repository }}

    - name: Configure .NET
      uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
      with:
        dotnet-version: '10.0.x'

    - name: Create File
      run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter Jellyfin.Server.Integration.Tests.OpenApiSpecTests

    - name: Upload Artifact
      uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
      with:
        name: ${{ inputs.artifact }}
        path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net10.0/openapi.json
        retention-days: 14
        if-no-files-found: error
