-
Notifications
You must be signed in to change notification settings - Fork 38
Feature/openapispec #62
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # ファイルフォーマット規約 | ||
|
|
||
| ## フォーマット | ||
|
|
||
| OpenAPI ドキュメントは JSON 形式、YAML 形式いずれかのフォーマットで記載できるが **YAML 形式** を利用する。 | ||
|
|
||
| 理由として、JSON と比較して YAML は視覚的に見やすく、レビューや差分管理が行いやすいためである。 | ||
|
|
||
| ## ファイル名 | ||
|
|
||
| ファイルの拡張子は `yaml` とする。通常ファイル名は `api.yaml` や `swagger.yaml`(v2の場合) を推奨する。 | ||
|
|
||
| もし、複数の Swagger 定義を管理するため区別したい場合は `${service}_api.yaml` とする。 | ||
|
|
||
| `${service}` にはサービス名を指定する | ||
|
|
||
| ## YAMLバージョン | ||
|
|
||
| [YAML v1.2](https://yaml.org/spec/1.2.2/#61-indentation-spaces)を用いる。 | ||
|
|
||
| ## ファイルレイアウト | ||
|
|
||
| - ファイルの最終行には空行を入れる | ||
| - 文字コードは UTF-8 とする | ||
| - タブは半角スペース 2 つとする | ||
|
|
||
| ## クォート | ||
|
|
||
| クォートは可読性を上げるために、できる限り利用しない。利用する場合はダブルクォートを利用する。 | ||
|
|
||
| ```yaml | ||
| # OK | ||
| description: 何かしらの説明 | ||
|
|
||
| # NG(クォートでのラップは不要) | ||
| description: '何かしらの説明' | ||
| description: "何かしらの説明" | ||
| ``` | ||
| 以下の場合は必須で利用する | ||
| - 文字列として認識させる必要のある数字("0123") | ||
| - 60 進数と認識させたくない場合("12:34") | ||
| - Bool として認識させたくない("true", "false", "yes", "no", "y", "n", "on", "off") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 「YAML 1.2を用いる」とあるにもかかわらず、YAML 1.2ではboolとして認識しない「"yes", "no", "y", "n", "on", "off"」が例として書いてあるのは違和感があります。また、60進数も同様です。 |
||
| - `#` で始まる文字列(`#` はコメントを示す記号のためである。例: `#/definitions/Users`) | ||
|
|
||
| ## YAML配列スタイル | ||
|
|
||
| - 複数項目を指定する場合は、 **Flow style(配列スキーム)** を用いることを推奨する | ||
|
|
||
| ```yaml | ||
| # OK(推奨: 配列リテラル構文) | ||
| required: [user_id, user_name, account_type, register_at] | ||
| # NG(非推奨: リスト構文) | ||
| required: | ||
| - user_id | ||
| - user_name | ||
| - account_type | ||
| - register_at | ||
| ``` | ||
|
|
||
| - YAML は項目定義がネストすることで縦長な定義になりやすい。情報密度を上げるために配列リテラルを推奨する | ||
|
|
||
| ## 改行の表現 | ||
|
|
||
| 改行を含む場合は、パイプ(ブロックスカラー) `|` を用いる | ||
|
|
||
| ```yaml | ||
| description: | | ||
| 説明文1 | ||
| 説明文2 | ||
| - 箇条書き1 | ||
| - 箇条書き2 | ||
| - 箇条書き3 | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このリンクは正しいですか?