From 0bc292fec166f8f3f660f23d51e581f8504b9b30 Mon Sep 17 00:00:00 2001 From: Victor Neuret Date: Tue, 2 Feb 2021 18:00:03 +0900 Subject: [PATCH] feat(doc): Improve documentation generation and display (#64) * Create new documentation architecture * Rename documentation folder to doc --- ...backend-ci-push-pre-prod-documentation.yml | 22 ++--- .../backend-ci-push-prod-documentation.yml | 22 ++--- .github/workflows/documentation-ci-build.yml | 12 +-- docker-compose.yml | 10 +- microservices/doc/app/.gitignore | 1 + .../{documentation => doc}/app/Dockerfile | 4 +- .../{documentation => doc}/app/Dockerfile-dev | 0 microservices/doc/app/auth.go | 25 +++++ microservices/doc/app/auth/info.yml | 18 ++++ .../app/auth/paths/auth.yml | 4 +- .../app/auth/paths/invitation.yml | 6 +- .../app/auth/paths/login.yml | 2 +- .../app/auth/paths/logout.yml | 4 +- .../app/auth/paths/passwordReset.yml | 8 +- .../app/auth/paths/refresh.yml | 2 +- .../app/auth/paths/register.yml | 2 +- .../app/auth/schemas/AuthRefresh.yml | 0 .../app/auth/schemas/AuthResponse.yml | 0 .../app/auth}/schemas/BadInput.yml | 0 .../app/auth}/schemas/BadRequestResponse.yml | 0 .../app/auth}/schemas/Field.yml | 0 .../app/auth/schemas/Invitation.yml | 0 .../app/auth}/schemas/NoContentResponse.yml | 0 .../schemas/UnauthorizedErrorResponse.yml | 0 .../app/auth/schemas/User.yml | 0 .../app/auth}/schemas/UserDataResponse.yml | 0 .../app/auth/schemas/UserLogin.yml | 0 .../app/auth/schemas/UserRegister.yml | 0 .../app/auth/schemas/UserResetPassword.yml | 0 .../auth/schemas/UserResetPasswordToken.yml | 0 .../app/auth/schemas/UserResponse.yml | 0 .../schemas/UserSendResetPasswordEmail.yml | 0 .../app => doc/app/auth}/security.yml | 4 +- microservices/doc/app/docs/info.yml | 25 +++++ .../{documentation => doc}/app/go.mod | 2 +- .../{documentation => doc}/app/go.sum | 0 microservices/doc/app/library.go | 25 +++++ microservices/doc/app/library/info.yml | 16 ++++ .../app/library/paths/bookMetadataCreate.yml | 6 +- .../app/library/paths/bookMetadataDelete.yml | 6 +- .../library/paths/bookMetadataRetrieve.yml | 6 +- .../app/library/paths/librariesNames.yml | 6 +- .../app/library/paths/libraryCreate.yml | 6 +- .../app/library/paths/libraryDelete.yml | 6 +- .../app/library/paths/libraryRetrieve.yml | 6 +- .../doc/app/library/schemas/BadInput.yml | 10 ++ .../library/schemas/BadRequestResponse.yml | 9 ++ .../schemas/BookMetadataCreateRequest.yml | 0 .../schemas/BookMetadataCreateResponse.yml | 0 .../schemas/BookMetadataDeleteRequest.yml | 0 .../schemas/BookMetadataDeleteResponse.yml | 0 .../schemas/BookMetadataRetrieveRequest.yml | 0 .../schemas/BookMetadataRetrieveResponse.yml | 0 .../doc/app/library/schemas/Field.yml | 10 ++ .../library/schemas/LibrariesNamesData.yml | 0 .../LibrariesNamesRetrieveResponse.yml | 0 .../library/schemas/LibraryCreateRequest.yml | 0 .../library/schemas/LibraryCreateResponse.yml | 0 .../library/schemas/LibraryDeleteRequest.yml | 0 .../library/schemas/LibraryDeleteResponse.yml | 0 .../schemas/LibraryRetrieveRequest.yml | 0 .../schemas/LibraryRetrieveResponse.yml | 0 .../schemas/UnauthorizedErrorResponse.yml | 0 microservices/doc/app/library/security.yml | 9 ++ .../{documentation => doc}/app/main.go | 0 microservices/doc/app/media.go | 25 +++++ microservices/doc/app/media/info.yml | 13 +++ .../app/media/paths/download.yml | 4 +- .../app/media/paths/upload.yml | 4 +- .../doc/app/media/schemas/BadInput.yml | 10 ++ .../app/media/schemas/BadRequestResponse.yml | 9 ++ .../app/media/schemas/DownloadRequest.yml | 0 .../app/media/schemas/DownloadResponse.yml | 0 microservices/doc/app/media/schemas/Field.yml | 10 ++ .../schemas/UnauthorizedErrorResponse.yml | 5 + .../app/media/schemas/UploadRequest.yml | 0 .../app/media/schemas/UploadResponse.yml | 0 microservices/doc/app/media/security.yml | 9 ++ microservices/doc/app/mergeFile.go | 74 +++++++++++++++ .../configs.txt => doc/app/merged/.gitadd} | 0 .../{documentation => doc}/app/rooting.go | 40 ++++++-- microservices/doc/app/template.go | 94 +++++++++++++++++++ microservices/doc/app/user.go | 25 +++++ microservices/doc/app/user/info.yml | 13 +++ .../app/user/paths/User.yml | 14 +-- .../doc/app/user/schemas/BadInput.yml | 10 ++ .../app/user/schemas/BadRequestResponse.yml | 9 ++ microservices/doc/app/user/schemas/Field.yml | 10 ++ .../app/user/schemas/NoContentResponse.yml | 0 .../schemas/UnauthorizedErrorResponse.yml | 5 + microservices/doc/app/user/schemas/User.yml | 27 ++++++ .../app/user/schemas/UserData.yml | 0 .../doc/app/user/schemas/UserDataResponse.yml | 22 +++++ microservices/doc/app/user/security.yml | 9 ++ .../deployment/preprod}/app/Deployment.yaml | 6 +- .../deployment/preprod/app/Ingress.yaml | 2 +- .../deployment/preprod}/configs.txt | 0 .../deployment/prod}/app/Deployment.yaml | 6 +- .../deployment/prod/app/Ingress.yaml | 2 +- microservices/doc/deployment/prod/configs.txt | 0 microservices/documentation/app/.gitignore | 1 - microservices/documentation/app/info.yml | 12 --- microservices/documentation/app/mergeFile.go | 56 ----------- 103 files changed, 651 insertions(+), 169 deletions(-) create mode 100644 microservices/doc/app/.gitignore rename microservices/{documentation => doc}/app/Dockerfile (77%) rename microservices/{documentation => doc}/app/Dockerfile-dev (100%) create mode 100644 microservices/doc/app/auth.go create mode 100644 microservices/doc/app/auth/info.yml rename microservices/{documentation => doc}/app/auth/paths/auth.yml (90%) rename microservices/{documentation => doc}/app/auth/paths/invitation.yml (93%) rename microservices/{documentation => doc}/app/auth/paths/login.yml (96%) rename microservices/{documentation => doc}/app/auth/paths/logout.yml (92%) rename microservices/{documentation => doc}/app/auth/paths/passwordReset.yml (93%) rename microservices/{documentation => doc}/app/auth/paths/refresh.yml (96%) rename microservices/{documentation => doc}/app/auth/paths/register.yml (96%) rename microservices/{documentation => doc}/app/auth/schemas/AuthRefresh.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/AuthResponse.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/BadInput.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/BadRequestResponse.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/Field.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/Invitation.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/NoContentResponse.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/UnauthorizedErrorResponse.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/User.yml (100%) rename microservices/{documentation/app/general => doc/app/auth}/schemas/UserDataResponse.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserLogin.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserRegister.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserResetPassword.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserResetPasswordToken.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserResponse.yml (100%) rename microservices/{documentation => doc}/app/auth/schemas/UserSendResetPasswordEmail.yml (100%) rename microservices/{documentation/app => doc/app/auth}/security.yml (96%) create mode 100644 microservices/doc/app/docs/info.yml rename microservices/{documentation => doc}/app/go.mod (76%) rename microservices/{documentation => doc}/app/go.sum (100%) create mode 100644 microservices/doc/app/library.go create mode 100644 microservices/doc/app/library/info.yml rename microservices/{documentation => doc}/app/library/paths/bookMetadataCreate.yml (88%) rename microservices/{documentation => doc}/app/library/paths/bookMetadataDelete.yml (88%) rename microservices/{documentation => doc}/app/library/paths/bookMetadataRetrieve.yml (88%) rename microservices/{documentation => doc}/app/library/paths/librariesNames.yml (83%) rename microservices/{documentation => doc}/app/library/paths/libraryCreate.yml (86%) rename microservices/{documentation => doc}/app/library/paths/libraryDelete.yml (86%) rename microservices/{documentation => doc}/app/library/paths/libraryRetrieve.yml (87%) create mode 100644 microservices/doc/app/library/schemas/BadInput.yml create mode 100644 microservices/doc/app/library/schemas/BadRequestResponse.yml rename microservices/{documentation => doc}/app/library/schemas/BookMetadataCreateRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/BookMetadataCreateResponse.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/BookMetadataDeleteRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/BookMetadataDeleteResponse.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/BookMetadataRetrieveRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/BookMetadataRetrieveResponse.yml (100%) create mode 100644 microservices/doc/app/library/schemas/Field.yml rename microservices/{documentation => doc}/app/library/schemas/LibrariesNamesData.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibrariesNamesRetrieveResponse.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryCreateRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryCreateResponse.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryDeleteRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryDeleteResponse.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryRetrieveRequest.yml (100%) rename microservices/{documentation => doc}/app/library/schemas/LibraryRetrieveResponse.yml (100%) rename microservices/{documentation/app/media => doc/app/library}/schemas/UnauthorizedErrorResponse.yml (100%) create mode 100644 microservices/doc/app/library/security.yml rename microservices/{documentation => doc}/app/main.go (100%) create mode 100644 microservices/doc/app/media.go create mode 100644 microservices/doc/app/media/info.yml rename microservices/{documentation => doc}/app/media/paths/download.yml (90%) rename microservices/{documentation => doc}/app/media/paths/upload.yml (90%) create mode 100644 microservices/doc/app/media/schemas/BadInput.yml create mode 100644 microservices/doc/app/media/schemas/BadRequestResponse.yml rename microservices/{documentation => doc}/app/media/schemas/DownloadRequest.yml (100%) rename microservices/{documentation => doc}/app/media/schemas/DownloadResponse.yml (100%) create mode 100644 microservices/doc/app/media/schemas/Field.yml create mode 100644 microservices/doc/app/media/schemas/UnauthorizedErrorResponse.yml rename microservices/{documentation => doc}/app/media/schemas/UploadRequest.yml (100%) rename microservices/{documentation => doc}/app/media/schemas/UploadResponse.yml (100%) create mode 100644 microservices/doc/app/media/security.yml create mode 100644 microservices/doc/app/mergeFile.go rename microservices/{documentation/deployment/preprod/configs.txt => doc/app/merged/.gitadd} (100%) rename microservices/{documentation => doc}/app/rooting.go (50%) create mode 100644 microservices/doc/app/template.go create mode 100644 microservices/doc/app/user.go create mode 100644 microservices/doc/app/user/info.yml rename microservices/{documentation => doc}/app/user/paths/User.yml (86%) create mode 100644 microservices/doc/app/user/schemas/BadInput.yml create mode 100644 microservices/doc/app/user/schemas/BadRequestResponse.yml create mode 100644 microservices/doc/app/user/schemas/Field.yml rename microservices/{documentation => doc}/app/user/schemas/NoContentResponse.yml (100%) create mode 100644 microservices/doc/app/user/schemas/UnauthorizedErrorResponse.yml create mode 100644 microservices/doc/app/user/schemas/User.yml rename microservices/{documentation => doc}/app/user/schemas/UserData.yml (100%) create mode 100644 microservices/doc/app/user/schemas/UserDataResponse.yml create mode 100644 microservices/doc/app/user/security.yml rename microservices/{documentation/deployment/prod => doc/deployment/preprod}/app/Deployment.yaml (79%) rename microservices/{documentation => doc}/deployment/preprod/app/Ingress.yaml (91%) rename microservices/{documentation/deployment/prod => doc/deployment/preprod}/configs.txt (100%) rename microservices/{documentation/deployment/preprod => doc/deployment/prod}/app/Deployment.yaml (78%) rename microservices/{documentation => doc}/deployment/prod/app/Ingress.yaml (91%) create mode 100644 microservices/doc/deployment/prod/configs.txt delete mode 100644 microservices/documentation/app/.gitignore delete mode 100644 microservices/documentation/app/info.yml delete mode 100644 microservices/documentation/app/mergeFile.go diff --git a/.github/workflows/backend-ci-push-pre-prod-documentation.yml b/.github/workflows/backend-ci-push-pre-prod-documentation.yml index 950eba6f..0b585eb9 100644 --- a/.github/workflows/backend-ci-push-pre-prod-documentation.yml +++ b/.github/workflows/backend-ci-push-pre-prod-documentation.yml @@ -1,4 +1,4 @@ -name: Build and push preprod documentation's images CI +name: Build and push preprod doc's images CI # This workflow is triggered on tag push finishing with '-preprod' on: push: @@ -6,14 +6,14 @@ on: - v*-preprod jobs: - build-and-push-documentation: - name: Docker Build Documentation and push image + build-and-push-doc: + name: Docker Build doc and push image runs-on: ubuntu-18.04 steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build and push Documentation Docker image with tag number + - name: Build and push doc Docker image with tag number # Official docker action: https://github.com/docker/build-push-action uses: docker/build-push-action@v1.1.0 with: @@ -22,12 +22,12 @@ jobs: registry: docker.pkg.github.com # github.repository -> alexandr-io/backend # https://github.com/docker/build-push-action/pull/14/files/d1c5c2f87bcd65b263d72ea6b1861bb25cbbcda5#r429877166 - repository: ${{github.repository}}/documentation + repository: ${{github.repository}}/doc tag_with_ref: true - path: microservices/documentation/app + path: microservices/doc/app push: true - - name: Build and push Documentation Docker image with tag latest-preprod + - name: Build and push doc Docker image with tag latest-preprod # Official docker action: https://github.com/docker/build-push-action uses: docker/build-push-action@v1.1.0 with: @@ -36,15 +36,15 @@ jobs: registry: docker.pkg.github.com # github.repository -> alexandr-io/backend # https://github.com/docker/build-push-action/pull/14/files/d1c5c2f87bcd65b263d72ea6b1861bb25cbbcda5#r429877166 - repository: ${{github.repository}}/documentation + repository: ${{github.repository}}/doc tags: latest-preprod - path: microservices/documentation/app + path: microservices/doc/app push: true - - name: Deploy or redeploy documentation app + - name: Deploy or redeploy doc app uses: cross-the-world/ssh-pipeline@master with: host: ${{ secrets.HOST_PREPROD }} user: ${{ secrets.HOST_PREPROD_USERNAME }} pass: ${{ secrets.HOST_PREPROD_PASSWORD }} - script: /kubernetes/app-deployment.sh documentation + script: /kubernetes/app-deployment.sh doc diff --git a/.github/workflows/backend-ci-push-prod-documentation.yml b/.github/workflows/backend-ci-push-prod-documentation.yml index c16949b3..17b16c76 100644 --- a/.github/workflows/backend-ci-push-prod-documentation.yml +++ b/.github/workflows/backend-ci-push-prod-documentation.yml @@ -1,4 +1,4 @@ -name: Build and push preprod documentation's images CI +name: Build and push preprod doc's images CI # This workflow is triggered on tag push finishing with '-preprod' on: push: @@ -6,14 +6,14 @@ on: - 'v*-*' jobs: - build-and-push-documentation: - name: Docker Build Documentation and push image + build-and-push-doc: + name: Docker Build doc and push image runs-on: ubuntu-18.04 steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build and push Documentation Docker image with tag number + - name: Build and push doc Docker image with tag number # Official docker action: https://github.com/docker/build-push-action uses: docker/build-push-action@v1.1.0 with: @@ -22,12 +22,12 @@ jobs: registry: docker.pkg.github.com # github.repository -> alexandr-io/backend # https://github.com/docker/build-push-action/pull/14/files/d1c5c2f87bcd65b263d72ea6b1861bb25cbbcda5#r429877166 - repository: ${{github.repository}}/documentation + repository: ${{github.repository}}/doc tag_with_ref: true - path: microservices/documentation/app + path: microservices/doc/app push: true - - name: Build and push Documentation Docker image with tag latest-preprod + - name: Build and push doc Docker image with tag latest-preprod # Official docker action: https://github.com/docker/build-push-action uses: docker/build-push-action@v1.1.0 with: @@ -36,15 +36,15 @@ jobs: registry: docker.pkg.github.com # github.repository -> alexandr-io/backend # https://github.com/docker/build-push-action/pull/14/files/d1c5c2f87bcd65b263d72ea6b1861bb25cbbcda5#r429877166 - repository: ${{github.repository}}/documentation + repository: ${{github.repository}}/doc tags: latest - path: microservices/documentation/app + path: microservices/doc/app push: true - - name: Deploy or redeploy documentation app + - name: Deploy or redeploy doc app uses: cross-the-world/ssh-pipeline@master with: host: ${{ secrets.HOST_PROD }} user: ${{ secrets.HOST_PROD_USERNAME }} pass: ${{ secrets.HOST_PROD_PASSWORD }} - script: /kubernetes/app-deployment.sh documentation + script: /kubernetes/app-deployment.sh doc diff --git a/.github/workflows/documentation-ci-build.yml b/.github/workflows/documentation-ci-build.yml index f03b85d8..bb161c28 100644 --- a/.github/workflows/documentation-ci-build.yml +++ b/.github/workflows/documentation-ci-build.yml @@ -1,26 +1,26 @@ -name: Documentation service build CI -# This workflow is triggered on pushes to the /microservices/documentation/app/ directory. +name: doc service build CI +# This workflow is triggered on pushes to the /microservices/doc/app/ directory. # The workflow does not trigger on main and pre-prod branch on: push: paths: - - 'microservices/documentation/app/**' + - 'microservices/doc/app/**' branches-ignore: - master jobs: build: - name: Docker Build Documentation + name: Docker Build doc runs-on: ubuntu-18.04 steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build Documentation Docker image + - name: Build doc Docker image # Official docker action: https://github.com/docker/build-push-action uses: docker/build-push-action@v1.1.0 with: # github.repository -> alexandr-io/backend repository: ${{github.repository}} - path: microservices/documentation/app + path: microservices/doc/app push: false diff --git a/docker-compose.yml b/docker-compose.yml index dd6357e6..50c5c467 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -138,17 +138,17 @@ services: env_file: .env-dev restart: unless-stopped - # Documentation service - documentation: - container_name: documentation + # Doc service + doc: + container_name: doc build: - context: microservices/documentation/app + context: microservices/doc/app dockerfile: Dockerfile-dev env_file: .env-dev ports: - "4000:3000" volumes: - - "./microservices/documentation/app:/app" + - "./microservices/doc/app:/app" # Library service library: diff --git a/microservices/doc/app/.gitignore b/microservices/doc/app/.gitignore new file mode 100644 index 00000000..815ed1e2 --- /dev/null +++ b/microservices/doc/app/.gitignore @@ -0,0 +1 @@ +merged/**.yml diff --git a/microservices/documentation/app/Dockerfile b/microservices/doc/app/Dockerfile similarity index 77% rename from microservices/documentation/app/Dockerfile rename to microservices/doc/app/Dockerfile index 29f5d574..28167845 100644 --- a/microservices/documentation/app/Dockerfile +++ b/microservices/doc/app/Dockerfile @@ -13,7 +13,7 @@ RUN go mod download COPY . ./ -RUN go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o alexandrio-backend-documentation . +RUN go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o alexandrio-backend-doc . # Run stage @@ -21,4 +21,4 @@ FROM scratch COPY --from=builder /app/ ./ -ENTRYPOINT ["./alexandrio-backend-documentation"] +ENTRYPOINT ["./alexandrio-backend-doc"] diff --git a/microservices/documentation/app/Dockerfile-dev b/microservices/doc/app/Dockerfile-dev similarity index 100% rename from microservices/documentation/app/Dockerfile-dev rename to microservices/doc/app/Dockerfile-dev diff --git a/microservices/doc/app/auth.go b/microservices/doc/app/auth.go new file mode 100644 index 00000000..3b848847 --- /dev/null +++ b/microservices/doc/app/auth.go @@ -0,0 +1,25 @@ +package main + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/gofiber/fiber/v2" + "github.com/valyala/fasthttp/fasthttpadaptor" +) + +const auth = "auth" + +func wrapAuthDocHandler() func(ctx *fiber.Ctx) error { + swaggerHandler := middleware.Redoc(fillRedocOpts(auth), nil) + + return func(ctx *fiber.Ctx) error { + fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) + return nil + } +} + +func mergeAuthFiles(ctx *fiber.Ctx) error { + if err := mergeDocsFiles(ctx, auth); err != nil { + return err + } + return ctx.Next() +} diff --git a/microservices/doc/app/auth/info.yml b/microservices/doc/app/auth/info.yml new file mode 100644 index 00000000..ce645758 --- /dev/null +++ b/microservices/doc/app/auth/info.yml @@ -0,0 +1,18 @@ +--- +openapi: 3.0.2 +info: + description: "Documentation for the Alexandrio's AUTH microsecervice REST API\n\n + You can find the documentation of the others MS in these pages:\n\n + Auth + User + Library + Media" + version: v1 + title: AUTH Documentation +tags: + - name: AUTHENTICATION + - name: INVITATION + - name: RESET PASSWORD + description: "Schema of reset password workflow: " +paths: + diff --git a/microservices/documentation/app/auth/paths/auth.yml b/microservices/doc/app/auth/paths/auth.yml similarity index 90% rename from microservices/documentation/app/auth/paths/auth.yml rename to microservices/doc/app/auth/paths/auth.yml index b5fb688d..e1dcd9a4 100644 --- a/microservices/documentation/app/auth/paths/auth.yml +++ b/microservices/doc/app/auth/paths/auth.yml @@ -10,11 +10,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //auth.alexandrio.cloud description: Production server - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - AUTHENTICATION diff --git a/microservices/documentation/app/auth/paths/invitation.yml b/microservices/doc/app/auth/paths/invitation.yml similarity index 93% rename from microservices/documentation/app/auth/paths/invitation.yml rename to microservices/doc/app/auth/paths/invitation.yml index 87fa6231..7c8444e0 100644 --- a/microservices/documentation/app/auth/paths/invitation.yml +++ b/microservices/doc/app/auth/paths/invitation.yml @@ -13,14 +13,14 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - INVITATION /invitation/{token}: delete: description: Delete an invitation corresponding to the given `token`. For test purpose only. summary: Delete Invitation security: - - Bearer Auth: [] + - bearerAuth: [] responses: "204": $ref: '#/components/schemas/NoContentResponse' @@ -32,4 +32,4 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - INVITATION diff --git a/microservices/documentation/app/auth/paths/login.yml b/microservices/doc/app/auth/paths/login.yml similarity index 96% rename from microservices/documentation/app/auth/paths/login.yml rename to microservices/doc/app/auth/paths/login.yml index 48fbec73..84c91a49 100644 --- a/microservices/documentation/app/auth/paths/login.yml +++ b/microservices/doc/app/auth/paths/login.yml @@ -21,4 +21,4 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - AUTHENTICATION diff --git a/microservices/documentation/app/auth/paths/logout.yml b/microservices/doc/app/auth/paths/logout.yml similarity index 92% rename from microservices/documentation/app/auth/paths/logout.yml rename to microservices/doc/app/auth/paths/logout.yml index 937c16e3..339723bb 100644 --- a/microservices/documentation/app/auth/paths/logout.yml +++ b/microservices/doc/app/auth/paths/logout.yml @@ -10,11 +10,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [ ] + - bearerAuth: [] servers: - url: //auth.alexandrio.cloud description: Production server - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - AUTHENTICATION diff --git a/microservices/documentation/app/auth/paths/passwordReset.yml b/microservices/doc/app/auth/paths/passwordReset.yml similarity index 93% rename from microservices/documentation/app/auth/paths/passwordReset.yml rename to microservices/doc/app/auth/paths/passwordReset.yml index 6d1d3da2..72ec777a 100644 --- a/microservices/documentation/app/auth/paths/passwordReset.yml +++ b/microservices/doc/app/auth/paths/passwordReset.yml @@ -23,10 +23,10 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - RESET PASSWORD get: - description: "Check if the reset password token is valid and get user info.\n\nSchema of reset password workflow: " + description: "Check if the reset password token is valid and get user info." summary: Check Reset Token requestBody: content: @@ -43,7 +43,7 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - RESET PASSWORD put: description: Final step of password reset, after asking and checking a reset password token. @@ -63,4 +63,4 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - RESET PASSWORD diff --git a/microservices/documentation/app/auth/paths/refresh.yml b/microservices/doc/app/auth/paths/refresh.yml similarity index 96% rename from microservices/documentation/app/auth/paths/refresh.yml rename to microservices/doc/app/auth/paths/refresh.yml index 2120281f..95f90cd8 100644 --- a/microservices/documentation/app/auth/paths/refresh.yml +++ b/microservices/doc/app/auth/paths/refresh.yml @@ -23,4 +23,4 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - AUTHENTICATION diff --git a/microservices/documentation/app/auth/paths/register.yml b/microservices/doc/app/auth/paths/register.yml similarity index 96% rename from microservices/documentation/app/auth/paths/register.yml rename to microservices/doc/app/auth/paths/register.yml index ef0517dd..f88c6f65 100644 --- a/microservices/documentation/app/auth/paths/register.yml +++ b/microservices/doc/app/auth/paths/register.yml @@ -21,4 +21,4 @@ paths: - url: //auth.preprod.alexandrio.cloud description: Preprod server tags: - - AUTH + - AUTHENTICATION diff --git a/microservices/documentation/app/auth/schemas/AuthRefresh.yml b/microservices/doc/app/auth/schemas/AuthRefresh.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/AuthRefresh.yml rename to microservices/doc/app/auth/schemas/AuthRefresh.yml diff --git a/microservices/documentation/app/auth/schemas/AuthResponse.yml b/microservices/doc/app/auth/schemas/AuthResponse.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/AuthResponse.yml rename to microservices/doc/app/auth/schemas/AuthResponse.yml diff --git a/microservices/documentation/app/general/schemas/BadInput.yml b/microservices/doc/app/auth/schemas/BadInput.yml similarity index 100% rename from microservices/documentation/app/general/schemas/BadInput.yml rename to microservices/doc/app/auth/schemas/BadInput.yml diff --git a/microservices/documentation/app/general/schemas/BadRequestResponse.yml b/microservices/doc/app/auth/schemas/BadRequestResponse.yml similarity index 100% rename from microservices/documentation/app/general/schemas/BadRequestResponse.yml rename to microservices/doc/app/auth/schemas/BadRequestResponse.yml diff --git a/microservices/documentation/app/general/schemas/Field.yml b/microservices/doc/app/auth/schemas/Field.yml similarity index 100% rename from microservices/documentation/app/general/schemas/Field.yml rename to microservices/doc/app/auth/schemas/Field.yml diff --git a/microservices/documentation/app/auth/schemas/Invitation.yml b/microservices/doc/app/auth/schemas/Invitation.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/Invitation.yml rename to microservices/doc/app/auth/schemas/Invitation.yml diff --git a/microservices/documentation/app/general/schemas/NoContentResponse.yml b/microservices/doc/app/auth/schemas/NoContentResponse.yml similarity index 100% rename from microservices/documentation/app/general/schemas/NoContentResponse.yml rename to microservices/doc/app/auth/schemas/NoContentResponse.yml diff --git a/microservices/documentation/app/general/schemas/UnauthorizedErrorResponse.yml b/microservices/doc/app/auth/schemas/UnauthorizedErrorResponse.yml similarity index 100% rename from microservices/documentation/app/general/schemas/UnauthorizedErrorResponse.yml rename to microservices/doc/app/auth/schemas/UnauthorizedErrorResponse.yml diff --git a/microservices/documentation/app/auth/schemas/User.yml b/microservices/doc/app/auth/schemas/User.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/User.yml rename to microservices/doc/app/auth/schemas/User.yml diff --git a/microservices/documentation/app/general/schemas/UserDataResponse.yml b/microservices/doc/app/auth/schemas/UserDataResponse.yml similarity index 100% rename from microservices/documentation/app/general/schemas/UserDataResponse.yml rename to microservices/doc/app/auth/schemas/UserDataResponse.yml diff --git a/microservices/documentation/app/auth/schemas/UserLogin.yml b/microservices/doc/app/auth/schemas/UserLogin.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserLogin.yml rename to microservices/doc/app/auth/schemas/UserLogin.yml diff --git a/microservices/documentation/app/auth/schemas/UserRegister.yml b/microservices/doc/app/auth/schemas/UserRegister.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserRegister.yml rename to microservices/doc/app/auth/schemas/UserRegister.yml diff --git a/microservices/documentation/app/auth/schemas/UserResetPassword.yml b/microservices/doc/app/auth/schemas/UserResetPassword.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserResetPassword.yml rename to microservices/doc/app/auth/schemas/UserResetPassword.yml diff --git a/microservices/documentation/app/auth/schemas/UserResetPasswordToken.yml b/microservices/doc/app/auth/schemas/UserResetPasswordToken.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserResetPasswordToken.yml rename to microservices/doc/app/auth/schemas/UserResetPasswordToken.yml diff --git a/microservices/documentation/app/auth/schemas/UserResponse.yml b/microservices/doc/app/auth/schemas/UserResponse.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserResponse.yml rename to microservices/doc/app/auth/schemas/UserResponse.yml diff --git a/microservices/documentation/app/auth/schemas/UserSendResetPasswordEmail.yml b/microservices/doc/app/auth/schemas/UserSendResetPasswordEmail.yml similarity index 100% rename from microservices/documentation/app/auth/schemas/UserSendResetPasswordEmail.yml rename to microservices/doc/app/auth/schemas/UserSendResetPasswordEmail.yml diff --git a/microservices/documentation/app/security.yml b/microservices/doc/app/auth/security.yml similarity index 96% rename from microservices/documentation/app/security.yml rename to microservices/doc/app/auth/security.yml index f33817c7..55ee0340 100644 --- a/microservices/documentation/app/security.yml +++ b/microservices/doc/app/auth/security.yml @@ -1,9 +1,9 @@ --- components: securitySchemes: - Bearer Auth: + bearerAuth: description: "Alexandrio backend is using both auth token and refresh token.\n\nThe auth token is used to access resources as an authenticated user. This token is only valid for 15 minutes for security purposes. \nThe auth token is given by the [`/register`](#operation/register), [`/login`](#operation/login) and [`/auth/refresh`](#operation/refresh_token) routes. \nYou need to send the auth token as a Bearer authentication token in the header of the request to access protected routes.\n\nThe refresh token is used to get a new auth token. When the auth token is expired, you need to send this refresh token to [`/auth/refresh`](#operation/refresh_token) to get a new auth and refresh token. \nThe refresh token is valid for 30 days and can be used only once. The [`/auth/refresh`](#operation/refresh_token) route return a new refresh token.\n\n
\n \"Workflow\"\n
\n

Schema of the authentication workflow

\n" - type: https + type: http scheme: bearer bearerFormat: JWT diff --git a/microservices/doc/app/docs/info.yml b/microservices/doc/app/docs/info.yml new file mode 100644 index 00000000..238fe833 --- /dev/null +++ b/microservices/doc/app/docs/info.yml @@ -0,0 +1,25 @@ +--- +openapi: 3.0.2 +info: + description: "Documentation for the Alexandrio's microsecervice REST API\n\n + You can find the documentation of the microservices in these pages:\n\n + Auth + User + Library + Media" + version: v1 + title: Alexandrio Documentation +paths: + /ping: + get: + description: Check whether or not a service is running + responses: + '200': + description: The service is running + servers: + - url: //service.alexandrio.cloud + description: Production server + - url: //service.preprod.alexandrio.cloud + description: Preprod server + tags: + - PING diff --git a/microservices/documentation/app/go.mod b/microservices/doc/app/go.mod similarity index 76% rename from microservices/documentation/app/go.mod rename to microservices/doc/app/go.mod index 294997e9..46d3c82c 100644 --- a/microservices/documentation/app/go.mod +++ b/microservices/doc/app/go.mod @@ -1,4 +1,4 @@ -module github.com/alexandr-io/backend/documentation +module github.com/alexandr-io/backend/doc go 1.15 diff --git a/microservices/documentation/app/go.sum b/microservices/doc/app/go.sum similarity index 100% rename from microservices/documentation/app/go.sum rename to microservices/doc/app/go.sum diff --git a/microservices/doc/app/library.go b/microservices/doc/app/library.go new file mode 100644 index 00000000..d440d2c8 --- /dev/null +++ b/microservices/doc/app/library.go @@ -0,0 +1,25 @@ +package main + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/gofiber/fiber/v2" + "github.com/valyala/fasthttp/fasthttpadaptor" +) + +const library = "library" + +func wrapLibraryDocHandler() func(ctx *fiber.Ctx) error { + swaggerHandler := middleware.Redoc(fillRedocOpts(library), nil) + + return func(ctx *fiber.Ctx) error { + fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) + return nil + } +} + +func mergeLibraryFiles(ctx *fiber.Ctx) error { + if err := mergeDocsFiles(ctx, library); err != nil { + return err + } + return ctx.Next() +} diff --git a/microservices/doc/app/library/info.yml b/microservices/doc/app/library/info.yml new file mode 100644 index 00000000..237d1e3b --- /dev/null +++ b/microservices/doc/app/library/info.yml @@ -0,0 +1,16 @@ +--- +openapi: 3.0.2 +info: + description: "Documentation for the Alexandrio's LIBRARY microsecervice REST API\n\n + You can find the documentation of the others MS in these pages:\n\n + Auth + User + Library + Media" + version: v1 + title: LIBRARY Documentation +tags: + - name: LIBRARIES + - name: BOOKS +paths: + diff --git a/microservices/documentation/app/library/paths/bookMetadataCreate.yml b/microservices/doc/app/library/paths/bookMetadataCreate.yml similarity index 88% rename from microservices/documentation/app/library/paths/bookMetadataCreate.yml rename to microservices/doc/app/library/paths/bookMetadataCreate.yml index f9935c10..1ac97d4a 100644 --- a/microservices/documentation/app/library/paths/bookMetadataCreate.yml +++ b/microservices/doc/app/library/paths/bookMetadataCreate.yml @@ -17,11 +17,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - BOOKS diff --git a/microservices/documentation/app/library/paths/bookMetadataDelete.yml b/microservices/doc/app/library/paths/bookMetadataDelete.yml similarity index 88% rename from microservices/documentation/app/library/paths/bookMetadataDelete.yml rename to microservices/doc/app/library/paths/bookMetadataDelete.yml index 093cb1a6..17ff80e0 100644 --- a/microservices/documentation/app/library/paths/bookMetadataDelete.yml +++ b/microservices/doc/app/library/paths/bookMetadataDelete.yml @@ -17,11 +17,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - BOOKS diff --git a/microservices/documentation/app/library/paths/bookMetadataRetrieve.yml b/microservices/doc/app/library/paths/bookMetadataRetrieve.yml similarity index 88% rename from microservices/documentation/app/library/paths/bookMetadataRetrieve.yml rename to microservices/doc/app/library/paths/bookMetadataRetrieve.yml index e9abf5b6..1f19bc07 100644 --- a/microservices/documentation/app/library/paths/bookMetadataRetrieve.yml +++ b/microservices/doc/app/library/paths/bookMetadataRetrieve.yml @@ -17,11 +17,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - BOOKS diff --git a/microservices/documentation/app/library/paths/librariesNames.yml b/microservices/doc/app/library/paths/librariesNames.yml similarity index 83% rename from microservices/documentation/app/library/paths/librariesNames.yml rename to microservices/doc/app/library/paths/librariesNames.yml index 361e3632..18f129f2 100644 --- a/microservices/documentation/app/library/paths/librariesNames.yml +++ b/microservices/doc/app/library/paths/librariesNames.yml @@ -10,11 +10,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - LIBRARIES diff --git a/microservices/documentation/app/library/paths/libraryCreate.yml b/microservices/doc/app/library/paths/libraryCreate.yml similarity index 86% rename from microservices/documentation/app/library/paths/libraryCreate.yml rename to microservices/doc/app/library/paths/libraryCreate.yml index 93b7c97d..6346c353 100644 --- a/microservices/documentation/app/library/paths/libraryCreate.yml +++ b/microservices/doc/app/library/paths/libraryCreate.yml @@ -16,11 +16,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - LIBRARIES diff --git a/microservices/documentation/app/library/paths/libraryDelete.yml b/microservices/doc/app/library/paths/libraryDelete.yml similarity index 86% rename from microservices/documentation/app/library/paths/libraryDelete.yml rename to microservices/doc/app/library/paths/libraryDelete.yml index a20db024..4a111c59 100644 --- a/microservices/documentation/app/library/paths/libraryDelete.yml +++ b/microservices/doc/app/library/paths/libraryDelete.yml @@ -16,11 +16,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - LIBRARIES diff --git a/microservices/documentation/app/library/paths/libraryRetrieve.yml b/microservices/doc/app/library/paths/libraryRetrieve.yml similarity index 87% rename from microservices/documentation/app/library/paths/libraryRetrieve.yml rename to microservices/doc/app/library/paths/libraryRetrieve.yml index 9b6c925c..ae13050f 100644 --- a/microservices/documentation/app/library/paths/libraryRetrieve.yml +++ b/microservices/doc/app/library/paths/libraryRetrieve.yml @@ -16,11 +16,11 @@ paths: "401": $ref: '#/components/schemas/UnauthorizedErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //library.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //library.preprod.alexandrio.cloud description: Preprod server tags: - - LIBRARY + - LIBRARIES diff --git a/microservices/doc/app/library/schemas/BadInput.yml b/microservices/doc/app/library/schemas/BadInput.yml new file mode 100644 index 00000000..0e4e32b8 --- /dev/null +++ b/microservices/doc/app/library/schemas/BadInput.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + BadInput: + properties: + fields: + items: + $ref: "#/components/schemas/Field" + type: array + type: object diff --git a/microservices/doc/app/library/schemas/BadRequestResponse.yml b/microservices/doc/app/library/schemas/BadRequestResponse.yml new file mode 100644 index 00000000..5e65576b --- /dev/null +++ b/microservices/doc/app/library/schemas/BadRequestResponse.yml @@ -0,0 +1,9 @@ +--- +components: + schemas: + BadRequestErrorResponse: + description: Bad Request + content: + application/json: + schema: + $ref: "#/components/schemas/BadInput" diff --git a/microservices/documentation/app/library/schemas/BookMetadataCreateRequest.yml b/microservices/doc/app/library/schemas/BookMetadataCreateRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataCreateRequest.yml rename to microservices/doc/app/library/schemas/BookMetadataCreateRequest.yml diff --git a/microservices/documentation/app/library/schemas/BookMetadataCreateResponse.yml b/microservices/doc/app/library/schemas/BookMetadataCreateResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataCreateResponse.yml rename to microservices/doc/app/library/schemas/BookMetadataCreateResponse.yml diff --git a/microservices/documentation/app/library/schemas/BookMetadataDeleteRequest.yml b/microservices/doc/app/library/schemas/BookMetadataDeleteRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataDeleteRequest.yml rename to microservices/doc/app/library/schemas/BookMetadataDeleteRequest.yml diff --git a/microservices/documentation/app/library/schemas/BookMetadataDeleteResponse.yml b/microservices/doc/app/library/schemas/BookMetadataDeleteResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataDeleteResponse.yml rename to microservices/doc/app/library/schemas/BookMetadataDeleteResponse.yml diff --git a/microservices/documentation/app/library/schemas/BookMetadataRetrieveRequest.yml b/microservices/doc/app/library/schemas/BookMetadataRetrieveRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataRetrieveRequest.yml rename to microservices/doc/app/library/schemas/BookMetadataRetrieveRequest.yml diff --git a/microservices/documentation/app/library/schemas/BookMetadataRetrieveResponse.yml b/microservices/doc/app/library/schemas/BookMetadataRetrieveResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/BookMetadataRetrieveResponse.yml rename to microservices/doc/app/library/schemas/BookMetadataRetrieveResponse.yml diff --git a/microservices/doc/app/library/schemas/Field.yml b/microservices/doc/app/library/schemas/Field.yml new file mode 100644 index 00000000..a2bbcc73 --- /dev/null +++ b/microservices/doc/app/library/schemas/Field.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + Field: + properties: + name: + type: string + reason: + type: string + type: object diff --git a/microservices/documentation/app/library/schemas/LibrariesNamesData.yml b/microservices/doc/app/library/schemas/LibrariesNamesData.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibrariesNamesData.yml rename to microservices/doc/app/library/schemas/LibrariesNamesData.yml diff --git a/microservices/documentation/app/library/schemas/LibrariesNamesRetrieveResponse.yml b/microservices/doc/app/library/schemas/LibrariesNamesRetrieveResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibrariesNamesRetrieveResponse.yml rename to microservices/doc/app/library/schemas/LibrariesNamesRetrieveResponse.yml diff --git a/microservices/documentation/app/library/schemas/LibraryCreateRequest.yml b/microservices/doc/app/library/schemas/LibraryCreateRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryCreateRequest.yml rename to microservices/doc/app/library/schemas/LibraryCreateRequest.yml diff --git a/microservices/documentation/app/library/schemas/LibraryCreateResponse.yml b/microservices/doc/app/library/schemas/LibraryCreateResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryCreateResponse.yml rename to microservices/doc/app/library/schemas/LibraryCreateResponse.yml diff --git a/microservices/documentation/app/library/schemas/LibraryDeleteRequest.yml b/microservices/doc/app/library/schemas/LibraryDeleteRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryDeleteRequest.yml rename to microservices/doc/app/library/schemas/LibraryDeleteRequest.yml diff --git a/microservices/documentation/app/library/schemas/LibraryDeleteResponse.yml b/microservices/doc/app/library/schemas/LibraryDeleteResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryDeleteResponse.yml rename to microservices/doc/app/library/schemas/LibraryDeleteResponse.yml diff --git a/microservices/documentation/app/library/schemas/LibraryRetrieveRequest.yml b/microservices/doc/app/library/schemas/LibraryRetrieveRequest.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryRetrieveRequest.yml rename to microservices/doc/app/library/schemas/LibraryRetrieveRequest.yml diff --git a/microservices/documentation/app/library/schemas/LibraryRetrieveResponse.yml b/microservices/doc/app/library/schemas/LibraryRetrieveResponse.yml similarity index 100% rename from microservices/documentation/app/library/schemas/LibraryRetrieveResponse.yml rename to microservices/doc/app/library/schemas/LibraryRetrieveResponse.yml diff --git a/microservices/documentation/app/media/schemas/UnauthorizedErrorResponse.yml b/microservices/doc/app/library/schemas/UnauthorizedErrorResponse.yml similarity index 100% rename from microservices/documentation/app/media/schemas/UnauthorizedErrorResponse.yml rename to microservices/doc/app/library/schemas/UnauthorizedErrorResponse.yml diff --git a/microservices/doc/app/library/security.yml b/microservices/doc/app/library/security.yml new file mode 100644 index 00000000..e3aea845 --- /dev/null +++ b/microservices/doc/app/library/security.yml @@ -0,0 +1,9 @@ +--- +components: + securitySchemes: + bearerAuth: + description: "Go to /auth to see more documentation." + type: http + scheme: bearer + bearerFormat: JWT + diff --git a/microservices/documentation/app/main.go b/microservices/doc/app/main.go similarity index 100% rename from microservices/documentation/app/main.go rename to microservices/doc/app/main.go diff --git a/microservices/doc/app/media.go b/microservices/doc/app/media.go new file mode 100644 index 00000000..0883d3d1 --- /dev/null +++ b/microservices/doc/app/media.go @@ -0,0 +1,25 @@ +package main + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/gofiber/fiber/v2" + "github.com/valyala/fasthttp/fasthttpadaptor" +) + +const media = "media" + +func wrapMediaDocHandler() func(ctx *fiber.Ctx) error { + swaggerHandler := middleware.Redoc(fillRedocOpts(media), nil) + + return func(ctx *fiber.Ctx) error { + fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) + return nil + } +} + +func mergeMediaFiles(ctx *fiber.Ctx) error { + if err := mergeDocsFiles(ctx, media); err != nil { + return err + } + return ctx.Next() +} diff --git a/microservices/doc/app/media/info.yml b/microservices/doc/app/media/info.yml new file mode 100644 index 00000000..cdf4cc2a --- /dev/null +++ b/microservices/doc/app/media/info.yml @@ -0,0 +1,13 @@ +--- +openapi: 3.0.2 +info: + description: "Documentation for the Alexandrio's MEDIA microsecervice REST API\n\n + You can find the documentation of the others MS in these pages:\n\n + Auth + User + Library + Media" + version: v1 + title: MEDIA Documentation +paths: + diff --git a/microservices/documentation/app/media/paths/download.yml b/microservices/doc/app/media/paths/download.yml similarity index 90% rename from microservices/documentation/app/media/paths/download.yml rename to microservices/doc/app/media/paths/download.yml index 0fb39192..899a398e 100644 --- a/microservices/documentation/app/media/paths/download.yml +++ b/microservices/doc/app/media/paths/download.yml @@ -17,11 +17,11 @@ paths: "400": $ref: '#/components/schemas/BadRequestErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //media.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //media.preprod.alexandrio.cloud description: Preprod server tags: - MEDIA diff --git a/microservices/documentation/app/media/paths/upload.yml b/microservices/doc/app/media/paths/upload.yml similarity index 90% rename from microservices/documentation/app/media/paths/upload.yml rename to microservices/doc/app/media/paths/upload.yml index a40bf2bd..8a187ec7 100644 --- a/microservices/documentation/app/media/paths/upload.yml +++ b/microservices/doc/app/media/paths/upload.yml @@ -17,11 +17,11 @@ paths: "400": $ref: '#/components/schemas/BadRequestErrorResponse' security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //media.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //media.preprod.alexandrio.cloud description: Preprod server tags: - MEDIA diff --git a/microservices/doc/app/media/schemas/BadInput.yml b/microservices/doc/app/media/schemas/BadInput.yml new file mode 100644 index 00000000..0e4e32b8 --- /dev/null +++ b/microservices/doc/app/media/schemas/BadInput.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + BadInput: + properties: + fields: + items: + $ref: "#/components/schemas/Field" + type: array + type: object diff --git a/microservices/doc/app/media/schemas/BadRequestResponse.yml b/microservices/doc/app/media/schemas/BadRequestResponse.yml new file mode 100644 index 00000000..5e65576b --- /dev/null +++ b/microservices/doc/app/media/schemas/BadRequestResponse.yml @@ -0,0 +1,9 @@ +--- +components: + schemas: + BadRequestErrorResponse: + description: Bad Request + content: + application/json: + schema: + $ref: "#/components/schemas/BadInput" diff --git a/microservices/documentation/app/media/schemas/DownloadRequest.yml b/microservices/doc/app/media/schemas/DownloadRequest.yml similarity index 100% rename from microservices/documentation/app/media/schemas/DownloadRequest.yml rename to microservices/doc/app/media/schemas/DownloadRequest.yml diff --git a/microservices/documentation/app/media/schemas/DownloadResponse.yml b/microservices/doc/app/media/schemas/DownloadResponse.yml similarity index 100% rename from microservices/documentation/app/media/schemas/DownloadResponse.yml rename to microservices/doc/app/media/schemas/DownloadResponse.yml diff --git a/microservices/doc/app/media/schemas/Field.yml b/microservices/doc/app/media/schemas/Field.yml new file mode 100644 index 00000000..a2bbcc73 --- /dev/null +++ b/microservices/doc/app/media/schemas/Field.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + Field: + properties: + name: + type: string + reason: + type: string + type: object diff --git a/microservices/doc/app/media/schemas/UnauthorizedErrorResponse.yml b/microservices/doc/app/media/schemas/UnauthorizedErrorResponse.yml new file mode 100644 index 00000000..06a38a3e --- /dev/null +++ b/microservices/doc/app/media/schemas/UnauthorizedErrorResponse.yml @@ -0,0 +1,5 @@ +--- +components: + schemas: + UnauthorizedErrorResponse: + description: Unauthorized diff --git a/microservices/documentation/app/media/schemas/UploadRequest.yml b/microservices/doc/app/media/schemas/UploadRequest.yml similarity index 100% rename from microservices/documentation/app/media/schemas/UploadRequest.yml rename to microservices/doc/app/media/schemas/UploadRequest.yml diff --git a/microservices/documentation/app/media/schemas/UploadResponse.yml b/microservices/doc/app/media/schemas/UploadResponse.yml similarity index 100% rename from microservices/documentation/app/media/schemas/UploadResponse.yml rename to microservices/doc/app/media/schemas/UploadResponse.yml diff --git a/microservices/doc/app/media/security.yml b/microservices/doc/app/media/security.yml new file mode 100644 index 00000000..e3aea845 --- /dev/null +++ b/microservices/doc/app/media/security.yml @@ -0,0 +1,9 @@ +--- +components: + securitySchemes: + bearerAuth: + description: "Go to /auth to see more documentation." + type: http + scheme: bearer + bearerFormat: JWT + diff --git a/microservices/doc/app/mergeFile.go b/microservices/doc/app/mergeFile.go new file mode 100644 index 00000000..51e9d0e5 --- /dev/null +++ b/microservices/doc/app/mergeFile.go @@ -0,0 +1,74 @@ +package main + +import ( + "io/ioutil" + "log" + "os" + "path" + "path/filepath" + + "github.com/gofiber/fiber/v2" + "github.com/miracl/conflate" +) + +func getAllFilesToMerge(directory string) ([]string, error) { + var matches []string + err := filepath.Walk(directory, func(path string, f os.FileInfo, err error) error { + if filepath.Base(path) == "swagger.yml" || + filepath.Base(path) == "info.yml" || + filepath.Base(path) == "security.yml" { + return nil + } + if filepath.Ext(path) == ".yml" || filepath.Ext(path) == ".yaml" { + matches = append(matches, path) + } + return nil + }) + return matches, err +} + +func mergeDocsFiles(ctx *fiber.Ctx, folder string) error { + thisDir, err := os.Getwd() + if err != nil { + log.Println(err) + return err + } + + matches, err := getAllFilesToMerge(path.Join(thisDir, folder)) + if err != nil { + log.Println(err) + return err + } + + infoPath, err := fillTemplateInfo(ctx, folder) + if err != nil { + return err + } + securityPath, err := fillTemplateSecurity(ctx, folder) + if err != nil { + if err.Error() != "NO FILE" { + return err + } + } else { + matches = append(matches, securityPath) + } + matches = append(matches, infoPath) + + c := conflate.New() + if err := c.AddFiles(matches...); err != nil { + log.Println(err) + return err + } + + yaml, err := c.MarshalYAML() + if err != nil { + log.Println(err) + return err + } + + if err := ioutil.WriteFile(path.Join(path.Join(thisDir, "merged"), folder+".yml"), yaml, 0644); err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/microservices/documentation/deployment/preprod/configs.txt b/microservices/doc/app/merged/.gitadd similarity index 100% rename from microservices/documentation/deployment/preprod/configs.txt rename to microservices/doc/app/merged/.gitadd diff --git a/microservices/documentation/app/rooting.go b/microservices/doc/app/rooting.go similarity index 50% rename from microservices/documentation/app/rooting.go rename to microservices/doc/app/rooting.go index b26798fa..25838f9a 100644 --- a/microservices/documentation/app/rooting.go +++ b/microservices/doc/app/rooting.go @@ -2,6 +2,7 @@ package main import ( "net/http" + "path" "github.com/go-openapi/runtime/middleware" "github.com/gofiber/fiber/v2" @@ -14,8 +15,16 @@ func createRoute(app *fiber.App) { // Recover middleware in case of panic app.Use(recover.New()) - app.Get("/docs", mergeDocsFiles, wrapDocHandler()) - app.Get("/swagger.yml", wrapFileServer()) + app.Get("/docs", mergeDocFiles, wrapDocHandler()) + app.Get("/merged/docs.yml", wrapFileServer()) + app.Get("/auth", mergeAuthFiles, wrapAuthDocHandler()) + app.Get("/merged/auth.yml", wrapFileServer()) + app.Get("/user", mergeUserFiles, wrapUserDocHandler()) + app.Get("/merged/user.yml", wrapFileServer()) + app.Get("/library", mergeLibraryFiles, wrapLibraryDocHandler()) + app.Get("/merged/library.yml", wrapFileServer()) + app.Get("/media", mergeMediaFiles, wrapMediaDocHandler()) + app.Get("/merged/media.yml", wrapFileServer()) // Ping route used for testing that the service is up and running app.Get("/ping", func(c *fiber.Ctx) error { @@ -28,19 +37,34 @@ func createRoute(app *fiber.App) { }) } -func wrapDocHandler() func(ctx *fiber.Ctx) error { - options := middleware.RedocOpts{SpecURL: "/swagger.yml"} - swaggerHandler := middleware.Redoc(options, nil) +func fillRedocOpts(service string) middleware.RedocOpts { + return middleware.RedocOpts{ + BasePath: "/", + Path: service, + SpecURL: path.Join("merged", service+".yml"), + Title: service + " documentation", + } +} +func wrapFileServer() func(ctx *fiber.Ctx) error { return func(ctx *fiber.Ctx) error { - fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) + fasthttpadaptor.NewFastHTTPHandler(http.FileServer(http.Dir("./")))(ctx.Context()) return nil } } -func wrapFileServer() func(ctx *fiber.Ctx) error { +func wrapDocHandler() func(ctx *fiber.Ctx) error { + swaggerHandler := middleware.Redoc(fillRedocOpts("docs"), nil) + return func(ctx *fiber.Ctx) error { - fasthttpadaptor.NewFastHTTPHandler(http.FileServer(http.Dir("./")))(ctx.Context()) + fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) return nil } } + +func mergeDocFiles(ctx *fiber.Ctx) error { + if err := mergeDocsFiles(ctx, "docs"); err != nil { + return err + } + return ctx.Next() +} diff --git a/microservices/doc/app/template.go b/microservices/doc/app/template.go new file mode 100644 index 00000000..c933c30b --- /dev/null +++ b/microservices/doc/app/template.go @@ -0,0 +1,94 @@ +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "text/template" + + "github.com/gofiber/fiber/v2" +) + +type info struct { + Auth string + User string + Library string + Media string +} + +type security struct { + Auth string +} + +func fillTemplateInfo(ctx *fiber.Ctx, folder string) (string, error) { + url := string(ctx.Request().URI().Scheme()) + "://" + string(ctx.Request().URI().Host()) + infos := info{ + Auth: url + "/auth", + User: url + "/user", + Library: url + "/library", + Media: url + "/media", + } + dat, err := ioutil.ReadFile("./" + folder + "/info.yml") + if err != nil { + log.Println(err) + return "", err + } + + t, err := template.New("info").Parse(string(dat)) + if err != nil { + log.Println(err) + return "", err + } + var tpl bytes.Buffer + err = t.Execute(&tpl, infos) + if err != nil { + log.Println(err) + return "", err + } + + var filePath = "/tmp/" + folder + "-info.yml" + if err := ioutil.WriteFile(filePath, tpl.Bytes(), 0644); err != nil { + log.Println(err) + return "", err + } + return filePath, nil +} + +func fillTemplateSecurity(ctx *fiber.Ctx, folder string) (string, error) { + if folder == auth { + return auth + "/security.yml", nil + } + url := string(ctx.Request().URI().Scheme()) + "://" + string(ctx.Request().URI().Host()) + sec := security{ + Auth: url + "/auth#section/Authentication", + } + if _, err := os.Stat("./" + folder + "/security.yml"); os.IsNotExist(err) { + return "", fmt.Errorf("NO FILE") + } + dat, err := ioutil.ReadFile("./" + folder + "/security.yml") + if err != nil { + log.Println(err) + return "", err + } + + t, err := template.New("security").Parse(string(dat)) + if err != nil { + log.Println(err) + return "", err + } + var tpl bytes.Buffer + err = t.Execute(&tpl, sec) + if err != nil { + log.Println(err) + return "", err + } + + var filePath = "/tmp/" + folder + "-security.yml" + if err := ioutil.WriteFile(filePath, tpl.Bytes(), 0644); err != nil { + log.Println(err) + return "", err + } + return filePath, nil +} diff --git a/microservices/doc/app/user.go b/microservices/doc/app/user.go new file mode 100644 index 00000000..acc4d70e --- /dev/null +++ b/microservices/doc/app/user.go @@ -0,0 +1,25 @@ +package main + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/gofiber/fiber/v2" + "github.com/valyala/fasthttp/fasthttpadaptor" +) + +const user = "user" + +func wrapUserDocHandler() func(ctx *fiber.Ctx) error { + swaggerHandler := middleware.Redoc(fillRedocOpts(user), nil) + + return func(ctx *fiber.Ctx) error { + fasthttpadaptor.NewFastHTTPHandler(swaggerHandler)(ctx.Context()) + return nil + } +} + +func mergeUserFiles(ctx *fiber.Ctx) error { + if err := mergeDocsFiles(ctx, user); err != nil { + return err + } + return ctx.Next() +} diff --git a/microservices/doc/app/user/info.yml b/microservices/doc/app/user/info.yml new file mode 100644 index 00000000..89bee2b7 --- /dev/null +++ b/microservices/doc/app/user/info.yml @@ -0,0 +1,13 @@ +--- +openapi: 3.0.2 +info: + description: "Documentation for the Alexandrio's USER microsecervice REST API\n\n + You can find the documentation of the others MS in these pages:\n\n + Auth + User + Library + Media" + version: v1 + title: USER Documentation +paths: + diff --git a/microservices/documentation/app/user/paths/User.yml b/microservices/doc/app/user/paths/User.yml similarity index 86% rename from microservices/documentation/app/user/paths/User.yml rename to microservices/doc/app/user/paths/User.yml index ae9930c3..88ab9c81 100644 --- a/microservices/documentation/app/user/paths/User.yml +++ b/microservices/doc/app/user/paths/User.yml @@ -6,15 +6,15 @@ paths: summary: Get User responses: "200": - $ref: "#/components/schemas/UserResponse" + $ref: "#/components/schemas/UserDataResponse" "401": $ref: "#/components/schemas/UnauthorizedErrorResponse" security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //user.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //user.preprod.alexandrio.cloud description: Preprod server tags: - USER @@ -37,11 +37,11 @@ paths: "401": $ref: "#/components/schemas/UnauthorizedErrorResponse" security: - - Bearer Auth: [] + - bearerAuth: [] servers: - url: //user.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //user.preprod.alexandrio.cloud description: Preprod server tags: - USER @@ -55,11 +55,11 @@ paths: "401": $ref: "#/components/schemas/UnauthorizedErrorResponse" security: - - Bearer Auth: [ ] + - bearerAuth: [] servers: - url: //user.alexandrio.cloud description: Production server - - url: //auth.preprod.alexandrio.cloud + - url: //user.preprod.alexandrio.cloud description: Preprod server tags: - USER diff --git a/microservices/doc/app/user/schemas/BadInput.yml b/microservices/doc/app/user/schemas/BadInput.yml new file mode 100644 index 00000000..0e4e32b8 --- /dev/null +++ b/microservices/doc/app/user/schemas/BadInput.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + BadInput: + properties: + fields: + items: + $ref: "#/components/schemas/Field" + type: array + type: object diff --git a/microservices/doc/app/user/schemas/BadRequestResponse.yml b/microservices/doc/app/user/schemas/BadRequestResponse.yml new file mode 100644 index 00000000..5e65576b --- /dev/null +++ b/microservices/doc/app/user/schemas/BadRequestResponse.yml @@ -0,0 +1,9 @@ +--- +components: + schemas: + BadRequestErrorResponse: + description: Bad Request + content: + application/json: + schema: + $ref: "#/components/schemas/BadInput" diff --git a/microservices/doc/app/user/schemas/Field.yml b/microservices/doc/app/user/schemas/Field.yml new file mode 100644 index 00000000..a2bbcc73 --- /dev/null +++ b/microservices/doc/app/user/schemas/Field.yml @@ -0,0 +1,10 @@ +--- +components: + schemas: + Field: + properties: + name: + type: string + reason: + type: string + type: object diff --git a/microservices/documentation/app/user/schemas/NoContentResponse.yml b/microservices/doc/app/user/schemas/NoContentResponse.yml similarity index 100% rename from microservices/documentation/app/user/schemas/NoContentResponse.yml rename to microservices/doc/app/user/schemas/NoContentResponse.yml diff --git a/microservices/doc/app/user/schemas/UnauthorizedErrorResponse.yml b/microservices/doc/app/user/schemas/UnauthorizedErrorResponse.yml new file mode 100644 index 00000000..06a38a3e --- /dev/null +++ b/microservices/doc/app/user/schemas/UnauthorizedErrorResponse.yml @@ -0,0 +1,5 @@ +--- +components: + schemas: + UnauthorizedErrorResponse: + description: Unauthorized diff --git a/microservices/doc/app/user/schemas/User.yml b/microservices/doc/app/user/schemas/User.yml new file mode 100644 index 00000000..f1aac1e6 --- /dev/null +++ b/microservices/doc/app/user/schemas/User.yml @@ -0,0 +1,27 @@ +--- +components: + schemas: + User: + description: User defines the structure for an API user + properties: + auth_token: + description: The authentication token of this user. Valid for 15 minutes. + example: eyJhb[...]FYqf4 + type: string + email: + description: The email address of this user + example: john@provider.net + type: string + refresh_token: + description: The refresh token of this user. Valid for 30 days. Used to get a new + auth token. + example: eyJhb[...]FYqf4 + type: string + username: + description: The username of this user + example: john + type: string + required: + - username + - email + type: object diff --git a/microservices/documentation/app/user/schemas/UserData.yml b/microservices/doc/app/user/schemas/UserData.yml similarity index 100% rename from microservices/documentation/app/user/schemas/UserData.yml rename to microservices/doc/app/user/schemas/UserData.yml diff --git a/microservices/doc/app/user/schemas/UserDataResponse.yml b/microservices/doc/app/user/schemas/UserDataResponse.yml new file mode 100644 index 00000000..5614e845 --- /dev/null +++ b/microservices/doc/app/user/schemas/UserDataResponse.yml @@ -0,0 +1,22 @@ +--- +components: + schemas: + UserDataResponse: + description: User's data response + content: + application/json: + schema: + description: User's data + properties: + email: + description: The email address of this user + example: john@provider.net + type: string + username: + description: The username of this user + example: john + type: string + required: + - username + - email + type: object diff --git a/microservices/doc/app/user/security.yml b/microservices/doc/app/user/security.yml new file mode 100644 index 00000000..e3aea845 --- /dev/null +++ b/microservices/doc/app/user/security.yml @@ -0,0 +1,9 @@ +--- +components: + securitySchemes: + bearerAuth: + description: "Go to /auth to see more documentation." + type: http + scheme: bearer + bearerFormat: JWT + diff --git a/microservices/documentation/deployment/prod/app/Deployment.yaml b/microservices/doc/deployment/preprod/app/Deployment.yaml similarity index 79% rename from microservices/documentation/deployment/prod/app/Deployment.yaml rename to microservices/doc/deployment/preprod/app/Deployment.yaml index 8535ae0d..51e1c38b 100644 --- a/microservices/documentation/deployment/prod/app/Deployment.yaml +++ b/microservices/doc/deployment/preprod/app/Deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: api - namespace: documentation + namespace: doc labels: app: api spec: @@ -17,7 +17,7 @@ spec: spec: containers: - name: api - image: docker.pkg.github.com/alexandr-io/backend/documentation:latest + image: docker.pkg.github.com/alexandr-io/backend/doc:latest-preprod imagePullPolicy: Always imagePullSecrets: - name: regcred @@ -27,7 +27,7 @@ apiVersion: v1 kind: Service metadata: name: api - namespace: documentation + namespace: doc spec: selector: app: api diff --git a/microservices/documentation/deployment/preprod/app/Ingress.yaml b/microservices/doc/deployment/preprod/app/Ingress.yaml similarity index 91% rename from microservices/documentation/deployment/preprod/app/Ingress.yaml rename to microservices/doc/deployment/preprod/app/Ingress.yaml index cee62e1b..1dde543b 100644 --- a/microservices/documentation/deployment/preprod/app/Ingress.yaml +++ b/microservices/doc/deployment/preprod/app/Ingress.yaml @@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress - namespace: documentation + namespace: doc spec: rules: - host: doc.preprod.alexandrio.cloud diff --git a/microservices/documentation/deployment/prod/configs.txt b/microservices/doc/deployment/preprod/configs.txt similarity index 100% rename from microservices/documentation/deployment/prod/configs.txt rename to microservices/doc/deployment/preprod/configs.txt diff --git a/microservices/documentation/deployment/preprod/app/Deployment.yaml b/microservices/doc/deployment/prod/app/Deployment.yaml similarity index 78% rename from microservices/documentation/deployment/preprod/app/Deployment.yaml rename to microservices/doc/deployment/prod/app/Deployment.yaml index 6e3e5428..1e288522 100644 --- a/microservices/documentation/deployment/preprod/app/Deployment.yaml +++ b/microservices/doc/deployment/prod/app/Deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: api - namespace: documentation + namespace: doc labels: app: api spec: @@ -17,7 +17,7 @@ spec: spec: containers: - name: api - image: docker.pkg.github.com/alexandr-io/backend/documentation:latest-preprod + image: docker.pkg.github.com/alexandr-io/backend/doc:latest imagePullPolicy: Always imagePullSecrets: - name: regcred @@ -27,7 +27,7 @@ apiVersion: v1 kind: Service metadata: name: api - namespace: documentation + namespace: doc spec: selector: app: api diff --git a/microservices/documentation/deployment/prod/app/Ingress.yaml b/microservices/doc/deployment/prod/app/Ingress.yaml similarity index 91% rename from microservices/documentation/deployment/prod/app/Ingress.yaml rename to microservices/doc/deployment/prod/app/Ingress.yaml index bc74779e..f07812d0 100644 --- a/microservices/documentation/deployment/prod/app/Ingress.yaml +++ b/microservices/doc/deployment/prod/app/Ingress.yaml @@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress - namespace: documentation + namespace: doc spec: rules: - host: doc.alexandrio.cloud diff --git a/microservices/doc/deployment/prod/configs.txt b/microservices/doc/deployment/prod/configs.txt new file mode 100644 index 00000000..e69de29b diff --git a/microservices/documentation/app/.gitignore b/microservices/documentation/app/.gitignore deleted file mode 100644 index 68f139fc..00000000 --- a/microservices/documentation/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -swagger.yml diff --git a/microservices/documentation/app/info.yml b/microservices/documentation/app/info.yml deleted file mode 100644 index c3062f06..00000000 --- a/microservices/documentation/app/info.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -openapi: 3.0.2 -info: - description: Documentation for the Alexandrio's REST API - title: REST API Documentation -schemes: - - http -tags: - - name: AUTH - description: Micro service auth. Everything about the authentication - - name: USER - description: Micro service user. Everything about the users diff --git a/microservices/documentation/app/mergeFile.go b/microservices/documentation/app/mergeFile.go deleted file mode 100644 index e96cd9a8..00000000 --- a/microservices/documentation/app/mergeFile.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "io/ioutil" - "log" - "os" - "path/filepath" - - "github.com/gofiber/fiber/v2" - "github.com/miracl/conflate" -) - -func getAllFilesToMerge(thisDir string) ([]string, error) { - var matches []string - err := filepath.Walk(thisDir, func(path string, f os.FileInfo, err error) error { - if filepath.Base(path) == "swagger.yml" { - return nil - } - if filepath.Ext(path) == ".yml" || filepath.Ext(path) == ".yaml" { - matches = append(matches, path) - } - return nil - }) - return matches, err -} - -func mergeDocsFiles(ctx *fiber.Ctx) error { - thisDir, err := os.Getwd() - if err != nil { - log.Println(err) - return err - } - - matches, err := getAllFilesToMerge(thisDir) - if err != nil { - log.Println(err) - return err - } - - c := conflate.New() - if err := c.AddFiles(matches...); err != nil { - log.Println(err) - return err - } - yaml, err := c.MarshalYAML() - if err != nil { - log.Println(err) - return err - } - - if err := ioutil.WriteFile(thisDir+"/swagger.yml", yaml, 0644); err != nil { - log.Println(err) - return err - } - return ctx.Next() -}