Skip to content

Commit

Permalink
Use Swashbuckle.AspNetCore.Cli to generate schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Syriiin committed May 18, 2024
1 parent dd47a35 commit 3f4d22a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"swashbuckle.aspnetcore.cli": {
"version": "6.6.1",
"commands": [
"swagger"
]
}
}
}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ start-dev: build-dev ## Starts development environment
clean-dev: ## Cleans development environment
$(COMPOSE_APP_DEV) down --remove-orphans

update-api-reference: start-dev ## Updates OpenAPI schemas in docs site
@scripts/update-api-reference.sh
update-api-reference: ## Updates OpenAPI schemas in docs site
$(COMPOSE_TOOLING_RUN) scripts/update-api-reference.sh

check-api-reference: start-dev ## Checks OpenAPI schemas are updated
@scripts/check-api-reference.sh
$(COMPOSE_TOOLING_RUN) scripts/check-api-reference.sh

build-docs: ## Builds documentation site
$(COMPOSE_RUN_DOCS) build --strict --clean
Expand Down
2 changes: 2 additions & 0 deletions compose.tooling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ services:
build:
context: .
dockerfile: ./tooling.Dockerfile
volumes:
- .:/app
10 changes: 6 additions & 4 deletions scripts/check-api-reference.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
set -euo pipefail

diff -q docs/docs/api-reference/difficalcy-osu.json <(curl --silent localhost:5000/swagger/v1/swagger.json)
diff -q docs/docs/api-reference/difficalcy-taiko.json <(curl --silent localhost:5001/swagger/v1/swagger.json)
diff -q docs/docs/api-reference/difficalcy-catch.json <(curl --silent localhost:5002/swagger/v1/swagger.json)
diff -q docs/docs/api-reference/difficalcy-mania.json <(curl --silent localhost:5003/swagger/v1/swagger.json)
dotnet build

diff -q docs/docs/api-reference/difficalcy-osu.json <(dotnet tool run swagger tofile Difficalcy.Osu/bin/Debug/net8.0/Difficalcy.Osu.dll v1)
diff -q docs/docs/api-reference/difficalcy-taiko.json <(dotnet tool run swagger tofile Difficalcy.Taiko/bin/Debug/net8.0/Difficalcy.Taiko.dll v1)
diff -q docs/docs/api-reference/difficalcy-catch.json <(dotnet tool run swagger tofile Difficalcy.Catch/bin/Debug/net8.0/Difficalcy.Catch.dll v1)
diff -q docs/docs/api-reference/difficalcy-mania.json <(dotnet tool run swagger tofile Difficalcy.Mania/bin/Debug/net8.0/Difficalcy.Mania.dll v1)
10 changes: 6 additions & 4 deletions scripts/update-api-reference.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
set -euo pipefail

curl localhost:5000/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-osu.json
curl localhost:5001/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-taiko.json
curl localhost:5002/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-catch.json
curl localhost:5003/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-mania.json
dotnet build

dotnet tool run swagger tofile Difficalcy.Osu/bin/Debug/net8.0/Difficalcy.Osu.dll v1 > docs/docs/api-reference/difficalcy-osu.json
dotnet tool run swagger tofile Difficalcy.Taiko/bin/Debug/net8.0/Difficalcy.Taiko.dll v1 > docs/docs/api-reference/difficalcy-taiko.json
dotnet tool run swagger tofile Difficalcy.Catch/bin/Debug/net8.0/Difficalcy.Catch.dll v1 > docs/docs/api-reference/difficalcy-catch.json
dotnet tool run swagger tofile Difficalcy.Mania/bin/Debug/net8.0/Difficalcy.Mania.dll v1 > docs/docs/api-reference/difficalcy-mania.json
4 changes: 4 additions & 0 deletions tooling.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | d

WORKDIR /app

COPY .config/dotnet-tools.json ./.config/

RUN dotnet tool restore

COPY Difficalcy.sln .
COPY Difficalcy/Difficalcy.csproj ./Difficalcy/
COPY Difficalcy.Catch/Difficalcy.Catch.csproj ./Difficalcy.Catch/
Expand Down

0 comments on commit 3f4d22a

Please sign in to comment.