Skip to content
Draft
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
18 changes: 18 additions & 0 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,21 @@ run-swagger:
openapi:
docker compose run --rm api bundle exec rake routes:oas:docs
docker compose run --rm api bundle exec rake routes:oas:build

openapi-cli:
@if [ -z "$(cmd)" ]; then \
echo "Usage: make openapi-cli cmd=\"version\""; \
exit 1; \
fi
./scripts/openapi-generator $(cmd)

openapi-generate:
spec=$${spec:-openapi/openapi.yml}; \
output=$${output:-api/generated/server}; \
generator=$${generator:-ruby-on-rails}; \
extra=$${extra:-}; \
./scripts/openapi-generator generate \
-i $$spec \
-g $$generator \
-o $$output \
$$extra
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,18 @@ nuxt.js<br>

## セットアップ
[git cloneをしたら](https://github.com/NUTFes/group-manager-2/wiki/git-clone-%E3%82%92%E3%81%97%E3%81%9F%E3%82%89)

## OpenAPI Generator
- `scripts/openapi-generator` で [openapi-generator-cli](https://github.com/OpenAPITools/openapi-generator) を Docker 経由で利用できます。
- 初回実行時は `docker` がイメージ `openapitools/openapi-generator-cli:v7.5.0` を取得します。
- 例: Rails サーバースタブを生成する場合
```bash
scripts/openapi-generator generate \
-i openapi/openapi.yml \
-g ruby-on-rails \
-o api/generated/server
```
- 生成物の出力先はマウント済みのリポジトリ内なら自由に指定できます。
- `make openapi-cli cmd="<コマンド>"` で CLI をそのまま呼び出せます(例: `cmd="version"`)。
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このドキュメントちょっと混乱しちゃうかも😵‍💫 実際のMakefileにはopenapi-cliタスクがあるけど、例としてcmd=\"version\"って書いてあるのに、実際に実行するとmake openapi-cli cmd=\"version\"になるから、具体例をもっと明確にした方がいいっぽい!💡

Suggested change
- `make openapi-cli cmd="<コマンド>"` で CLI をそのまま呼び出せます(例: `cmd="version"`)。
- `make openapi-cli cmd="<コマンド>"` で CLI をそのまま呼び出せます(例: `make openapi-cli cmd="version"`)。

Copilot uses AI. Check for mistakes.
- `make openapi-generate` では `openapi/openapi.yml` を元に Rails サーバースタブを `api/generated/server` へ生成します。
- `spec`, `output`, `generator`, `extra` を渡すと動作を上書きできます。
1 change: 0 additions & 1 deletion api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'r2-oas'
end


Expand Down
Binary file removed api/oas_docs/.docs
Binary file not shown.
Empty file removed api/oas_docs/.paths
Empty file.
Empty file removed api/oas_docs/plugins/.gitkeep
Empty file.
Empty file.
4 changes: 0 additions & 4 deletions api/oas_docs/src/external_docs.yml

This file was deleted.

2 changes: 0 additions & 2 deletions api/oas_docs/src/openapi.yml

This file was deleted.

4 changes: 0 additions & 4 deletions api/oas_docs/src/servers.yml

This file was deleted.

7 changes: 0 additions & 7 deletions api/oas_docs/src/tags.yml

This file was deleted.

Empty file removed api/oas_docs/tasks/.gitkeep
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions compose.swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ services:
ports:
- "8004:8080"
volumes:
- ./api/oas_docs/dist:/oas_docs
- ./openapi:/openapi
environment:
SWAGGER_JSON: /oas_docs/oas_doc.yml
SWAGGER_JSON: /openapi/openapi.yml
13 changes: 13 additions & 0 deletions api/oas_docs/src/info.yml → openapi/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
openapi: 3.0.0
info:
title: OAS API Document Title
description: |-
Expand All @@ -14,3 +15,15 @@ info:
name: ''
url: ''
version: 1.0.0
externalDocs:
description: ''
url: ''
Comment on lines +18 to +20
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空の文字列を設定するより、適切な値を入れるかプロパティ自体を削除した方がよいっぽい!😊 OpenAPIスキーマでは空文字列より意味のある値を入れるか、オプショナルなプロパティは省略するのがベストプラクティスなの💫

Copilot uses AI. Check for mistakes.
servers:
- url: http://localhost:3000
description: localhost
tags:
- name: venue_map
description: venue_map description
externalDocs:
description: description
url: url
Comment on lines +27 to +29
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

プレースホルダーテキスト('description', 'url')が残ってるよ〜😅 実際の値に置き換えるか、もしくは適切な値がない場合はこのセクション自体を削除した方がいいかも✨

Suggested change
externalDocs:
description: description
url: url

Copilot uses AI. Check for mistakes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions scripts/openapi-generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
IMAGE="${OPENAPI_GENERATOR_IMAGE:-openapitools/openapi-generator-cli:v7.5.0}"

if [ $# -eq 0 ]; then
set -- "help"
fi

exec docker run --rm \
-u "$(id -u):$(id -g)" \
-v "${ROOT_DIR}:/workspace" \
-w /workspace \
"${IMAGE}" "$@"