Skip to content

simple swaggerui support#43

Open
slmgong wants to merge 4 commits intoOrleansContrib:masterfrom
slmgong:master
Open

simple swaggerui support#43
slmgong wants to merge 4 commits intoOrleansContrib:masterfrom
slmgong:master

Conversation

@slmgong
Copy link
Copy Markdown

@slmgong slmgong commented Sep 3, 2020

add a SwashbuckleOrleansDescriptionProvider , which analysis Orleans.Http.Abstractions attribute then return
IApiDescriptionGroupCollectionProvider instance.

slm1800 and others added 4 commits August 18, 2020 16:10
in host startup.cs just call like '
   services.AddMvcCore().AddApiExplorer();
   services.AddSwashbuckleOrleans();
    services.AddSwaggerGen(c =>{});
'
@oising
Copy link
Copy Markdown

oising commented Jun 24, 2022

Doesn't seem to work? I followed the readme instructions, (also had to add Swashbuckle.AspNetCore to the host example project) and when visiting the swagger ui, it fails to pick up any information on the IHelloGrain sample:

image

@jaredthirsk
Copy link
Copy Markdown

jaredthirsk commented Jul 1, 2022

@oising @vivid216

I got endpoints to show up by changing SwashbuckleOrleansDescriptionProvider.CreateDescriptors as follows:

    var pattern = methodAttributes.Pattern;
    if(string.IsNullOrWhiteSpace(pattern))
    {
        pattern = "{optionalPrefix}/{optionalTopLevelPattern}{grainTypeName}/{grainId}/{methodName}";
    }
    string optionalPrefix = "grains"; // TODO MOVE to configuration
    string optionalTopLevelPatternWithTrailingSlash = ""; // TODO MOVE to configuration

    var relativePath = pattern
        .Replace("{optionalPrefix}", optionalPrefix)
        .Replace("{optionalTopLevelPattern}", optionalTopLevelPatternWithTrailingSlash)
        .Replace("{grainTypeName}", grainType.FullName)
        .Replace("{methodName}", methodInfo.Name)
        ;

    var description = new ApiDescription()
    {
        ActionDescriptor = descriptor,
        //GroupName = groupName, // Causes things to be skipped by default if the group doesn't match the documentName (SwaggerGeneratorOptions.DefaultOperationIdSelector)
        HttpMethod = methodAttributes.Method,
        RelativePath = relativePath
    };

If you want to see the full file, I checked in my version here:

https://github.com/lionfire/Core/blob/master/src/LionFire.Orleans.Http.Swagger/SwashbuckleOrleansDescriptionProvider.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants