MCPcopy Create free account
hub / github.com/loopbackio/loopback-next / _redirectToSwaggerUI

Method _redirectToSwaggerUI

packages/rest/src/rest.server.ts:567–592  ·  view source on GitHub ↗
(
    request: Request,
    response: Response,
    next: express.NextFunction,
  )

Source from the content-addressed store, hash-verified

565 }
566 }
567 private async _redirectToSwaggerUI(
568 request: Request,
569 response: Response,
570 next: express.NextFunction,
571 ) {
572 const config = this.config.apiExplorer;
573
574 if (config.disabled) {
575 debug('Redirect to swagger-ui was disabled by configuration.');
576 next();
577 return;
578 }
579
580 debug('Redirecting to swagger-ui from %j.', request.originalUrl);
581 const requestContext = new RequestContext(
582 request,
583 response,
584 this,
585 this.config,
586 );
587 const protocol = requestContext.requestedProtocol;
588 const baseUrl = protocol === 'http' ? config.httpUrl : config.url;
589 const openApiUrl = `${requestContext.requestedBaseUrl}/openapi.json`;
590 const fullUrl = `${baseUrl}?url=${openApiUrl}`;
591 response.redirect(302, fullUrl);
592 }
593
594 /**
595 * Register a controller class with this server.

Callers 1

Calls 1

redirectMethod · 0.45

Tested by

no test coverage detected