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

openapi.yamlに関してのlinterを設定 #25

Merged
merged 8 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
15 changes: 15 additions & 0 deletions .github/workflows/check_openapi_format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: OpenAPI validation

on:
pull_request:
paths:
- 'openapi.yaml'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Lint OpenAPI
run: npx @stoplight/spectral-cli lint openapi.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

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

これをローカルでもnpm run lint で走らせられるようにpackage.json変更しといてもらっていいかな?

Copy link
Author

Choose a reason for hiding this comment

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

あ、承知しました!

Copy link
Author

Choose a reason for hiding this comment

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

346705d こちらにて修正しました🙇‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

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

ここもnpm run lint で書き換えてもらえると

Copy link
Author

Choose a reason for hiding this comment

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

bf68749 こちらにて修正しました!🙇‍♂️

19 changes: 19 additions & 0 deletions .spectral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends: ['spectral:oas', 'spectral:asyncapi']
aliases:
PathItem:
- $.paths[*]
OperationObject:
- '#PathItem[get,put,post,delete,options,head,patch,trace]'
rules:
oas3-valid-media-example: off
Copy link
Author

@yossydev yossydev Nov 24, 2022

Choose a reason for hiding this comment

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

stoplightのバグで、

OpenAPIが定義しているexampleオブジェクトについて知らないので、idをスキーマidとして解釈している

というものがあり、色々試しましたが解消ができなかったのでlintをoffにしています。

対象 Issue

