@@ -53,6 +53,34 @@ public static async Task<HttpResponseMessage> RenderSwaggerDocumentInJson(
5353 return response ;
5454 }
5555
56+ /// <summary>
57+ /// Invokes the HTTP trigger endpoint to get Swagger document in a format of YAML.
58+ /// </summary>
59+ /// <param name="req"><see cref="HttpRequestMessage"/> instance.</param>
60+ /// <param name="log"><see cref="ILogger"/> instance.</param>
61+ /// <returns>Swagger document in a format in YAML.</returns>
62+ [ FunctionName ( nameof ( OpenApiHttpTrigger . RenderSwaggerDocumentInYaml ) ) ]
63+ [ OpenApiIgnore ]
64+ public static async Task < HttpResponseMessage > RenderSwaggerDocumentInYaml (
65+ [ HttpTrigger ( AuthorizationLevel . Function , "get" , Route = "swagger.yml" ) ] HttpRequestMessage req ,
66+ ILogger log )
67+ {
68+ log . LogInformation ( $ "swagger.yaml was requested.") ;
69+
70+ var result = await context . Document
71+ . InitialiseDocument ( )
72+ . AddMetadata ( context . OpenApiInfo )
73+ . AddServer ( req , context . HttpSettings . RoutePrefix )
74+ . Build ( context . GetExecutingAssembly ( ) )
75+ . RenderAsync ( context . GetOpenApiSpecVersion ( V2 ) , context . GetOpenApiFormat ( YAML ) )
76+ . ConfigureAwait ( false ) ;
77+
78+ var content = new StringContent ( result , Encoding . UTF8 , context . GetOpenApiFormat ( YAML ) . GetContentType ( ) ) ;
79+ var response = new HttpResponseMessage ( HttpStatusCode . OK ) { Content = content } ;
80+
81+ return response ;
82+ }
83+
5684 /// <summary>
5785 /// Invokes the HTTP trigger endpoint to get Swagger document in a format of YAML.
5886 /// </summary>
@@ -109,6 +137,34 @@ public static async Task<HttpResponseMessage> RenderOpenApiDocumentV2InJson(
109137 return response ;
110138 }
111139
140+ /// <summary>
141+ /// Invokes the HTTP trigger endpoint to get Open API document v2 in a format of YAML.
142+ /// </summary>
143+ /// <param name="req"><see cref="HttpRequestMessage"/> instance.</param>
144+ /// <param name="log"><see cref="ILogger"/> instance.</param>
145+ /// <returns>Open API document v2 in a format of YAML.</returns>
146+ [ FunctionName ( nameof ( OpenApiHttpTrigger . RenderOpenApiDocumentV2InYaml ) ) ]
147+ [ OpenApiIgnore ]
148+ public static async Task < HttpResponseMessage > RenderOpenApiDocumentV2InYaml (
149+ [ HttpTrigger ( AuthorizationLevel . Function , "get" , Route = "openapi/v2.yml" ) ] HttpRequestMessage req ,
150+ ILogger log )
151+ {
152+ log . LogInformation ( $ "v2.yaml was requested.") ;
153+
154+ var result = await context . Document
155+ . InitialiseDocument ( )
156+ . AddMetadata ( context . OpenApiInfo )
157+ . AddServer ( req , context . HttpSettings . RoutePrefix )
158+ . Build ( context . GetExecutingAssembly ( ) )
159+ . RenderAsync ( context . GetOpenApiSpecVersion ( V2 ) , context . GetOpenApiFormat ( YAML ) )
160+ . ConfigureAwait ( false ) ;
161+
162+ var content = new StringContent ( result , Encoding . UTF8 , context . GetOpenApiFormat ( YAML ) . GetContentType ( ) ) ;
163+ var response = new HttpResponseMessage ( HttpStatusCode . OK ) { Content = content } ;
164+
165+ return response ;
166+ }
167+
112168 /// <summary>
113169 /// Invokes the HTTP trigger endpoint to get Open API document v2 in a format of YAML.
114170 /// </summary>
@@ -165,6 +221,34 @@ public static async Task<HttpResponseMessage> RenderOpenApiDocumentV3InJson(
165221 return response ;
166222 }
167223
224+ /// <summary>
225+ /// Invokes the HTTP trigger endpoint to get Open API document v3 in a format of YAML.
226+ /// </summary>
227+ /// <param name="req"><see cref="HttpRequestMessage"/> instance.</param>
228+ /// <param name="log"><see cref="ILogger"/> instance.</param>
229+ /// <returns>Open API document v3 in a format of YAML.</returns>
230+ [ FunctionName ( nameof ( OpenApiHttpTrigger . RenderOpenApiDocumentV3InYaml ) ) ]
231+ [ OpenApiIgnore ]
232+ public static async Task < HttpResponseMessage > RenderOpenApiDocumentV3InYaml (
233+ [ HttpTrigger ( AuthorizationLevel . Function , "get" , Route = "openapi/v3.yml" ) ] HttpRequestMessage req ,
234+ ILogger log )
235+ {
236+ log . LogInformation ( $ "v3.yaml was requested.") ;
237+
238+ var result = await context . Document
239+ . InitialiseDocument ( )
240+ . AddMetadata ( context . OpenApiInfo )
241+ . AddServer ( req , context . HttpSettings . RoutePrefix )
242+ . Build ( context . GetExecutingAssembly ( ) )
243+ . RenderAsync ( context . GetOpenApiSpecVersion ( V3 ) , context . GetOpenApiFormat ( YAML ) )
244+ . ConfigureAwait ( false ) ;
245+
246+ var content = new StringContent ( result , Encoding . UTF8 , context . GetOpenApiFormat ( YAML ) . GetContentType ( ) ) ;
247+ var response = new HttpResponseMessage ( HttpStatusCode . OK ) { Content = content } ;
248+
249+ return response ;
250+ }
251+
168252 /// <summary>
169253 /// Invokes the HTTP trigger endpoint to get Open API document v3 in a format of YAML.
170254 /// </summary>
0 commit comments