0

I have an API that is using MagicOnion and MessagePack in .NET. I am using swagger like this:

public static IServiceCollection AddMagicOnionServices(this IServiceCollection services)
{
    services.AddMagicOnion();
    MessagePackSerializer.DefaultOptions =
        MessagePackSerializerOptions.Standard.WithResolver(
            CompositeResolver.Create(
                ContractlessStandardResolver.Instance,
                StandardResolver.Instance));

    services.AddApiVersioning(o =>
    {
        o.DefaultApiVersion = new ApiVersion(1, 0);
        o.AssumeDefaultVersionWhenUnspecified = false;
        o.RouteConstraintName = "apiVersion";
        o.ApiVersionReader = new UrlSegmentApiVersionReader();
        o.ReportApiVersions = true;
    })
    .AddMvc()
    .AddApiExplorer(
        o =>
        {
            // ReSharper disable once StringLiteralTypo
            o.GroupNameFormat = "'v'VVV";
            o.SubstituteApiVersionInUrl = true;
        });

    services.AddSwaggerGen(
        options =>
        {
            options.AddEnumsWithValuesFixFilters().EnableAnnotations(true, true);

            if (Assembly.GetExecutingAssembly().Location is { } location)
            {
                options.IncludeXmlComments(Path.ChangeExtension(location, ".xml"));
                options.IncludeGrpcXmlComments(Path.ChangeExtension(location, ".xml"), true);
            }
        });

    return services;
}

public static void UseAppSwagger(this WebApplication app)
{
    app.UseSwagger(o => o.RouteTemplate = "/swagger-rest/{documentName}/swagger.json");
    app.UseSwaggerUI(o => o.RoutePrefix = "swagger-rest");
}

I am able to open swagger and send requests :

swagger

But how to import it or use endpoints from Postman? Before when API was using protobuf instead of MessagePack, I was able to import protobufs in postman and send request using Grpc

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.