Skip to content

Commit 3f4d22a

Browse files
committed
Use Swashbuckle.AspNetCore.Cli to generate schemas
1 parent dd47a35 commit 3f4d22a

6 files changed

+33
-11
lines changed

.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"swashbuckle.aspnetcore.cli": {
6+
"version": "6.6.1",
7+
"commands": [
8+
"swagger"
9+
]
10+
}
11+
}
12+
}

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ start-dev: build-dev ## Starts development environment
2727
clean-dev: ## Cleans development environment
2828
$(COMPOSE_APP_DEV) down --remove-orphans
2929

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

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

3636
build-docs: ## Builds documentation site
3737
$(COMPOSE_RUN_DOCS) build --strict --clean

compose.tooling.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ services:
33
build:
44
context: .
55
dockerfile: ./tooling.Dockerfile
6+
volumes:
7+
- .:/app

scripts/check-api-reference.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
diff -q docs/docs/api-reference/difficalcy-osu.json <(curl --silent localhost:5000/swagger/v1/swagger.json)
5-
diff -q docs/docs/api-reference/difficalcy-taiko.json <(curl --silent localhost:5001/swagger/v1/swagger.json)
6-
diff -q docs/docs/api-reference/difficalcy-catch.json <(curl --silent localhost:5002/swagger/v1/swagger.json)
7-
diff -q docs/docs/api-reference/difficalcy-mania.json <(curl --silent localhost:5003/swagger/v1/swagger.json)
4+
dotnet build
5+
6+
diff -q docs/docs/api-reference/difficalcy-osu.json <(dotnet tool run swagger tofile Difficalcy.Osu/bin/Debug/net8.0/Difficalcy.Osu.dll v1)
7+
diff -q docs/docs/api-reference/difficalcy-taiko.json <(dotnet tool run swagger tofile Difficalcy.Taiko/bin/Debug/net8.0/Difficalcy.Taiko.dll v1)
8+
diff -q docs/docs/api-reference/difficalcy-catch.json <(dotnet tool run swagger tofile Difficalcy.Catch/bin/Debug/net8.0/Difficalcy.Catch.dll v1)
9+
diff -q docs/docs/api-reference/difficalcy-mania.json <(dotnet tool run swagger tofile Difficalcy.Mania/bin/Debug/net8.0/Difficalcy.Mania.dll v1)

scripts/update-api-reference.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
curl localhost:5000/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-osu.json
5-
curl localhost:5001/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-taiko.json
6-
curl localhost:5002/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-catch.json
7-
curl localhost:5003/swagger/v1/swagger.json -o docs/docs/api-reference/difficalcy-mania.json
4+
dotnet build
5+
6+
dotnet tool run swagger tofile Difficalcy.Osu/bin/Debug/net8.0/Difficalcy.Osu.dll v1 > docs/docs/api-reference/difficalcy-osu.json
7+
dotnet tool run swagger tofile Difficalcy.Taiko/bin/Debug/net8.0/Difficalcy.Taiko.dll v1 > docs/docs/api-reference/difficalcy-taiko.json
8+
dotnet tool run swagger tofile Difficalcy.Catch/bin/Debug/net8.0/Difficalcy.Catch.dll v1 > docs/docs/api-reference/difficalcy-catch.json
9+
dotnet tool run swagger tofile Difficalcy.Mania/bin/Debug/net8.0/Difficalcy.Mania.dll v1 > docs/docs/api-reference/difficalcy-mania.json

tooling.Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | d
88

99
WORKDIR /app
1010

11+
COPY .config/dotnet-tools.json ./.config/
12+
13+
RUN dotnet tool restore
14+
1115
COPY Difficalcy.sln .
1216
COPY Difficalcy/Difficalcy.csproj ./Difficalcy/
1317
COPY Difficalcy.Catch/Difficalcy.Catch.csproj ./Difficalcy.Catch/

0 commit comments

Comments
 (0)