From 5a2604320dd5ec77269eae35c3f7b126863212ce Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Sat, 27 Jun 2020 21:48:20 +0900 Subject: [PATCH 1/6] [doc] add container name --- docker-compose.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 682bd06..91fa78b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,12 @@ version: '3' services : app: + container_name: app build: - context: ./ - dockerfile: ./docker/Dockerfile + context: ./ + dockerfile: ./docker/Dockerfile ports: - - '8081:80' + - '8081:80' volumes: - ./application:/var/www/application env_file: @@ -15,6 +16,7 @@ services : stdin_open: true mysql: + container_name: mysql image: mysql:5.7 volumes: - ./docker/mysql/conf.d:/etc/mysql/conf.d From 66a2bd51db6b4fb6e5aa15864d4801dd588222d6 Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Sat, 27 Jun 2020 21:50:58 +0900 Subject: [PATCH 2/6] [feat] add container swagger-editor, swagger-ui --- README.md | 27 +++++++++++++++++++++++++++ api.yml | 13 +++++++++++++ docker-compose.yml | 16 ++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 api.yml diff --git a/README.md b/README.md index 101e5a3..01cdeb1 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ PHPでエンドポイント(APIにアクセスするためのURI)を定義して、 フロントエンドから呼び出す想定をしてます +[API定義はこちら](https://github.com/acio-o9/knowledge_browser#about_APIs) + phpは7.4、Mysqlは5.7系で動いています。Laravelは7系を入れました。 ``` @@ -57,3 +59,28 @@ GUIツールなどで見る場合は下記とenvファイルのユーザで接 ホスト: 127.0.0.1 ポート: 3306 +# about APIs + +提供するAPIを下記ファイルで定義している + +- /api.yml + +## swagger-editor + +ymlファイル編集に利用する + +``` +http://localhost:8001 +``` + +画面上部のmenuより、import yml fileを選択して編集する + +// FIXME マウントして更新できるようにしたい + +## swagger-ui + +editor機能をなくしたもの + +``` +http://localhost:8002 +``` diff --git a/api.yml b/api.yml new file mode 100644 index 0000000..d2e049e --- /dev/null +++ b/api.yml @@ -0,0 +1,13 @@ +openapi: 3.0.0 + +info: + title: Knowledge Browser + description: "This product can share cards: Word-Explanation lists for learning new knowledge. + If you get new knowledge, write a card on `Knowledge Browser`. + The card is checked by another member, add to card lists with member agreement. + All member using `Knowledge Browser` meets the card someday." + contact: + name: acio-o9 + url: https://github.com/acio-o9 + version: 1.0.0 + diff --git a/docker-compose.yml b/docker-compose.yml index 91fa78b..6234a2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,3 +27,19 @@ services : MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} ports: - '3306:3306' + + swagger-editor: + image: swaggerapi/swagger-editor + container_name: swagger-editor + ports: + - "8001:8080" + + swagger-ui: + image: swaggerapi/swagger-ui + container_name: swagger-ui + ports: + - "8002:8080" + volumes: + - "./api.yml:/api.yml" + environment: + SWAGGER_JSON: /api.yml From 80ceccb379d1655d6a4bf7e424c8d3ccb2f1ab31 Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Sun, 28 Jun 2020 02:33:44 +0900 Subject: [PATCH 3/6] [doc] define Card GET requests --- api.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/api.yml b/api.yml index d2e049e..ac36c26 100644 --- a/api.yml +++ b/api.yml @@ -11,3 +11,64 @@ info: url: https://github.com/acio-o9 version: 1.0.0 +servers: + - url: http://localhost:8081 + description: Development server + +paths: + /cards: + get: + summary: List all Cards. + description: Returns an array of Card model + tags: + - cards + responses: + '200': + description: A JSON array of Card model + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Card' + example: + - id: 1 + word: LGTM + explanation: Looks Good To Me + - id: 2 + word: YAGNI + explanation: You ain't gonna need it + + /cards/{cardId}: + get: + summary: Info for a specific card + description: Returns a single Card model + tags: + - cards + parameters: + - name: cardId + in: path + required: true + description: The id of the card to retrieve + schema: + type: integer + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: '#/components/schemas/Card' + +components: + schemas: + Card: + type: object + properties: + id: + type: integer + format: int64 + word: + type: string + explanation: + type: string From 70f6f2ef0338d3b28f7f0c259f6b6ad51ae2b7ad Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Mon, 29 Jun 2020 00:55:28 +0900 Subject: [PATCH 4/6] [doc] define POST method as create Card --- api.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api.yml b/api.yml index ac36c26..672c292 100644 --- a/api.yml +++ b/api.yml @@ -38,6 +38,23 @@ paths: - id: 2 word: YAGNI explanation: You ain't gonna need it + post: + summary: Create a Card + description: Create new Card + tags: + - cards + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Card' + examples: + card: + word: LGTM + explanation: Looks Good To Me + responses: + '201': + description: CREATED /cards/{cardId}: get: From dec95ae0e07e98d662e8e06c8d4bfb2327e42fbb Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Mon, 29 Jun 2020 00:56:14 +0900 Subject: [PATCH 5/6] [doc] define PUT method as update Card --- api.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/api.yml b/api.yml index 672c292..3d04d13 100644 --- a/api.yml +++ b/api.yml @@ -77,6 +77,29 @@ paths: schema: $ref: '#/components/schemas/Card' + post: + summary: Updata a card Infomation + description: Update a card Infomation + tags: + - cards + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Card' + examples: + card: + id: 1 + word: LGTM + explanation: Looks Good To Me + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: '#/components/schemas/Card' + components: schemas: Card: From 471a87ea39fee930508892fad8b39f4ae8af9c6e Mon Sep 17 00:00:00 2001 From: acio-o9 Date: Sun, 28 Jun 2020 10:46:21 +0900 Subject: [PATCH 6/6] [doc] define DELETE method as delete Card --- api.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api.yml b/api.yml index 3d04d13..d9b65a4 100644 --- a/api.yml +++ b/api.yml @@ -100,6 +100,22 @@ paths: schema: $ref: '#/components/schemas/Card' + delete: + summary: Delete a card + description: Process to delete a card + tags: + - cards + parameters: + - name: cardId + in: path + required: true + description: The id of the card to retrieve + schema: + type: integer + responses: + '200': + description: Expected response to a valid request + components: schemas: Card: