Azure / Azure/azure-functions-openapi-extension

HttpTrigger attribute on custom model isn't rendered

Open
#507 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

**Describe the issue**
As per Microsoft documentation, the HttpTrigger attribute can be placed on a custom model instead the HttpRequest.
If this is **not** the first parameter in the function then the method is ignored when generating the OpenApi/swagger spec.

[Edit]
If the HttpTrigger is **not** annotated on the first parameter, regardless of whether it is a custom model or the HttpRequest, the method is ignored.

**To Reproduce**
Create a Function with an HttpTrigger attribute on a custom type, first parameter.
Create a Function with an HttpTrigger attribute on a custom type, second parameter, with the first being `HttpRequest.`

**Expected behavior**
Both endpoints should be visible in the OpenApi spec

```
[FunctionName(nameof(GetThing))]
public async Task GetThing(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "thing/{id:int}")]
HttpRequest req,
int id,
ExecutionContext context) { }

[FunctionName(nameof(CreateThing))]
public async Task CreateThing(
HttpRequest req,
[HttpTrigger(AuthorizationLevel.Function, "POST", Route = "thing")]
Thing thing,
ExecutionContext context) { }
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two Function signatures described in the issue, with HttpTrigger on the first and second parameters, and compare the generated OpenAPI/Swagger spec. Done means both endpoints are visible in the spec, including the endpoint using a custom model.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.