Skip to content

Commit 7ce1d0f

Browse files
Disable NSwag caching
Allow "fairer" comparison benchmarks by disabling the ability of NSwag's middleware to cache the generated OpenAPI document.
1 parent abaac7d commit 7ce1d0f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/TodoApp/OpenApi/NSwag/NSwagOpenApiEndpoints.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public static T UseNSwagOpenApi<T>(this T builder)
9090
}
9191
};
9292
};
93+
94+
// For the purposes of comparison with the other implementations in the benchmarks,
95+
// disable document caching. Otherwise, NSwag will only generate the OpenAPI document
96+
// once and every request for the OpenAPI document becomes essentially "free".
97+
settings.CreateDocumentCacheKey = (_) => Guid.NewGuid().ToString();
9398
});
9499

95100
return builder;

0 commit comments

Comments
 (0)