Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build openapi spec from golang annotations #11

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/openapi2_golang_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
workflow_call:
inputs:
entrypoint:
required: false
type: string
default: "main.go"
workdir:
required: false
type: string
default: "./"

jobs:
build_with_swagger:
runs-on: ubuntu-latest
if: "!startsWith(github.ref, 'refs/tags/')"
container:
image: cubicrootxyz/golang-ci:v1.23.0
options: --user root
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v3
with:
node-version: "14"
- name: Get dependencies
run: (cd ${{ inputs.workdir }} && go get ./...)
- name: Make docs folder
run: mkdir -p docs
- name: Build the api documentation
run: swag init --parseDependency=true -d . -g ${{ inputs.entrypoint }}
- name: Archive OpenAPI spec
uses: actions/upload-artifact@v4
with:
name: openapi-spec
path: |
docs/
8 changes: 8 additions & 0 deletions .github/workflows/openapi2_golang_build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
on: push

jobs:
openapi2_golang_build_test:
uses: ./.github/workflows/openapi2_golang_build.yaml
with:
entrypoint: tests/openapi2/main.go
workdir: tests/openapi2/
3 changes: 3 additions & 0 deletions tests/openapi2/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module openapi2

go 1.23.0
22 changes: 22 additions & 0 deletions tests/openapi2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"os"
)

// @title Matrix Reminder and Calendar Bot (RemindMe)
// @version 2.0.0
// @description API documentation for the matrix reminder and calendar bot.

// @contact.name Support

// @host your-bot-domain.tld
// @BasePath /
// @query.collection.format multi

// @securityDefinitions.apikey APIKeyAuthentication
// @in header
// @name Authorization
func main() {
os.Exit(0)
}
Loading