-
Notifications
You must be signed in to change notification settings - Fork 57
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
#196 Publish a global dotnet tool (AsyncAPI.Saunter.Generator.Cli) #217
Open
smoerijf
wants to merge
37
commits into
asyncapi:main
Choose a base branch
from
smoerijf:#196-Publish-a-global-dotnet-tool
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
6318f80
#196 Publish a global dotnet tool
2162d72
#196 Publish a global dotnet tool -- Api/API casing fix
55895a2
#196 .NET8
6ba3409
#196 .NET6
74c9cff
#196 I'd like .NET8 more, request both for ci
cc5d952
#196 I'd like .NET8 more, request both for ci?
569a30a
#196 Fixed resolving, added support for multiple asyncAPI documents, …
0419101
#196 Test for dotnet cli tool, added support for default asyncapi doc…
b29a1ab
#196 Pack_Install_Run_Uninstall Test
12593dc
#196 Pack_Install_Run_Uninstall fix casing in test, add meta data to …
93dc17e
#196 fix accident
e701660
#196 fix warnings, fix permission
d9b558c
#196 unix needs a shebang
f0af6d1
#196 sourcelink properties
1ebb77c
#196 renamed tool to make up a more logical name, fixed empty paramet…
ba1e856
#196 fix readme error
90dcff1
Merge remote-tracking branch 'remotes/origin/main' into #196-Publish-…
a746e4d
#196 Fixed formatting etc + some PR remarks
8e7a01f
#196 Tool rewrite to make its components testable, removed Swachbuckl…
240c9ed
#196 formatting
715a62d
#196 add unitTests for tofile classes
e181850
#196 add unitTests for tofile
ab5b375
#196-Publish-a-global-dotnet-tool
183a4e8
#196 formatting
8d2fd49
#196 ALL tests should run
a9d544a
#196 Tests use streetlights DLL in integegration tests, add dependency
72dc742
#196 release also the CLI tool
7b22ce0
#196 Add example project with top level statement, because that faile…
ba8dd8e
#196 Ignore expected warning (ASP0014 needs #173)
3d6c0ea
#196 formatting and readme wording
8a4f5c6
#196 ExitCode test problems
07b4273
#196 ExitCode test problems -- the issue is a missing reference
e846dd9
#196 GetStreamFor logging
fc7cccd
#196 GetStreamFor try recreate directory?
4f1064e
#196 GetStreamFor try recreate directory??
74260a8
#196 permission issue?
5fe8c6e
#196 cleanup csproj
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
specs/ | ||
streetlights.json | ||
streetlights.yml | ||
streetlights.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
46 changes: 46 additions & 0 deletions
46
examples/StreetlightsAPI.TopLevelStatement/StreetlightsAPI.TopLevelStatement.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added 2nd example project (also to be used in integration test) because Top Level Statement projects initially didn't work with the Generator.Cli tool. Now it does work too. And proves using integration test that both NET6 & NET8 targets work. |
||
<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> | ||
|
||
<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
19
examples/StreetlightsAPI.TopLevelStatement/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
autoReload="true"> | ||
|
||
<variable name="BaseDir" value="./" /> | ||
|
||
<!-- the targets to write to --> | ||
<targets> | ||
<!-- File Target for all log messages with basic details --> | ||
<target xsi:type="File" name="allfile" fileName="${BaseDir}/streetlights.nlog" | ||
layout="${longdate}|${level:uppercase=true}|${activity:property=TraceId}|${logger}|${message} ${exception:format=tostring}" | ||
maxArchiveFiles="5" archiveAboveSize="104857600" archiveNumbering="DateAndSequence" archiveDateFormat="yyyy-MM-dd" archiveFileName="${BaseDir}/streetlights-{#}.nlog" /> | ||
|
||
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection --> | ||
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" /> | ||
</targets> | ||
|
||
<!-- rules to map from logger name to target --> | ||
<rules> | ||
<logger name="*" minlevel="Debug" writeTo="allfile" /> | ||
</rules> | ||
</nlog> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current files were using a size of 2 and lf line endings, so I changed it (because my VS defaults are different)