@@ -56,6 +56,9 @@ import {
5656} from "./constants" ;
5757import LocalRestApiPublicApi from "./api" ;
5858
59+ // Import openapi.yaml as a string
60+ import openapiYaml from "../docs/openapi.yaml" ;
61+
5962export default class RequestHandler {
6063 app : App ;
6164 api : express . Express ;
@@ -255,10 +258,10 @@ export default class RequestHandler {
255258 certificateInfo :
256259 this . requestIsAuthenticated ( req ) && certificate
257260 ? {
258- validityDays : getCertificateValidityDays ( certificate ) ,
259- regenerateRecommended :
260- ! getCertificateIsUptoStandards ( certificate ) ,
261- }
261+ validityDays : getCertificateValidityDays ( certificate ) ,
262+ regenerateRecommended :
263+ ! getCertificateIsUptoStandards ( certificate ) ,
264+ }
262265 : undefined ,
263266 apiExtensions : this . requestIsAuthenticated ( req )
264267 ? this . apiExtensions . map ( ( { manifest } ) => manifest )
@@ -1173,6 +1176,12 @@ export default class RequestHandler {
11731176 }
11741177
11751178 setupRouter ( ) {
1179+ // Serve /openapi.yaml unauthenticated
1180+ this . api . get ( "/openapi.yaml" , ( req , res ) => {
1181+ res . setHeader ( "Content-Type" , "application/yaml; charset=utf-8" ) ;
1182+ res . status ( 200 ) . send ( openapiYaml ) ;
1183+ } ) ;
1184+
11761185 this . api . use ( ( req , res , next ) => {
11771186 const originalSend = res . send ;
11781187 res . send = function ( body , ...args ) {
0 commit comments