Generate a Refit client interface and contracts from an OpenAPI specifications document using Refitter.
The path to the OpenAPI document (both JSON and YAML are supported). Defaults to "openapi.json" (i.e. a file in the current directory called openapi.json). Paths that do not start with /
are assumed to be relative to the root of the repository.
The URL to load the OpenAPI document from. If set, openapi-file
will be ignored.
The default namespace used for the generated types (default: GeneratedCode
)
Return Task<IApiResponse<T>>
instead of Task<T>
Use cancellation tokens
Additional arguments to pass through to the Refitter CLI tool.
Setting this will publish the generated code as C# files as build artifacts
Setting this will package the generated code into a NuGet package and publish this as a build artifact. The following inputs are Required when client-sdk
is enabled
No outputs are returned. The generated client is placed in the current directory and called Output.cs which contains both the Refit interface and the contract types used by the API
jobs:
smoke-test-url:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Use the action to generate a Refit client interface
# This produces a file called Output.cs as a build artifact
- uses: christianhelle/refitter-action@main
name: Generate Refit Client
with:
openapi-file: openapi.json
namespace: ChristianHelle.Examples.Petstore.v3
# Do something with the generated client (like include it in an existing project)
- run: Get-Content Output.cs | Write-Host
shell: pwsh
jobs:
smoke-test-url-with-client-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Use the action to generate a Refit client interface
# This produces a NuGet package as a build artifact
- uses: christianhelle/refitter-action@main
name: Generate Refit Client SDK
with:
openapi-url: https://petstore3.swagger.io/api/v3/openapi.json
namespace: ChristianHelle.Examples.Petstore.v3
client-sdk: true
client-sdk-version: 3.0.${{ github.run_number }}
client-sdk-package-id: ChristianHelle.Examples.Petstore.v3
client-sdk-title: ChristianHelle.Examples.Petstore.v3
client-sdk-root-namespace: ChristianHelle.Examples.Petstore.v3
client-sdk-assembly: ChristianHelle.Examples.Petstore.v3
client-sdk-product: ChristianHelle.Examples.Petstore.v3
client-sdk-authors: Christian Resma Helle
client-sdk-company: Christian Resma Helle
client-sdk-description: Example generated code using Refitter and the Swagger Petstore v3 example OpenAPI specifications
client-sdk-project-url: https://github.com/christianhelle/refitter-action