Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cba1f47
Initial plan
Copilot Jul 23, 2025
0f4a431
Complete API implementation with Go Gin framework and Swagger documen…
Copilot Jul 23, 2025
e44aa84
Initial plan
Copilot Jul 23, 2025
a143ccf
Add react-native-maps dependency and map tab with route display
Copilot Jul 23, 2025
107e1c2
Complete react-native-maps implementation with platform-specific support
Copilot Jul 23, 2025
93d5aae
📃 docs: README new line
naoki-00-ito Jul 27, 2025
3e5f49b
🐳 chore: update mod
naoki-00-ito Jul 27, 2025
0f8031a
Initial plan to address OpenAPI 3.0.3 upgrade and swag init issues
Copilot Jul 27, 2025
6785798
✅ Upgrade to OpenAPI 3.0.3 and fix swag init command issues
Copilot Jul 27, 2025
16a1d73
Fix iOS Text component error by removing space in empty fragment
Copilot Jul 27, 2025
2815138
Merge pull request #20 from rowicy/copilot/fix-7
naoki-00-ito Jul 27, 2025
bf231cd
Initial plan
Copilot Jul 27, 2025
65164d4
🔧 Implement pure Go-based OpenAPI 3.0.3 generation without npm depend…
Copilot Jul 27, 2025
726b0fa
Implement TanStack Query migration for data fetching
Copilot Jul 27, 2025
0b7596d
Fix React Native error by replacing HTML elements with proper RN comp…
Copilot Jul 27, 2025
fca013d
Merge pull request #22 from rowicy/copilot/fix-21
naoki-00-ito Jul 27, 2025
f600f60
✅ Fix backup file generation and add comprehensive response examples …
Copilot Jul 27, 2025
c7ba8e9
🔄 Revert to Swagger 2.0 format and fix syntax errors
Copilot Jul 27, 2025
bcfdd8f
🐳 chore: remove docs
naoki-00-ito Jul 27, 2025
02e3382
🐳 chore: npm script
naoki-00-ito Jul 27, 2025
3075eae
🔄 Upgrade to OpenAPI 3.0.3 with comprehensive examples and working Re…
Copilot Jul 27, 2025
8dba43d
✅ Implement complete swag init to OpenAPI 3.0.3 workflow with React N…
Copilot Jul 27, 2025
bc1f9fc
📚 Add OpenAPI generation documentation and workflow test
Copilot Jul 27, 2025
5d8c0cc
Fix: Use Node.js version from mobile-app/.nvmrc in GitHub Actions
Copilot Jul 27, 2025
6cec75f
Fix GitHub Actions workflow style to match mobile-app-test.yml
Copilot Jul 27, 2025
7c4092c
Fix workflow name and remove paths-ignore to run on all PRs
Copilot Jul 27, 2025
6ab6e96
Fix: Update Node.js setup step name in GitHub Actions workflow and ad…
naoki-00-ito Jul 27, 2025
0e651f8
Merge pull request #19 from rowicy/copilot/fix-2-3
naoki-00-ito Jul 27, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/mobile-app-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
working-directory: ${{ env.WORKING_DIRECTORY }}
steps:
- uses: actions/[email protected]
- name: Use Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: mobile-app/.nvmrc
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/project-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@ name: Test Project

