asyncapi / saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.
https://www.asyncapi.com/
MIT License
199 stars 56 forks source link

Multiple async api #104

Closed JanEggers closed 3 years ago

JanEggers commented 3 years ago

fixes #64

also contains some more null fixes related to njsonschema.

the concept revolves around having named options per api. that way most of the api can remain the same.

usage:

public virtual void ConfigureServices(IServiceCollection services)
{
            services.AddAsyncApiSchemaGeneration();
            services.ConfigureNamedAsyncApi("A", asyncApi =>
            {
                  ....
                asyncApi.Middleware.Route = "/asyncapi/a/asyncapi.json";
                asyncApi.Middleware.UiBaseRoute = "/asyncapi/a/ui/";
            });

            services.ConfigureNamedAsyncApi("B", asyncApi =>
            {
                  ....
                asyncApi.Middleware.Route = "/asyncapi/b/asyncapi.json";
                asyncApi.Middleware.UiBaseRoute = "/asyncapi/b/ui/";
            });
}

public virtual void Configure(IApplicationBuilder app)
        {
              ...
            app.UseMiddleware<AsyncApiMiddleware>("A");
            app.UseMiddleware<AsyncApiMiddleware>("B");

            app.UseMiddleware<AsyncApiUiMiddleware>("A");
            app.UseMiddleware<AsyncApiUiMiddleware>("B");
        }

    [AsyncApi("A")]
    public class ASender {
   } 

    [AsyncApi("B")]
    public class BSender {} 
JanEggers commented 3 years ago

thx alot for the quick review i will be happy if i can drop the submodule and use the official nuget again :)

JanEggers commented 3 years ago

I just tested with .net 5 and there is an issue with the ui (before i was just testing with aspnet2.1 that is different because endpoint routing is not present) i will push a fix once i found what is wrong

m-wild commented 3 years ago

I think it’s the NPM files being excluded. I was planning to move them to a separate directory outside the csproj path. I will do this tomorrow, so don’t worry about it 🙂

JanEggers commented 3 years ago

i fixed it for now you have been correct it was just missing the static files. anyway while testing with net5 i noticed that with that version you have routevalues on the request so the routematching code could be simplified a bit