-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
91 lines (86 loc) · 2.72 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: "Generate C# Refit interface using Refitter"
description: "Generates a C# Refit interface using Refitter from an OpenAPI Specifications file or URL"
branding:
icon: code
color: green
inputs:
openapi-url:
description: If set, the OpenAPI document will be loaded from this URL instead of openapi-file.
required: false
openapi-file:
description: The path to the OpenAPI document to generate a client library for
required: false
default: openapi.json
namespace:
description: The default namespace used for the generated types
required: false
use-api-response:
description: Return Task<IApiResponse<T>> instead of Task<T>
required: false
default: false
type: boolean
cancellation-tokens:
description: Use cancellation tokens
required: false
default: false
type: boolean
multiple-interfaces:
type: choice
description: Generate a Refit interface for each endpoint. May be one of ByEndpoint, ByTag
options:
- ByEndpoint
- ByTag
command-args:
description: Optional, additional arguments to pass through to Refitter
required: false
type: string
publish-artifacts:
description: Setting this will publish the generated code as C# files
required: false
type: boolean
default: false
output-filename:
description: Generated output filename
required: false
type: string
default: Output.cs
runs:
using: composite
steps:
- name: Install Refitter
run: dotnet tool install --global refitter
shell: pwsh
- name: Generate Client Interface
run: |
$input = ""
if ("${{ inputs.openapi-url }}") {
$input = "${{ inputs.openapi-url }}"
} else {
$input = "${{ inputs.openapi-file }}"
}
$args = ""
if ("${{ inputs.namespace }}") {
$args = "$args --namespace ${{ inputs.namespace }}"
}
if ("${{ inputs.use-api-response }}") {
$args = "$args --use-api-response"
}
if ("${{ inputs.cancellation-tokens }}") {
$args = "$args --cancellation-tokens"
}
if ("${{ inputs.multiple-interfaces }}") {
$args = "$args --multiple-interfaces ${{ inputs.multiple-interfaces }}"
}
Write-Host "refitter $input $args ${{ inputs.command-args }}"
Start-Process refitter `
-Args "$input $args ${{ inputs.command-args }} --output ${{ inputs.output-filename }}" `
-NoNewWindow `
-PassThru `
-Wait
shell: pwsh
- name: Publish Generated Code Artifacts
if: ${{ inputs.publish-artifacts }}
uses: actions/upload-artifact@v3
with:
name: Refit C# Client Code
path: ${{ inputs.output-filename }}