on:
pull_request:
paths-ignore:
- api/**
- mobile-app/**

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: mobile-app/.nvmrc

- name: Test OpenAPI generation workflow
run: |
chmod +x ./generate-openapi.sh
./generate-openapi.sh

- name: Run ls-lint
uses: ls-lint/action@v2
with:
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@ This is a template for mobile app development using:

This is a template for building APIs using:

- [Go](https://go.dev/) // TODO: 選定して更新
- [Go](https://go.dev/) with [Gin](https://gin-gonic.com/) framework
- [gin-swagger](https://github.com/swaggo/gin-swagger) for OpenAPI/Swagger generation

## [openapi-specifications](./openapi-specifications)

This directory contains OpenAPI specifications swagger files.
OpenAPI version 3.0 is used for the specifications, and the files are in JSON format.

To generate the OpenAPI definitions, run the following command from the repository root:

```bash
./generate-openapi.sh
```

This script will:

1. Generate Swagger 2.0 documentation using `swag init` in the API directory
2. Convert the Swagger 2.0 specification to OpenAPI 3.0.3 format
3. Place the result in `openapi-specifications/api.swagger.json`
4. Verify that React Native type generation and mock server commands work correctly

- [OpenAPI](https://www.openapis.org/)
- [Swagger](https://swagger.io/)

Expand Down
41 changes: 41 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Application specific
main
*.log

# generated files
docs
32 changes: 32 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Build stage
FROM golang:1.21-alpine AS builder

WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy source code
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

# Final stage
FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

# Copy the pre-built binary file from the previous stage
COPY --from=builder /app/main .

# Expose port 8080
EXPOSE 8080

# Run the binary
CMD ["./main"]
111 changes: 111 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,112 @@
# API

This is a template API implementation using Go and the Gin framework, with automatic Swagger documentation generation.

## Technology Stack

- **[Go](https://go.dev/)** - Programming language
- **[Gin](https://gin-gonic.com/)** - Web framework
- **[gin-swagger](https://github.com/swaggo/gin-swagger)** - Swagger/OpenAPI documentation generation

## Features

- RESTful API endpoints
- Automatic Swagger/OpenAPI documentation
- **Automated Swagger 2.0 to OpenAPI 3.0.3 conversion** (pure Go implementation)
- CORS support
- Health check endpoint
- Example integration with external API (JSONPlaceholder)
- Proper error handling and response formatting

## Getting Started

### Prerequisites

- Go 1.21 or higher
- Internet connection (for external API calls)

### Installation

1. Navigate to the API directory:
```bash
cd api
```

2. Install dependencies:
```bash
go mod tidy
```

3. Install swag tool (for Swagger generation):
```bash
go install github.com/swaggo/swag/cmd/swag@latest
```

4. Ensure swag is in your PATH (add this to your shell profile if needed):
```bash
export PATH=$PATH:$(go env GOPATH)/bin
```

### Running the API

1. Generate OpenAPI 3.0.3 documentation:
```bash
# From repository root directory
./generate-openapi.sh
```

2. Start the server:
```bash
go run main.go
```

The API will be available at `http://localhost:8080`

### API Endpoints

- `GET /api/v1/health` - Health check
- `GET /api/v1/posts` - Get all posts from JSONPlaceholder
- `GET /api/v1/posts/{id}` - Get a specific post by ID
- `GET /swagger/index.html` - Swagger UI documentation

### Swagger Documentation

The API automatically generates OpenAPI/Swagger documentation through the following workflow:

1. **Swagger 2.0 Generation**: `swag init` generates Swagger 2.0 format in `docs/swagger.json`
2. **Conversion to OpenAPI 3.0.3**: A Go converter transforms it to OpenAPI 3.0.3 format
3. **Output**: Final specification is placed in `../openapi-specifications/api.swagger.json`

The documentation is:
- Served at `/swagger/index.html` when the server is running (Swagger 2.0 format)
- Available as OpenAPI 3.0.3 in `../openapi-specifications/api.swagger.json` for tooling

### Development

To regenerate OpenAPI 3.0.3 documentation after making changes:

**Complete workflow (Recommended):**
```bash
# From repository root
./generate-openapi.sh
```

This script will:
1. Run `swag init` to generate Swagger 2.0 documentation in `api/docs/`
2. Convert Swagger 2.0 to OpenAPI 3.0.3 format using a Go converter
3. Place the result in `openapi-specifications/api.swagger.json`
4. Test that `npm run gen-schema` and `npm run mock` work correctly

**Manual steps:**
```bash
# 1. Generate Swagger 2.0
cd api && swag init && cd ..

# 2. Convert to OpenAPI 3.0.3
go run convert-swagger.go

# 3. Test React Native tooling
cd mobile-app
npm run gen-schema # Generate TypeScript definitions
npm run mock # Start mock server on port 3001
```
50 changes: 50 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module template-mobile-app-api

go 1.24.5

require (
github.com/gin-gonic/gin v1.10.1
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/swaggo/swag v1.8.12 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading