Possible to show required Roles on Swagger UI

Hi,

Would it be possible to show required roles (aka scopes) for a route on the Swagger UI?
Also an indication whether a route is secured or not?
Thanks for the feedback.

We use the default Swagger UI as-is which generates its UI from the generated JSON specification. The only features we can enable must already exist in the Swagger UI and JSON Spec.

This SwaggerFeature is built on the Swagger 1.2 Specification. The JSON spec that’s returned can be modified from the filters on below:

public Action<SwaggerResourcesResponse> ResourcesResponseFilter { get; set; }

public Action<SwaggerApiDeclaration> ApiDeclarationFilter { get; set; }

public Action<SwaggerOperation> OperationFilter { get; set; }

public Action<SwaggerModel> ModelFilter { get; set; }

Populating OAuth Scopes using Roles isn’t appropriate default behavior as it isn’t an valid match for it but you should be able to customize the JSON returned with the above APIs. We can look at adding any missing properties or types that’s missing from the spec as needed.

If you’re using Open API Feature instead the metadata DTOs and returned JSON is based on Open API v2.0 specification.

1 Like