Are people seriously using this in production code?
See original GitHub issueI don’t mean to be mean or disrespectful, but looking at the examples such as:
// Add these three attribute classes below
[OpenApiOperation(operationId: "greeting", tags: new[] { "greeting" }, Summary = "Greetings", Description = "This shows a welcome message.", Visibility = OpenApiVisibilityType.Important)]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiParameter("name", Type = typeof(string), In = ParameterLocation.Query, Visibility = OpenApiVisibilityType.Important)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Greeting), Summary = "The response", Description = "This returns the response")]
[Function("Net60HttpTrigger")]
public static async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "greetings")] HttpRequestData req,
FunctionContext executionContext)
{
}
Besides being a hard to read these are horrible to maintain. In previous versions when one could use swagger the documentation was made from what was actually in the code. With the above everything from the request parameters to the response data is in attributes. How long is it going to take before one of those is out of sync with the actual request parameters or response types.
I mean this might be fine for a hello world or some simple one developer site with few requests… But for a normal sized site with multiple developers and 100s or more different methods being exposed… This will just be one big mess.
I tried to see if there is some type of roadmap where auto generation of the specifications is in the future (which I dearly hope) but I could not find anything about that.
… or am I missing some big point here which makes this all very useful?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:14 (5 by maintainers)
This could be done via a Roslyn Analyzer. I think the real answer is that it’s hard to dive deep in code and truly understand wrapped responses.
Let’s duscuss further. I’m also interested in this type of “linting” process. I don’t think it’s possible during the compile time, but it may be possible during the runtime (startup time).