Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#197 Produce AsyncAPI documents at build time (AsyncAPI.Saunter.Generator.Build) #219

Draft
wants to merge 75 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
6318f80
#196 Publish a global dotnet tool
Jul 6, 2024
2162d72
#196 Publish a global dotnet tool -- Api/API casing fix
Jul 6, 2024
55895a2
#196 .NET8
Jul 6, 2024
6ba3409
#196 .NET6
Jul 6, 2024
74c9cff
#196 I'd like .NET8 more, request both for ci
Jul 6, 2024
cc5d952
#196 I'd like .NET8 more, request both for ci?
Jul 6, 2024
569a30a
#196 Fixed resolving, added support for multiple asyncAPI documents, …
Jul 6, 2024
0419101
#196 Test for dotnet cli tool, added support for default asyncapi doc…
Jul 6, 2024
b29a1ab
#196 Pack_Install_Run_Uninstall Test
Jul 6, 2024
12593dc
#196 Pack_Install_Run_Uninstall fix casing in test, add meta data to …
Jul 6, 2024
93dc17e
#196 fix accident
Jul 6, 2024
e701660
#196 fix warnings, fix permission
Jul 6, 2024
d9b558c
#196 unix needs a shebang
Jul 6, 2024
f0af6d1
#196 sourcelink properties
Jul 6, 2024
a379a3e
#197 Produce AsyncAPI documents at build time
Jul 6, 2024
02ffbcd
#197 Produce AsyncAPI documents at build time
Jul 7, 2024
1ebb77c
#196 renamed tool to make up a more logical name, fixed empty paramet…
Jul 7, 2024
ba1e856
#196 fix readme error
Jul 7, 2024
88c5caf
Merge remote-tracking branch 'remotes/smoerijf/#196-Publish-a-global-…
Jul 7, 2024
a2813e2
#197 Produce AsyncAPI documents at build time - test + setup with loc…
Jul 7, 2024
a42ab3f
#197 local nuget source folder should exist
Jul 7, 2024
d3f0472
#197 update readme's
Jul 7, 2024
e10112b
#197 set streetlights example to depend on the Generator.Build projec…
Jul 7, 2024
4741f56
#197 undo streetlights example order, use 2 step build approach
Jul 7, 2024
195dc14
#197 use better path to the dotnet dll in tools and hopefully fix the…
Jul 7, 2024
8583f08
#197 need more logging
Jul 7, 2024
2f2c172
#197 need more logging - dir logs
Jul 7, 2024
0c033f1
#197 slashes?
Jul 7, 2024
31bacc6
#197 idk
Jul 7, 2024
fbbf601
Merge branch '#197-more-logging' of https://github.com/smoerijf/saunt…
Jul 7, 2024
6cc92e3
#197 try by installing local tool
Jul 7, 2024
df5636e
#197 bump net version
Jul 7, 2024
829d5a5
#197 install dotnet in .nuget iso the csproj root
Jul 7, 2024
49fb31f
#197 use 999.* for local nuget package buils to use in tests and exam…
Jul 7, 2024
f110afe
#197 readme style
Jul 7, 2024
1b7087a
#197 pin .Cli version to beta in .Build
Jul 8, 2024
90dcff1
Merge remote-tracking branch 'remotes/origin/main' into #196-Publish-…
Jul 8, 2024
a746e4d
#196 Fixed formatting etc + some PR remarks
Jul 9, 2024
8e7a01f
#196 Tool rewrite to make its components testable, removed Swachbuckl…
Jul 9, 2024
240c9ed
#196 formatting
Jul 9, 2024
715a62d
#196 add unitTests for tofile classes
Jul 10, 2024
e181850
#196 add unitTests for tofile
Jul 10, 2024
ab5b375
#196-Publish-a-global-dotnet-tool
Jul 11, 2024
183a4e8
#196 formatting
Jul 11, 2024
8d2fd49
#196 ALL tests should run
Jul 11, 2024
a9d544a
#196 Tests use streetlights DLL in integegration tests, add dependency
Jul 11, 2024
72dc742
#196 release also the CLI tool
Jul 11, 2024
2c6e2d9
#197 formatting
Jul 11, 2024
5823431
Merge remote-tracking branch 'remotes/smoerijf/#196-Publish-a-global-…
Jul 11, 2024
38ac1eb
#197 .build nuget package
Jul 13, 2024
6099e65
#197 fix test
Jul 13, 2024
e804aaf
Merge branch '#197-more-logging' of https://github.com/smoerijf/saunt…
Jul 13, 2024
1bb7d30
#196 fix wrong ci.yml merge
Jul 13, 2024
0babe05
#196 2 phase build: first src, then the others
Jul 13, 2024
9ee1100
#196 fix formatting
Jul 13, 2024
7c5095a
#196 test after build
Jul 13, 2024
d30c503
#196 test needs build
Jul 13, 2024
e739072
#196 trying...
Jul 13, 2024
ba95b28
#196 seperate job is inpossible, giving up on it
Jul 13, 2024
a9cc0de
#197 wording
Jul 13, 2024
e16fcf1
#197 common.props
Jul 13, 2024
7b22ce0
#196 Add example project with top level statement, because that faile…
Jul 13, 2024
ba8dd8e
#196 Ignore expected warning (ASP0014 needs #173)
Jul 13, 2024
3d6c0ea
#196 formatting and readme wording
Jul 13, 2024
8a4f5c6
#196 ExitCode test problems
Jul 13, 2024
07b4273
#196 ExitCode test problems -- the issue is a missing reference
Jul 13, 2024
e846dd9
#196 GetStreamFor logging
Jul 13, 2024
fc7cccd
#196 GetStreamFor try recreate directory?
Jul 13, 2024
4f1064e
#196 GetStreamFor try recreate directory??
Jul 13, 2024
74260a8
#196 permission issue?
Jul 13, 2024
e937716
Merge branch '#196-Publish-a-global-dotnet-tool' into #197-more-logging
Jul 13, 2024
a2cee95
#197 cleanup csproj
Jul 13, 2024
b043a77
#197 cleanup csproj
Jul 13, 2024
5fe8c6e
#196 cleanup csproj
Jul 13, 2024
68e06ca
Merge remote-tracking branch 'remotes/smoerijf/#196-Publish-a-global-…
Jul 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ spelling_exclusion_path = SpellingExclusions.dic
indent_size = 4
insert_final_newline = true
charset = utf-8-bom
end_of_line = lf

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 4
indent_size = 2
end_of_line = lf

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
Expand Down Expand Up @@ -142,8 +144,6 @@ dotnet_naming_symbols.all_members.applicable_kinds = *

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.

# RS0016: Only enable if API files are present
dotnet_public_api_analyzer.require_api_files = true

Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
4 changes: 3 additions & 1 deletion .github/dotnet/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ runs:
id: setup-dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
dotnet-version: |
6.0.x
8.0.x
20 changes: 6 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ jobs:
- uses: actions/checkout@v2
- name: setup build
uses: ./.github/npm
- name: Run dotnet build
- name: Run dotnet build src
run: dotnet build ./src/Saunter-src.slnf --configuration Debug
- name: Run dotnet build all
run: dotnet build --configuration Debug
- name: unit test
run: dotnet test --no-build --configuration Debug

fmt:
runs-on: ubuntu-latest
Expand All @@ -24,18 +28,6 @@ jobs:
- name: setup dotnet
uses: ./.github/dotnet
- name: dotnet format check
run: dotnet format --verify-no-changes *.sln
run: dotnet format --verify-no-changes --no-restore *.sln
env:
PATH: ${{ github.env.PATH }}:/home/runner/.dotnet/tools

unit-test:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed separate unittest step because it causes a lot duplicate work:

  • It builds to whole solution again, while the build itself already does this
  • I couldn't get it working to let the test-job depend on the build job build output and use that to run tests.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup build
uses: ./.github/npm
- name: unit test
run: dotnet test ./test/Saunter.Tests/Saunter.Tests.csproj
# TODO: why there are 2 of them....
- name: unit mark test
run: dotnet test ./test/Saunter.Tests.MarkerTypeTests/Saunter.Tests.MarkerTypeTests.csproj
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# Gets the numeric version from a tag (e.g. v1.2.3 -> 1.2.3)
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Create Nuget package
run: dotnet pack ./src/Saunter/Saunter.csproj --configuration Release -p:Version="$RELEASE_VERSION" --output ./build
run: dotnet pack --configuration Release -p:Version="$RELEASE_VERSION" --output ./build
- name: Push Nuget package to Nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ PublishScripts/
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
local-nuget-source/
dotnet-tools.json

