forked from asyncapi/saunter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asyncapi#196 Fixed resolving, added support for multiple asyncAPI doc…
…uments, default all. Added support for env vars
- Loading branch information
Senn Geerts
authored and
Senn Geerts
committed
Jul 6, 2024
1 parent
cc5d952
commit 569a30a
Showing
7 changed files
with
118 additions
and
88 deletions.
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
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
28 changes: 28 additions & 0 deletions
28
src/AsyncAPI.Saunter.Generator.Cli/Internal/DependencyResolver.cs
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,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Reflection; | ||
|
||
namespace AsyncAPI.Saunter.Generator.Cli.Internal; | ||
|
||
internal static class DependencyResolver | ||
{ | ||
public static void Init() | ||
{ | ||
var basePath = Path.GetDirectoryName(typeof(Program).GetTypeInfo().Assembly.Location); | ||
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => | ||
{ | ||
var requestedAssembly = new AssemblyName(args.Name); | ||
var fullPath = Path.Combine(basePath, $"{requestedAssembly.Name}.dll"); | ||
if (File.Exists(fullPath)) | ||
{ | ||
var assembly = Assembly.LoadFile(fullPath); | ||
return assembly; | ||
} | ||
|
||
Console.WriteLine($"Could not resolve assembly: {args.Name}, requested by {args.RequestingAssembly?.FullName}"); | ||
return default; | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
# AsyncApi Generator.Cli Tool | ||
A dotnet tool to generate AsyncAPI specification files based of dotnet DLL (The application itself). | ||
|
||
## Tool usage | ||
``` | ||
dotnet asyncapi tofile --output [output-path] --format [json,yml,yaml] [startup-assembly] [asyncapi-document-name] | ||
dotnet asyncapi.net tofile --output [output-path] --format [json,yml,yaml] --doc [asyncapi-document-name] [startup-assembly] | ||
``` | ||
|
||
## Tool options | ||
startup-assembly: the file path to the entrypoint dotnet DLL that hosts AsyncAPI document(s). | ||
asyncapi-document-name: (optional) The name of the AsyncAPI document as defined in the startup class by the ```.ConfigureNamedAsyncApi()```-method. If not specified, all documents will be exported. | ||
|
||
--output: the output path or the file name. File extension can be omitted, as the --format file determine the file extension. | ||
## Tool options | ||
--doc: The name of the AsyncAPI document as defined in the startup class by the ```.ConfigureNamedAsyncApi()```-method. If not specified, all documents will be exported. | ||
--output: relative path where the AsyncAPI will be output [defaults to stdout] | ||
--filename: the template for the outputted file names. Default: "{document}_asyncapi.{extension}" | ||
--format: the output formats to generate, can be a combination of json, yml and/or yaml. File extension is appended to the output path. | ||
--env: define environment variable(s) for the application |