Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Swagger - public api definition #7919


User avatar
0
p.j.keukens created

Hi,

I'm using the aspnet zero .net core and jquery version 6.9, I've just added swagger to my project which is working fine. But I would like swagger to only show a few of the actions. For example I would only like to show "api/TokenAuth/Authenticate" and "api/Cars/GetAll". There are more calls that are used by the application and that are generated which is fine but I don't want them to appear in the public swagger api definition.

Is there a way to configure which methods show up in Swagger (but still generate all api's as they are needed by the web application)?

Best regards,

Patrick


6 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    You can also use the RemoteService attribute for any service or method definition to enable or disable (IsEnabled) the dynamic API or API explorer settings (IsMetadataEnabled).

    [RemoteService(IsMetadataEnabled = false)]
    

  • User Avatar
    0
    p.j.keukens created

    When I add [RemoteService(IsMetadataEnabled = false)] or [RemoteService(IsEnabled = false)] then it doesn't show in swagger but also the application doesn't work anymore because those services can't be reached through javascript.

    So I need some thing to remove it from swagger but in a way that the methods can still be accessed by the application through javascript.

  • User Avatar
    0
    maliming created
    Support Team

    can still be accessed by the application through javascript.

    Do you mean that these methods are not available in service-proxies.ts?

  • User Avatar
    0
    p.j.keukens created

    No for example I have a view with a datatable on there, in je javascript file I call the app service like so:

    var _carService = abp.services.app.car;
    
    var dataTable = _$opticianInsurancesTable.DataTable({
                paging: true,
                serverSide: true,
                processing: true,
    listAction: {
                    ajaxFunction:  _carService.getAll
    

    but when I decorate the car app service with Remote services the _carService.getAll doesn't work anymore.

    [RemoteService(IsMetadataEnabled = false)]
        [AbpAuthorize(AppPermissions.Pages_Cars)]
        public class CarAppService : CarAppServiceBase, ICarAppService
    
  • User Avatar
    0
    maliming created
    Support Team

    Sorry, I thought you were using angular. You can refer to this: https://support.aspnetzero.com/QA/Questions/4380

  • User Avatar
    0
    p.j.keukens created

    That worked! Thanks