Skip to content

Commit

Permalink
Prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
atrakic committed Jun 8, 2024
1 parent ef55bed commit 8329d23
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 15 deletions.
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ all:
dotnet build --configuration Release --no-restore
dotnet test --no-restore --verbosity normal

help-generator:
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli help config-help
HELP_ARGS ?= "help"

help: ### make help HELP_ARGS="help generate"
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli $(HELP_ARGS)

bootstrap:
dotnet new tool-manifest --force
dotnet tool install Microsoft.dotnet-openapi
dotnet tool list
#dotnet new solution
#dotnet new gitignore --force
#dotnet new xunit -o tests/DotnetOpenapi.Tests
#dotnet sln add tests/DotnetOpenapi.Tests/DotnetOpenapi.Tests.csproj
#pushd tests/DotnetOpenapi.Tests
#dotnet add reference ../../src/src.csproj
#popd
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Echo.Api - ASP.NET Core 6.0 Server

A simple API to store and retrieve messages.

## Upgrade NuGet Packages

NuGet packages get frequently updated.

To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool.


Install dotnet-outdated tool:

```
dotnet tool install --global dotnet-outdated-tool
```

Upgrade only to new minor versions of packages

```
dotnet outdated --upgrade --version-lock Major
```

Upgrade to all new versions of packages (more likely to include breaking API changes)

```
dotnet outdated --upgrade
```


## Run

Linux/OS X:

```
sh build.sh
```

Windows:

```
build.bat
```
## Run in Docker

```
cd src/Echo.Api
docker build -t echo.api .
docker run -p 5000:8080 echo.api
```
9 changes: 9 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:: Generated by: https://openapi-generator.tech
::

@echo off

dotnet restore src\Echo.Api
dotnet build src\Echo.Api
echo Now, run the following to start the project: dotnet run -p src\Echo.Api\Echo.Api.csproj --launch-profile web.
echo.
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Generated by: https://openapi-generator.tech
#

dotnet restore src/Echo.Api/ && \
dotnet build src/Echo.Api/ && \
echo "Now, run the following to start the project: dotnet run -p src/Echo.Api/Echo.Api.csproj --launch-profile web"
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

aspnetCoreVersion: 6.0
swashbuckleVersion: 6.4.0
packageName: Echo.Api
packageName: Echo.OpenAPI
useSeparateModelProject: true

# Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only) (Default: false)
Expand Down
5 changes: 1 addition & 4 deletions echo.yaml → openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# create openapi spec for rest Echo api.
# The api should support storing getting and updating messages to the database.
# https://github.com/OAI/OpenAPI-Specification/tree/main/examples/v3.0

openapi: 3.0.2

servers:
Expand Down Expand Up @@ -82,4 +79,4 @@ components:
type: string
required:
- id
- message
- message
8 changes: 7 additions & 1 deletion scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/usr/bin/env bash

out="${1}"

# https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/aspnetcore.md
# docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli help config-help
# docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli config-help -g aspnetcore

spec=openapi.yaml
image=openapitools/openapi-generator-cli
docker pull -q "$image"

docker run --rm -e CSHARP_POST_PROCESS_FILE=${CSHARP_POST_PROCESS_FILE} -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
--skip-validate-spec \
--enable-post-process-file \
-c /local/config.yaml \
-i /local/echo.yaml \
-i /local/"$spec" \
-g aspnetcore \
-o /local/"$out"

dos2unix $(find . -type f -exec grep -I -q . {} \; -print)
pre-commit run -a

0 comments on commit 8329d23

Please sign in to comment.