-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathprepare_swagger.yml
More file actions
69 lines (55 loc) · 2.04 KB
/
prepare_swagger.yml
File metadata and controls
69 lines (55 loc) · 2.04 KB
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
name: Convert Swagger to OpenAPI
# This workflow demonstrates how to use the prepare/swagger action to convert
# Swagger 2.0 specs to OpenAPI 3.x format. It can run on pull requests or pushes
# to automatically convert and commit the updated spec.
on:
pull_request:
paths:
- "swagger.json"
- "swagger.yaml"
push:
branches:
- main
paths:
- "swagger.json"
- "swagger.yaml"
permissions:
contents: write
pull-requests: write
jobs:
convert-swagger:
runs-on: ubuntu-latest
steps:
# IMPORTANT: Always checkout the repository first!
# Without this step, the action cannot access your spec files.
- name: Checkout code
uses: actions/checkout@v6
with:
# Use the pull request head ref for PRs, otherwise use the default branch
ref: ${{ github.head_ref || github.ref }}
# Required for committing changes back to the repository
token: ${{ secrets.GITHUB_TOKEN }}
- name: Convert Swagger to OpenAPI
uses: stainless-api/upload-openapi-spec-action/prepare/swagger@v1
with:
# Path to your Swagger 2.0 spec file
input_path: ./swagger.json
# Path where the converted OpenAPI 3.x spec will be written
output_path: ./openapi.json
# Fix up small errors in the source definition
patch: false
# Resolve external references
resolve: true
# Target OpenAPI version: '3.0' or '3.1'
target_version: "3.0"
# Whether to commit the converted file
commit: true
# Commit message (only used if commit is true)
commit_message: "chore: convert Swagger 2.0 to OpenAPI 3.x"
# GitHub token for committing (defaults to GITHUB_TOKEN)
github_token: ${{ secrets.GITHUB_TOKEN }}
# Optional: Use the converted spec in subsequent steps
- name: Display conversion result
run: |
echo "Conversion complete!"
echo "Output file: ${{ steps.convert.outputs.output_path }}"