From 7d03676f397e67b91a9cdde09981dcfb8bb29636 Mon Sep 17 00:00:00 2001 From: Park Jeongseop Date: Tue, 5 Sep 2023 00:52:50 +0900 Subject: [PATCH] Feat/37 API Docs file type json to yaml (#80) --- .../workflows/generate-open-api-document.yml | 10 +- docs/open-api.json | 1 - docs/open-api.yaml | 435 ++++++++++++++++++ docs/swagger-initializer.js | 2 +- .../ticketingservice/config/SecurityConfig.kt | 2 +- 5 files changed, 442 insertions(+), 8 deletions(-) delete mode 100644 docs/open-api.json create mode 100644 docs/open-api.yaml diff --git a/.github/workflows/generate-open-api-document.yml b/.github/workflows/generate-open-api-document.yml index 559a8c19..8da32cc0 100644 --- a/.github/workflows/generate-open-api-document.yml +++ b/.github/workflows/generate-open-api-document.yml @@ -19,24 +19,24 @@ jobs: - name: Check the deployed service URL uses: jtalk/url-health-check-action@v3 with: - url: http://localhost:8080/api-docs + url: http://localhost:8080/api-docs.yaml max-attempts: 10 retry-delay: 5s retry-all: true - name: Create json file run: | - curl -o docs/open-api.json http://localhost:8080/api-docs + curl -o docs/open-api.yaml http://localhost:8080/api-docs.yaml - name: Commit changes run: | git config --global user.name 'Git Actions' git config --global user.email 'no-reply@github.com' - git add docs/open-api.json + git add docs/open-api.yaml if git status | grep -ic "Changes to be committed:"; then echo "Committing changes" - git commit -m "docs: update open-api.json" + git commit -m "docs: update open-api.yaml" git push else echo "No changes" @@ -44,4 +44,4 @@ jobs: - name: Stop containers if: always() - run: docker-compose -f "docker-compose.yml" down \ No newline at end of file + run: docker-compose -f "docker-compose.yml" down diff --git a/docs/open-api.json b/docs/open-api.json deleted file mode 100644 index 7462bf3f..00000000 --- a/docs/open-api.json +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"프동프동 티켓팅 시스템 API Document","description":"티켓팅 시스템 백엔드 API입니다.","version":"1.0.0"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"paths":{"/reservations/{id}":{"get":{"tags":["reservation-controller"],"operationId":"getReservation","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReservationResponse"}}}}}},"put":{"tags":["reservation-controller"],"operationId":"updateReservation","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReservationUpdateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReservationResponse"}}}}}},"delete":{"tags":["reservation-controller"],"operationId":"deleteReservation","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK"}}}},"/events/{id}":{"get":{"tags":["event-controller"],"operationId":"getEvent","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/EventResponse"}}}}}},"put":{"tags":["event-controller"],"operationId":"updateEvent","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventCreateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/EventResponse"}}}}}},"delete":{"tags":["event-controller"],"operationId":"deleteEvent","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Unit"}}}}}}},"/users/signup":{"post":{"tags":["user-controller"],"operationId":"signup","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignUpRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UserDto"}}}}}}},"/reservations":{"post":{"tags":["reservation-controller"],"operationId":"createReservation","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReservationCreateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReservationResponse"}}}}}}},"/events":{"post":{"tags":["event-controller"],"operationId":"createEvent","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventCreateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/EventResponse"}}}}}}},"/bookmarks":{"get":{"tags":["bookmark-controller"],"operationId":"getBookmarks","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}},"post":{"tags":["bookmark-controller"],"operationId":"addBookmark","parameters":[{"name":"boardFormDto","in":"query","required":true,"schema":{"$ref":"#/components/schemas/BookmarkFromdto"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},"/users/access_token_info":{"get":{"tags":["user-controller"],"operationId":"getAccessTokenInfo","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object","additionalProperties":{"type":"object"}}}}}}}},"/health":{"get":{"tags":["health-controller"],"operationId":"healthCheck2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},"/events/":{"get":{"tags":["event-controller"],"operationId":"getEvents","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/EventResponse"}}}}}}}},"/bookmarks/{id}":{"get":{"tags":["bookmark-controller"],"operationId":"getBookmark","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}},"delete":{"tags":["bookmark-controller"],"operationId":"deleteBookmark","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},"/":{"get":{"tags":["health-controller"],"operationId":"healthCheck1_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}}},"components":{"schemas":{"ReservationUpdateRequest":{"required":["eventId"],"type":"object","properties":{"eventId":{"type":"integer","format":"int64"}}},"ReservationResponse":{"required":["bookedAt","eventId","id","userId"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"eventId":{"type":"integer","format":"int64"},"userId":{"type":"integer","format":"int64"},"bookedAt":{"type":"string","format":"date-time"}}},"EventCreateRequest":{"required":["date","maxAttendees","reservationEndTime","reservationStartTime","title"],"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string","format":"date-time"},"reservationStartTime":{"type":"string","format":"date-time"},"reservationEndTime":{"type":"string","format":"date-time"},"maxAttendees":{"type":"integer","format":"int32"}}},"EventResponse":{"required":["date","id","maxAttendees","reservationEndTime","reservationStartTime","title"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"title":{"type":"string"},"date":{"type":"string","format":"date-time"},"reservationStartTime":{"type":"string","format":"date-time"},"reservationEndTime":{"type":"string","format":"date-time"},"maxAttendees":{"type":"integer","format":"int32"}}},"SignUpRequest":{"required":["email","name","password"],"type":"object","properties":{"email":{"type":"string"},"name":{"maxLength":30,"minLength":2,"type":"string"},"password":{"maxLength":128,"minLength":9,"type":"string"}}},"UserDto":{"required":["email","name"],"type":"object","properties":{"name":{"type":"string"},"email":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"ReservationCreateRequest":{"required":["eventId","userId"],"type":"object","properties":{"eventId":{"type":"integer","format":"int64"},"userId":{"type":"integer","format":"int64"}}},"BookmarkFromdto":{"required":["show_id","user_id"],"type":"object","properties":{"user_id":{"type":"integer","format":"int32"},"show_id":{"type":"integer","format":"int32"}}},"Unit":{"type":"object"}}}} \ No newline at end of file diff --git a/docs/open-api.yaml b/docs/open-api.yaml new file mode 100644 index 00000000..871278bf --- /dev/null +++ b/docs/open-api.yaml @@ -0,0 +1,435 @@ +openapi: 3.0.1 +info: + title: 프동프동 티켓팅 시스템 API Document + description: 티켓팅 시스템 백엔드 API입니다. + version: 1.0.0 +servers: +- url: http://localhost:8080 + description: Generated server url +paths: + /reservations/{id}: + get: + tags: + - reservation-controller + operationId: getReservation + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/ReservationResponse' + put: + tags: + - reservation-controller + operationId: updateReservation + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ReservationUpdateRequest' + required: true + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/ReservationResponse' + delete: + tags: + - reservation-controller + operationId: deleteReservation + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + /events/{id}: + get: + tags: + - event-controller + operationId: getEvent + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/EventResponse' + put: + tags: + - event-controller + operationId: updateEvent + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EventCreateRequest' + required: true + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/EventResponse' + delete: + tags: + - event-controller + operationId: deleteEvent + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/Unit' + /users/signup: + post: + tags: + - user-controller + operationId: signup + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SignUpRequest' + required: true + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/UserDto' + /reservations: + post: + tags: + - reservation-controller + operationId: createReservation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ReservationCreateRequest' + required: true + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/ReservationResponse' + /events: + post: + tags: + - event-controller + operationId: createEvent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EventCreateRequest' + required: true + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/EventResponse' + /bookmarks: + get: + tags: + - bookmark-controller + operationId: getBookmarks + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + post: + tags: + - bookmark-controller + operationId: addBookmark + parameters: + - name: boardFormDto + in: query + required: true + schema: + $ref: '#/components/schemas/BookmarkFromdto' + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + /users/access_token_info: + get: + tags: + - user-controller + operationId: getAccessTokenInfo + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + additionalProperties: + type: object + /health: + get: + tags: + - health-controller + operationId: healthCheck2 + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + /events/: + get: + tags: + - event-controller + operationId: getEvents + responses: + "200": + description: OK + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/EventResponse' + /bookmarks/{id}: + get: + tags: + - bookmark-controller + operationId: getBookmark + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int32 + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + delete: + tags: + - bookmark-controller + operationId: deleteBookmark + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int32 + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object + /: + get: + tags: + - health-controller + operationId: healthCheck1_1 + responses: + "200": + description: OK + content: + '*/*': + schema: + type: object +components: + schemas: + ReservationUpdateRequest: + required: + - eventId + type: object + properties: + eventId: + type: integer + format: int64 + ReservationResponse: + required: + - bookedAt + - eventId + - id + - userId + type: object + properties: + id: + type: integer + format: int64 + eventId: + type: integer + format: int64 + userId: + type: integer + format: int64 + bookedAt: + type: string + format: date-time + EventCreateRequest: + required: + - date + - maxAttendees + - reservationEndTime + - reservationStartTime + - title + type: object + properties: + title: + type: string + date: + type: string + format: date-time + reservationStartTime: + type: string + format: date-time + reservationEndTime: + type: string + format: date-time + maxAttendees: + type: integer + format: int32 + EventResponse: + required: + - date + - id + - maxAttendees + - reservationEndTime + - reservationStartTime + - title + type: object + properties: + id: + type: integer + format: int64 + title: + type: string + date: + type: string + format: date-time + reservationStartTime: + type: string + format: date-time + reservationEndTime: + type: string + format: date-time + maxAttendees: + type: integer + format: int32 + SignUpRequest: + required: + - email + - name + - password + type: object + properties: + email: + type: string + name: + maxLength: 30 + minLength: 2 + type: string + password: + maxLength: 128 + minLength: 9 + type: string + UserDto: + required: + - email + - name + type: object + properties: + name: + type: string + email: + type: string + createdAt: + type: string + format: date-time + ReservationCreateRequest: + required: + - eventId + - userId + type: object + properties: + eventId: + type: integer + format: int64 + userId: + type: integer + format: int64 + BookmarkFromdto: + required: + - show_id + - user_id + type: object + properties: + user_id: + type: integer + format: int32 + show_id: + type: integer + format: int32 + Unit: + type: object diff --git a/docs/swagger-initializer.js b/docs/swagger-initializer.js index 4957cd3e..12b3bac9 100644 --- a/docs/swagger-initializer.js +++ b/docs/swagger-initializer.js @@ -3,7 +3,7 @@ window.onload = function() { // the following lines will be replaced by docker/configurator, when it runs in a docker-container window.ui = SwaggerUIBundle({ - url: "open-api.json", + url: "open-api.yaml", dom_id: '#swagger-ui', deepLinking: true, presets: [ diff --git a/src/main/kotlin/com/group4/ticketingservice/config/SecurityConfig.kt b/src/main/kotlin/com/group4/ticketingservice/config/SecurityConfig.kt index 15acc56c..349fb4ed 100644 --- a/src/main/kotlin/com/group4/ticketingservice/config/SecurityConfig.kt +++ b/src/main/kotlin/com/group4/ticketingservice/config/SecurityConfig.kt @@ -21,7 +21,7 @@ class SecurityConfig( private val tokenProvider: TokenProvider ) { - private val allowedUrls = arrayOf("/", "/api-docs", "/health", "/users/signup", "/bookmarks/**", "/reservations/**", "/events/**") + private val allowedUrls = arrayOf("/", "/api-docs.yaml", "/health", "/users/signup", "/bookmarks/**", "/reservations/**", "/events/**") @Bean fun filterChain(http: HttpSecurity): DefaultSecurityFilterChain {