Skip to content
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

simple swaggerui support #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

slmgong
Copy link

@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

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

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.

None yet

4 participants