operation-tags: error
operation-id-camel-case:
description: Operation IDs must be camelCase since some generators (e.g. RTK Query) don't support kebab-cases.
message: 'Operation ID "{{value}}" must be camelCase since some generators (e.g. RTK Query) don''t support kebab-cases.'
given: '#OperationObject'
severity: error
then:
field: operationId
function: casing
functionOptions:
type: camel
82 changes: 62 additions & 20 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@ x-stoplight:
info:
title: radio_openapi
version: '1.0'
description: radio_openapi
contact:
name: Anycloud
email: info@anycloud.co.jp
url: https://anycloud.co.jp/
servers:
- url: ''
description: Production server
- url: ''
description: Staging server
- url: ''
description: Development server
- url: 'http://127.0.0.1:4010'
description: Development Mockserver
paths:
/programs:
post:
summary: Create Program
operationId: create-program
operationId: createProgram
description: Radioプログラム登録API
requestBody:
$ref: '#/components/requestBodies/Program'
Expand All @@ -20,13 +34,13 @@ paths:
parameters: []
get:
summary: List of programs available to members
operationId: get-programs
operationId: getPrograms
description: 主にマイページ向けの、特定の会員の拝聴可能なRadioプログラムの一覧取得API
responses:
'200':
$ref: '#/components/responses/Programs'
tags:
- program
- programs
'/programs/{id}':
parameters:
- schema:
Expand All @@ -36,7 +50,7 @@ paths:
required: true
get:
summary: Get program's chapters
operationId: get-program-chapters
operationId: getProgramChapters
description: プログラム内の音声データ一覧を取得するAPI
responses:
'200':
Expand All @@ -45,14 +59,16 @@ paths:
- programs
put:
summary: Edit program
operationId: put-program
operationId: putProgram
description: Radioプログラム編集API(オーナー向け)
parameters: []
requestBody:
$ref: '#/components/requestBodies/Program'
responses:
'200':
$ref: '#/components/responses/Program'
tags:
- programs
'/programs/of_club/{slug}':
parameters:
- schema:
Expand All @@ -65,7 +81,7 @@ paths:
responses:
'200':
$ref: '#/components/responses/Programs'
operationId: get-club-programs
operationId: getClubPrograms
description: クラブに登録されているプログラム一覧を取得するAPI
parameters:
- schema:
Expand All @@ -86,7 +102,7 @@ paths:
responses:
'200':
$ref: '#/components/responses/Programs'
operationId: get-club-programs-for-owner
operationId: getClubProgramsForOwner
description: クラブに登録されているプログラム一覧を取得するAPI。オーナー管理画面向け(下書きでフィルター機能がある)
parameters:
- schema:
Expand All @@ -111,7 +127,7 @@ paths:
parameters: []
patch:
summary: Switch reserved all program to publish
operationId: patch-programs-reserved_to_pubslish
operationId: patchProgramsReservedToPublish
responses:
'200':
description: OK
Expand All @@ -131,7 +147,7 @@ paths:
summary: Get Reactions Comment
tags:
- reaction_comments
operationId: get-program-reactionComments
operationId: getProgramReactionComments
description: 特定のプログラムのリアクションコメントを取得するAPI
responses:
'200':
Expand All @@ -154,13 +170,15 @@ paths:
required: true
post:
summary: ''
operationId: post-program-reactionComments
operationId: postProgramReactionComments
responses:
'200':
$ref: '#/components/responses/ReactionComment'
description: 特定のプログラムにリアクションコメントをするAPI
requestBody:
$ref: '#/components/requestBodies/ReactionComment'
tags:
- reaction_comments
'/reaction_comments/like_toggle/{commentId}':
parameters:
- schema:
Expand All @@ -170,7 +188,7 @@ paths:
required: true
patch:
summary: Like ON/OFF
operationId: patch-reaction_comments-like_toggle-id
operationId: patchReactionCommentsLikeToggleId
responses:
'200':
$ref: '#/components/responses/ReactionComment'
Expand All @@ -186,7 +204,7 @@ paths:
required: true
delete:
summary: Delete Reaction Comment
operationId: delete-reaction_comments-commentId
operationId: deleteReactionCommentsCommentId
description: リアクションコメントを削除するAPI。(コメント投稿者向け)
responses:
'200':
Expand All @@ -195,7 +213,7 @@ paths:
- reaction_comments
patch:
summary: Hidden Reaction Comment
operationId: patch-reaction_comments-commentId
operationId: patchReactionCommentsCommentId
responses:
'200':
$ref: '#/components/responses/ReactionComment'
Expand All @@ -206,7 +224,7 @@ paths:
parameters: []
post:
summary: Start record chapter play log.
operationId: chapter-of_play_log-start-chapterId
operationId: chapterOfPlayLogStartChapterId
responses:
'200':
$ref: '#/components/responses/ChapterPlayLog'
Expand All @@ -228,7 +246,7 @@ paths:
type: integer
put:
summary: End record chapter play log.
operationId: chapter-of_play_log-end-chapterId
operationId: chapterOfPlayLogEndChapterId
responses:
'200':
$ref: '#/components/responses/ChapterPlayLog'
Expand All @@ -237,9 +255,11 @@ paths:
Request Bodyに追加して送る必要がある。
requestBody:
$ref: '#/components/requestBodies/PutChapterPlayLog'
tags:
- play_logs
get:
summary: ''
operationId: get-play_logs
operationId: getPlayLogs
responses:
'200':
$ref: '#/components/responses/PlayLogs'
Expand All @@ -249,6 +269,8 @@ paths:
type: string
in: query
name: profileId
tags:
- play_logs
'/chapters/{id}':
parameters:
- schema:
Expand All @@ -258,7 +280,7 @@ paths:
required: true
delete:
summary: Delete Chapter's media file.
operationId: delete-chapter-id
operationId: deleteChapterId
description: Chapterデータを論理削除するのと、S3から音声ファイルを削除するAPI(登録済みデータのみ。つまり、編集中のみ使うAPI)
responses:
'200':
Expand All @@ -268,18 +290,22 @@ paths:
/pre_signed_url:
post:
summary: Publish pre-signed URL
operationId: post-publish_pre_signed_url
operationId: postPublishPreSignedUrl
description: 音声メディアファイルをs3に直接アップロードするためのURLを発行するためのAPI
requestBody:
$ref: '#/components/requestBodies/PreSignedUrl'
responses:
'200':
$ref: '#/components/responses/PreSignedUrl'
tags:
- pre_signed_url
parameters: []
/healthcheck:
get:
summary: healthcheck
tags: []
description: 'healthcheck'
tags:
- healthcheck
responses:
'200':
description: OK
Expand All @@ -290,7 +316,8 @@ paths:
examples:
example:
value: OK
operationId: get-healthcheck
operationId: getHealthcheck

components:
schemas:
Program:
Expand Down Expand Up @@ -964,3 +991,18 @@ components:
type: integer
session:
type: string
tags:
- name: program
description: ''
- name: programs
description: ''
- name: reaction_comments
description: ''
- name: chapter
description: ''
- name: play_logs
description: ''
- name: pre_signed_url
description: ''
- name: healthcheck
description: ''