# Microsoft Azure Build Output
csx/
Expand Down
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<ItemGroup>
<!-- Make it possible for NSubstitube to make substitues of internal classes -->
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />

<!-- Make project internals visible to their respective .Tests project -->
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
</ItemGroup>
</Project>
89 changes: 89 additions & 0 deletions Saunter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{28D4C365-FDED-49AE-A97D-36202E24A55A}"
ProjectSection(SolutionItems) = preProject
src\Saunter-src.slnf = src\Saunter-src.slnf
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter", "src\Saunter\Saunter.csproj", "{240F263C-4F9B-40E0-8392-1FDB324153F6}"
EndProject
Expand All @@ -12,13 +15,24 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.Tests", "test\Saunter.Tests\Saunter.Tests.csproj", "{3ADB27EF-7C80-40EB-AFC6-5D06D415FFAB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{6ABD4842-47AF-49A5-B057-0EBA64416789}"
ProjectSection(SolutionItems) = preProject
examples\.gitignore = examples\.gitignore
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetlightsAPI", "examples\StreetlightsAPI\StreetlightsAPI.csproj", "{F188D4A7-BBCB-464F-A370-2BD84D18EA79}"
ProjectSection(ProjectDependencies) = postProject
{A320E670-5CB0-4815-AF67-D8D09FC92A2A} = {A320E670-5CB0-4815-AF67-D8D09FC92A2A}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
src\Common.NugetPackage.props = src\Common.NugetPackage.props
Directory.Build.props = Directory.Build.props
nuget.config = nuget.config
README.md = README.md
EndProjectSection
EndProject
Expand All @@ -42,6 +56,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "npm", "npm", "{E8FACA22-CFE
.github\npm\action.yaml = .github\npm\action.yaml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsyncAPI.Saunter.Generator.Cli", "src\AsyncAPI.Saunter.Generator.Cli\AsyncAPI.Saunter.Generator.Cli.csproj", "{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsyncAPI.Saunter.Generator.Cli.Tests", "test\AsyncAPI.Saunter.Generator.Cli.Tests\AsyncAPI.Saunter.Generator.Cli.Tests.csproj", "{18AD0249-0436-4A26-9972-B97BA6905A54}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetlightsAPI.TopLevelStatement", "examples\StreetlightsAPI.TopLevelStatement\StreetlightsAPI.TopLevelStatement.csproj", "{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsyncAPI.Saunter.Generator.Build", "src\AsyncAPI.Saunter.Generator.Build\AsyncAPI.Saunter.Generator.Build.csproj", "{A320E670-5CB0-4815-AF67-D8D09FC92A2A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsyncAPI.Saunter.Generator.Build.Tests", "test\AsyncAPI.Saunter.Generator.Build.Tests\AsyncAPI.Saunter.Generator.Build.Tests.csproj", "{61142B10-7B49-436E-AE32-2737658BD1E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -112,6 +136,66 @@ Global
{02284473-6DE7-4EE0-8433-2AC295045549}.Release|x64.Build.0 = Release|Any CPU
{02284473-6DE7-4EE0-8433-2AC295045549}.Release|x86.ActiveCfg = Release|Any CPU
{02284473-6DE7-4EE0-8433-2AC295045549}.Release|x86.Build.0 = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|x64.ActiveCfg = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|x64.Build.0 = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|x86.ActiveCfg = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Debug|x86.Build.0 = Debug|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|Any CPU.Build.0 = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|x64.ActiveCfg = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|x64.Build.0 = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|x86.ActiveCfg = Release|Any CPU
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}.Release|x86.Build.0 = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|x64.ActiveCfg = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|x64.Build.0 = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|x86.ActiveCfg = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Debug|x86.Build.0 = Debug|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|Any CPU.Build.0 = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|x64.ActiveCfg = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|x64.Build.0 = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|x86.ActiveCfg = Release|Any CPU
{18AD0249-0436-4A26-9972-B97BA6905A54}.Release|x86.Build.0 = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|x64.ActiveCfg = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|x64.Build.0 = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|x86.ActiveCfg = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Debug|x86.Build.0 = Debug|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|Any CPU.Build.0 = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|x64.ActiveCfg = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|x64.Build.0 = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|x86.ActiveCfg = Release|Any CPU
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA}.Release|x86.Build.0 = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|x64.ActiveCfg = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|x64.Build.0 = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|x86.ActiveCfg = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Debug|x86.Build.0 = Debug|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|Any CPU.Build.0 = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|x64.ActiveCfg = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|x64.Build.0 = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|x86.ActiveCfg = Release|Any CPU
{A320E670-5CB0-4815-AF67-D8D09FC92A2A}.Release|x86.Build.0 = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|x64.ActiveCfg = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|x64.Build.0 = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|x86.ActiveCfg = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Debug|x86.Build.0 = Debug|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|Any CPU.Build.0 = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|x64.ActiveCfg = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|x64.Build.0 = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|x86.ActiveCfg = Release|Any CPU
{61142B10-7B49-436E-AE32-2737658BD1E5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -124,6 +208,11 @@ Global
{02284473-6DE7-4EE0-8433-2AC295045549} = {6491E321-2D02-44AB-9116-D722FE169595}
{69459F9D-DA73-4E84-8BA7-4CE03E2B7664} = {D8CB9C0D-9605-457B-979F-C8994B20A926}
{E8FACA22-CFED-4710-89E4-D55F31BF96B3} = {D8CB9C0D-9605-457B-979F-C8994B20A926}
{6C102D4D-3DA4-4763-B75E-C15E33E7E94A} = {28D4C365-FDED-49AE-A97D-36202E24A55A}
{18AD0249-0436-4A26-9972-B97BA6905A54} = {6491E321-2D02-44AB-9116-D722FE169595}
{6F6B8B03-9045-46EC-AE12-E7ADA492F9FA} = {6ABD4842-47AF-49A5-B057-0EBA64416789}
{A320E670-5CB0-4815-AF67-D8D09FC92A2A} = {28D4C365-FDED-49AE-A97D-36202E24A55A}
{61142B10-7B49-436E-AE32-2737658BD1E5} = {6491E321-2D02-44AB-9116-D722FE169595}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2F85D9DA-DBCF-4F13-8C42-5719F1469B2E}
Expand Down
4 changes: 4 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
specs/
streetlights.json
streetlights.yml
streetlights.yaml
79 changes: 79 additions & 0 deletions examples/StreetlightsAPI.TopLevelStatement/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NLog;
using NLog.Web;
using Saunter;
using Saunter.AsyncApiSchema.v2;
using StreetlightsAPI;

LogManager.Setup().LoadConfigurationFromAppSettings();

var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddSimpleConsole(console => console.SingleLine = true);
builder.Host.UseNLog();

// Add Saunter to the application services.
builder.Services.AddAsyncApiSchemaGeneration(options =>
{
options.AssemblyMarkerTypes = [typeof(StreetlightMessageBus)];

options.Middleware.UiTitle = "Streetlights API";

options.AsyncApi = new AsyncApiDocument
{
Info = new Info("Streetlights API", "1.0.0")
{
Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.",
License = new License("Apache 2.0")
{
Url = "https://www.apache.org/licenses/LICENSE-2.0"
}
},
Servers =
{
["mosquitto"] = new Server("test.mosquitto.org", "mqtt"),
["webapi"] = new Server("localhost:5000", "http"),
},
};
});

builder.Services.AddScoped<IStreetlightMessageBus, StreetlightMessageBus>();
builder.Services.AddControllers();

var app = builder.Build();

app.UseDeveloperExceptionPage();

app.UseRouting();
app.UseCors(configure => configure.AllowAnyOrigin().AllowAnyMethod());

// to be fixed with issue #173
#pragma warning disable ASP0014 // Suggest using top level route registrations instead of UseEndpoints
app.UseEndpoints(endpoints =>
{
endpoints.MapAsyncApiDocuments();
endpoints.MapAsyncApiUi();

endpoints.MapControllers();
});
#pragma warning restore ASP0014 // Suggest using top level route registrations instead of UseEndpoints

await app.StartAsync();

// Print the AsyncAPI doc location
var logger = app.Services.GetService<ILoggerFactory>().CreateLogger<Program>();
var options = app.Services.GetService<IOptions<AsyncApiOptions>>();
var addresses = app.Urls;
logger.LogInformation("AsyncAPI doc available at: {URL}", $"{addresses.FirstOrDefault()}{options.Value.Middleware.Route}");
logger.LogInformation("AsyncAPI UI available at: {URL}", $"{addresses.FirstOrDefault()}{options.Value.Middleware.UiBaseRoute}");

// Redirect base url to AsyncAPI UI
app.Map("/", () => Results.Redirect("index.html"));
app.Map("/index.html", () => Results.Redirect(options.Value.Middleware.UiBaseRoute));

await app.WaitForShutdownAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<!-- This project is targeting .NET8 intentionally (The 'old school' Startup-class project is .NET6), to prove that
the AsyncAPI.Saunter.Generator.Cli tool can generate specs for projects targetting .NET6 and .NET8. -->
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>

<!-- Example settings for "AsyncAPI.Saunter.Generator.Build", they are all option though -->
<AsyncAPIGenerateDocumentsOnBuild>true</AsyncAPIGenerateDocumentsOnBuild>
<AsyncAPIDocumentFormats>json,yml</AsyncAPIDocumentFormats>
<AsyncAPIDocumentFilename>streetlights.{extension}</AsyncAPIDocumentFilename>
<AsyncAPIDocumentOutputPath>specs</AsyncAPIDocumentOutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>bin\Debug\StreetlightsAPI.TopLevelStatement.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\StreetlightsAPI.TopLevelStatement.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<!-- Get the latest local build nuget package from source code, from the local nuget packages source as configured in nuget.config
999.* are the 'special' version number for local builds -->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="AsyncAPI.Saunter.Generator.Build" Version="999.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- For release: use a real published nuget package -->
<ItemGroup Condition=" '$(Configuration)' == 'Release' ">
<PackageReference Include="AsyncAPI.Saunter.Generator.Build" Version="*-*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Saunter\Saunter.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="specs\" />

<Compile Include="../StreetlightsAPI/API.cs" />
<Compile Include="../StreetlightsAPI/Messaging.cs" />

<None Include="../StreetlightsAPI/nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="NLog" Version="5.3.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.11" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions examples/StreetlightsAPI.TopLevelStatement/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},

"AllowedHosts": "*",

"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5001"
}
}
}
}
Loading
Loading