Swagger failed to load api definition.

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 10.5
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? Net Core

When i try to acces swagger I get the following error:

Fetch error response status is 500/swagger/v1/swagger.json

I have looked at the knowledgebase but the only related answers were logged 3 or more years ago

here: https://support.aspnetzero.com/QA/Questions/6173/Swagger-Failed-to-load-API-definition and here: https://support.aspnetzero.com/QA/Questions/5531/Swagger-UI-Not-Found-swaggerv1swaggerjson

and in anycase my current configuration seems to correspond to the solutions provided.

Can anyone please help me?

Failed to load API definition is displayed on the Swagger Generation page

Environment

Product ProgressĀ® TelerikĀ® Reporting
Project Type ASP.NET Core

Description

"Failed to load API definition." message is displayed on the Swagger Generation page.

There may also be a short error on the page about being unable to fetch swagger.json.

Error Message

  • Error message on client-side:
Fetch error

response status is 500 https://localhost:{port}/swagger/v1/swagger.json
  • Server-side exception:
An unhandled exception has occurred while executing the request.
      Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Conflicting method/path combination "GET api/ReportDesignerControllerBase" for actions - Telerik.WebReportDesigner.Services.Controllers.ReportDesignerControllerBase.GetDesignerResource (Telerik.WebReportDesigner.Services),Telerik.WebReportDesigner.Services.Controllers.ReportDesignerControllerBase.GetResource (Telerik.WebReportDesigner.Services). Actions require a unique method/path combination for Swagger/OpenAPI 3.0. Use ConflictingActionsResolver as a workaround
         at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
         at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
         at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Cause

There is a confliction method/path in ReportDesignerController. Swagger requires actions to have unique methods/paths.

Solution

  • For .NET Core 3.1 and .NET 5, configure the Swagger Generation in Startup.cs:
 public void ConfigureServices(IServiceCollection services)
        {
        ...
            services.AddSwaggerGen(c => {
                c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
                c.IgnoreObsoleteActions();
                c.IgnoreObsoleteProperties();
                c.CustomSchemaIds(type => type.FullName);
                });
                ...
        }
  • For .NET 6, configure the Swagger Generation in Program.cs
builder.Services.AddSwaggerGen(c => {
    c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
    c.IgnoreObsoleteActions();
    c.IgnoreObsoleteProperties();
    c.CustomSchemaIds(type => type.FullName);
});

This documentation supports the 21.3 version of Action Request System.

To view an earlier version, select the version from the Product version menu.

The Swagger user interface (UI) is an HTML/JS web application that can be hosted on simple web servers such as Apache, Microsoft Internet Information Services (IIS), or Apache Tomcat. The Swagger UI provides a sample request response that helps to integrate  AR System server with the REST service.

This topic describes the most common issues that might occur while using the Swagger UI.

Symptoms

  • Pages are not displayed for the specified Jetty URLs.
  • Pages are not displayed for the specified Swagger URLs.
  • One of the following errors is displayed:
    Failed to load API definition on Swagger UI
    Or
    Possible cross-origin (CORS) issue
  • The API definition is not provided in the Swagger UI.

Scope

Swagger, being a third-party tool, does not affect other areas. If the Jetty server doesn't respond, the Swagger UI and other integrations that use the Jetty server do not work.

Resolution

Perform the following steps to troubleshoot an issue:

Step

Task

Description

1 Ensure that the Jetty server is running

By default, the Jetty server runs on port 8008 and port 8443. For more information, see the following documents:

  • Configuring the REST API by using SSL certificates
  • Troubleshooting the REST API
  • Knowledge article How to test if a webserver is responding to requests

2

Enable the Swagger UI

  • Follow the instructions in the Using the REST API with Swagger topic.
  • Ensure that you can access the Swagger UI through a URL.
    For example, http://TOMCAT:8080/swagger-ui/index.html
  • Do not use the file:// protocol to access the Swagger UI.
3 Remove the Cross-Origin Resource Sharing (CORS) restrictions

If the following error occurs in the Swagger UI, remove the CORS restrictions on the Jetty server:

Possible cross-origin (CORS) issue? The URL origin (http://[Not_localhost]:8008) does not match the page (http://localhost:8080/).

Swagger failed to load api definition.

For information about removing CORS restrictions, see the knowledge article How to avoid RSSO from filtering REST requests.

If the error prevails, Remedy SSO might be intercepting the requests.

4

Configure the Swagger UI to load AR System definitions

The Swagger UI shows a blank page or the following error:

No API definition provided

Swagger failed to load api definition.

This error can occur in the following circumstances:

  • Syntax errors in the index.html file, located in /swagger/dist/ folder.
  • The variable URL does not have adequate content.

For more information about configuring the Swagger UI, see the knowledge article How to configure swagger UI to load Remedy REST definitions.

5

Using swagger

You cannot use the Swagger UI to send attachments. For more information, see the knowledge article How to send Attachments into Remedy REST API.

After you determine a specific symptom or error message, use the following table to identify the solution:

SymptomLocationAction

AR System server version 19.08

Enable CORS settings for the Swagger UI. For more information, see the knowledge article REMEDY REST API - CORS setup for Swagger UI.

You don't get a response when you access a URL pointing to a REST API.
For example,
http://server:port/api/arsys/v1.0/swagger/ars-jwt.json

Swagger failed to load api definition.

AR System server version 9.x and later

Enable debug logs on the Jetty server and create a support case. For instructions on how to enable Jetty logs, see the knowledge article How to turn logging on for REST API problems

The browser receives no response when accessing the
Swagger UI. For example,
http://localhost:8080/arsys/shared/swagger/index.html

Swagger failed to load api definition.

Any web server hosting html or javascript

Ensure that the following conditions are met:

  • The HTTP server is up and running.
  • The HTTP server can host the HTML file.
  • The browser can run javascript files.

If the issue persists, document the steps followed to publish the Swagger UI web pages and create a support case. For more information, see Using the REST API with Swagger.

Was this page helpful? Yes No Submitting... Thank you

How do I check swagger error?

In case you face an error in Swagger when calling the data via shipper API, use this article to see the reason of the error..
Although Swagger shows the error code, the tool does not precisely describe the reason behind the error. ... .
Open the browser console (F12) and go to the network tab;.
Then try the same action again;.

How do I import API into Swagger?

Click Drafts in the UI navigation pane, and then click APIs. The APIs tab opens. Click Add and then select , OpenAPI (Swagger 2.0), or Import an existing OpenAPI from the Import section.

Where is swagger v1 swagger JSON?

Launch the app and navigate to https://localhost:<port>/swagger/v1/swagger.json . The generated document describing the endpoints appears as shown in OpenAPI specification (openapi. json). The Swagger UI can be found at https://localhost:<port>/swagger .

How do I add swagger to Visual Studio?

Installing Swagger from NuGet Package Manager, from Visual Studio project,.
Right click Tools > NuGet Package Manager > Manage NuGet for Solution..
In the opened NuGet-Solution dialog: Click Browse, then Search Swagger..
Install Swashbuckle v5. 6.0..